using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace FrmManagement_System
{
public partial class FrmInsert : Form
{
DBHelper helper = new DBHelper();
public FrmInsert()
{
InitializeComponent();
}
#region 去登录
private void btnLogin1_Click(object sender, EventArgs e)
{
FrmLogin login = new FrmLogin();
login.Show();
this.Hide();
}
#endregion
private void btnSave_Click(object sender, EventArgs e)
{
if (Insert()==true)
{
InsertInto();
}
}
private void InsertInto()
{
try
{
helper.OpenConnection();
string sql = string.Format(@"INSERT INTO [Login]
([UserName]
,[passWord]
,[pwd]
,[Email])
VALUES
('{0}'
,'{1}'
,'{2}',
'{3}')", this.txtName.Text.Trim(), this.txtPass.Text.Trim(), this.txtPwd.Text.Trim(),this.txtEmail.Text.Trim());
SqlCommand comm = new SqlCommand(sql, helper.Connection);
int iRet=comm.ExecuteNonQuery();
if (iRet>0)
{
MessageBox.Show("添加成功");
}
else
{
MessageBox.Show("添加失败");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
helper.CloseConnection();
}
}
private bool Insert()
{
if (this.txtPass.Text.Trim()==string.Empty)
{
MessageBox.Show("密码不为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
if (this.txtName.Text.Trim() == string.Empty)
{
MessageBox.Show("用户名不为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
if (this.txtPwd.Text.Trim() == string.Empty)
{
MessageBox.Show("确认密码不为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
if (this.txtEmail.Text.Trim() == string.Empty)
{
MessageBox.Show("邮箱不为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
if (this.txtPwd.Text.Trim()!=this.txtPass.Text.Trim())
{
MessageBox.Show("两次密码不正确", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
return true;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace FrmManagement_System
{
public partial class FrmLogin : Form
{
DBHelper helper = new DBHelper();
public FrmLogin()
{
InitializeComponent();
}
#region 取消
private void btnclose_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确认取消登录吗?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result==DialogResult.Yes)
{
Application.Exit();
}
}
#endregion
#region 注册
private void btnenroll_Click(object sender, EventArgs e)
{
FrmInsert insert = new FrmInsert();
insert.Show();
this.Hide();
}
#endregion
#region 登录
private void btnLogin_Click(object sender, EventArgs e)
{
if (Login()==true)
{
LoginP();
}
}
private bool LoginP()
{
try
{
helper.OpenConnection();
String sql = string.Format(@"SELECT [id]
,[UserName]
,[passWord]
FROM [Login]
where UserName='{0}' and passWord='{1}'",this.txtName.Text.Trim(),this.txtPass.Text.Trim());
SqlCommand comm = new SqlCommand(sql, helper.Connection);
int iRet=Convert.ToInt32(comm.ExecuteScalar());
if (iRet>0)
{
MessageBox.Show("登录成功");
FrmMangment Mangment = new FrmMangment();
Mangment.User = this.txtName.Text.Trim();
Mangment.Pwd = this.txtPass.Text.Trim();
Mangment.Show();
this.Hide();
return true;
}
else
{
MessageBox.Sh
C#高校人力管理系统
本文探讨了如何使用C#编程语言开发高效的高校人力管理系统。内容涉及系统设计、功能实现以及C#相较于Java的独特优势。通过实例,展示了C#在数据处理、界面交互等方面的高效性能。
摘要由CSDN通过智能技术生成