⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zhucheframe.cs

📁 独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 
💻 CS
📖 第 1 页 / 共 4 页
字号:
			}
			else if (this.QuanXianHaoCombo.Text.Equals(""))
			{
				MessageBox.Show(this,"权限级别号不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				this.QuanXianHaoCombo.Focus();
				return false;
			}
			return true;
		}
		#endregion
		#region 返回数据集而已...
		private DataTable returnUser()
		{
			DataTable dataTableUser=new DataTable();
			try
			{
                string strSelectUser="select distinct 用户号 from System_UserTable";
				dataTableUser=ExcuteSql(strSelectUser,"System_UserTable");
			}
			catch(Exception ele)
			{
				ele.ToString();
			}
			return dataTableUser;
		}
		#endregion
		#region 判断用户是否存在...
		private bool UserIsNot()
		{
			bool f=true;
			DataTable selUser=new DataTable();
			selUser=returnUser();
			for(int i=0;i<selUser.Rows.Count;i++)
			{
				if(selUser.Rows[i][0].ToString().Equals(this.textUserHao.Text.ToString()))
				{
					MessageBox.Show(this,"已经存在该项啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					this.btnAddUser.Enabled=false;
					f=false;
				}
			}
			return f;
		}
		#endregion
		#region  清空函数
		private void ClearText()
		{
			this.textUserHao.Text="";
			this.textUserName.Text="";
			this.textUserPassword.Text="";
			this.textUserRepassword.Text="";
		}
		#endregion 
		#region DataFunction
		private DataTable ExcuteSql(string strSql,string tableName)
		{
			DataSet dsSet=new DataSet();
			DataTable dsTable=new DataTable();
			try
			{
				dsSet=conn.ExcuteDataSetResult(strSql,tableName);
				dsTable=dsSet.Tables[0];
			}
			catch(Exception eles)
			{
				MessageBox.Show(this,eles.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return dsTable;
		}
		#endregion
		#region 添加函数...
		private void AddUser()
		{
			if(this.CheckNull().Equals(false))
			{
				return;
			}
			bool bluser=UserIsNot();
			if(bluser.Equals(false))
			{
				return;
			}
			try
			{
				string str="";
				password=this.textUserRepassword.Text.ToString();
				//string userpassword=toMD5.toJiaMi(password);
				string userpassword=MD4.EncryptString(password);
                string insertUserSql="Insert into System_UserTable(用户号,用户名称,密码,用户类型)values('"+this.textUserHao.Text.ToString()+"','"+this.textUserName.Text.ToString()+"','"+userpassword+"','"+this.QuanXianHaoCombo.Text.ToString()+"')";
                int k=conn.ExcuteStrSql(insertUserSql);
				if(k>0)
				{
					str="添加成功";
                    MessageBox.Show(this,"添加成功啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    zhecheHistory(str);
					ClearText();
				}
				else
				{
					str="添加失败";
                    zhecheHistory(str);
					MessageBox.Show(this,"添加失败啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					ClearText();
				}
			}
			catch(Exception exe)
			{
				exe.ToString();
			}
		}
		#endregion
		#region 修改函数...
		private void ModifyUser()
		{
			try
			{
				string str="";
                string updateSql="update System_UserTable set 用户名称='"+this.textUserName.Text.ToString()+"', 密码='"+MD4.EncryptString(this.textUserRepassword.Text.ToString())+"', 用户类型='"+this.QuanXianHaoCombo.Text+"'where 用户号='"+this.textUserHao.Text.ToString()+"'";
				int j=conn.ExcuteStrSql(updateSql);
				if(j>0)
				{
                    str="修改成功";
					zhecheHistory(str);
					MessageBox.Show(this,"用户修改成功啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					ClearText();
				}
				else
				{
					str="修改失败";
					zhecheHistory(str);
					MessageBox.Show(this,"用户修改失败啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					ClearText();
				}
			}
			catch(Exception exe)
			{
				exe.ToString();
			}
		}
		#endregion
		#region 删除函数...
		private void DeleteUser()
		{
			try
			{
				string str="";
				string updateSql="delete from System_UserTable where 用户号='"+this.textUserHao.Text+"' and 用户名称='"+this.textUserName.Text+"'and 密码='"+MD4.EncryptString(this.textUserRepassword.Text)+"'and 用户类型='"+this.QuanXianHaoCombo.Text+"'";
				int j=conn.ExcuteStrSql(updateSql);
				if(j>0)
				{
					str="删除成功";
					zhecheHistory(str);
					MessageBox.Show(this,"用户删除成功啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					ClearText();
				}
				else
				{
					str="删除失败";
					zhecheHistory(str);
					MessageBox.Show(this,"用户删除失败啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					ClearText();
				}
			}
			catch(Exception exe)
			{
				exe.ToString();
			}
		}
		#endregion
		#region 读取函数...
		private void Readuser()
		{
			bool bluser=UserIsNot();
			if(bluser.Equals(false))
			{
				this.btnDelete.Enabled=true;
				this.btnModifyUser.Enabled=true;
				this.btnAddUser.Enabled=false;
				this.textUserName.Enabled=true;
				this.textUserPassword.Enabled=true;
				this.textUserRepassword.Enabled=true;
				this.QuanXianHaoCombo.Enabled=true;
				try
				{
                    string selctUser="select * from System_UserTable where 用户号='"+this.textUserHao.Text+"'";
					DataTable alluserTable=new DataTable();
					alluserTable=ExcuteSql(selctUser,"System_UserTable");
					for(int u=0;u<alluserTable.Rows.Count;u++)
					{
						if(alluserTable.Rows[u][0].ToString().Equals(this.textUserHao.Text.ToString()))
						{
							this.textUserName.Text=alluserTable.Rows[u][1].ToString().Trim();
							this.textUserPassword.Text=MD4.DecryptString(alluserTable.Rows[u][2].ToString().Trim());
							this.textUserRepassword.Text=this.textUserPassword.Text;
							this.QuanXianHaoCombo.Text=alluserTable.Rows[u][3].ToString().Trim();
						}
						else
						{
							ClearText();
							this.btnDelete.Enabled=false;
							this.btnModifyUser.Enabled=false;
							this.btnAddUser.Enabled=true;
							this.btnRead.Enabled=false;
							MessageBox.Show(this,"不存该用户请你添加一个吧!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
						}
					}
				}
				catch(Exception exe)
				{
					exe.ToString();
				}
			}
			else
			{
				this.btnDelete.Enabled=false;
				this.btnModifyUser.Enabled=false;
				this.btnAddUser.Enabled=true;
				this.textUserName.Enabled=true;
				this.textUserPassword.Enabled=true;
				this.QuanXianHaoCombo.Enabled=true;
				this.textUserRepassword.Enabled=true;
				ClearText();
			}
		}
		#endregion
		#region 初始化开始...
		private void ZhuCheFrame_Load(object sender, System.EventArgs e)
		{
			#region 初始化用户类型列表框...
			try
			{
				DataTable user=new DataTable();
				user=ExcuteSql(userTypeSql,"System_UserTable");
				for(int l=0;l<user.Rows.Count;l++)
				{
					this.QuanXianHaoCombo.Items.Add(user.Rows[l][0].ToString());
				}
			}
			catch(Exception exe)
			{
				exe.ToString();
			}
			#endregion
			#region 初始化各个控件...
			//this.textUserHao.Text=selecMaxCount().ToString();
			this.btnAddUser.Enabled=false;
			this.btnModifyUser.Enabled=false;
			this.btnDelete.Enabled=false;
			this.textUserName.Enabled=false;
			this.textUserRepassword.Enabled=false;
			this.textUserPassword.Enabled=false;
			this.QuanXianHaoCombo.Enabled=false;
			this.dateLabel.Text="日期:"+System.DateTime.Now.ToLongDateString().Trim();
			#endregion
		}
		#endregion
		#region 读取按钮事件...
		private void btnRead_Click(object sender, System.EventArgs e)
		{
			if(this.textUserHao.Text.Equals(""))
			{
                MessageBox.Show(this,"用户号不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				this.textUserHao.Focus();
			}
			else
			{
				if(this.textUserHao.Text.Equals("101"))
				{
					MessageBox.Show(this,"错误,此号码不能使用啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					this.textUserHao.Focus();
					this.textUserHao.Text="";
					ClearText();
					this.btnAddUser.Enabled=false;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -