searchuserpeodomframe.cs

来自「独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 」· CS 代码 · 共 689 行 · 第 1/3 页

CS
689 行
字号
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnDelete);
			this.Controls.Add(this.btnModify);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.dataGrid);
			this.Controls.Add(this.TitleLabel);
			this.Controls.Add(this.label1);
			this.Cursor = System.Windows.Forms.Cursors.Hand;
			this.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.HelpButton = true;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "searchUserPeodomFrame";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "searchUserPeodomFrame";
			this.Load += new System.EventHandler(this.searchUserPeodomFrame_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.system_PopedomSet)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		#region InitEvent...
		private void searchUserPeodomFrame_Load(object sender, System.EventArgs e)
		{
			#region initDataGrid...
			try
			{
				this.sqlDataAdapter.Fill(this.system_PopedomSet);
				DataTable tempTable=new DataTable();
				//tempTable=DataConnection.DataConnection.ExcuteSql("select distinct 权限名称 from System_PopedomTable","System_PopedomTable");
				tempTable=system_PopedomSet.Tables[0];
				this.dataGrid.DataSource=tempTable;
				this.cmOrder=(System.Windows.Forms.CurrencyManager) BindingContext[system_PopedomSet.Tables[0]];
				this.textPeodomID.DataBindings.Add("Text",system_PopedomSet.Tables[0],"编号");
				this.textPeodomName.DataBindings.Add("Text",system_PopedomSet.Tables[0],"权限名称");
				this.textPeodomStatus.Text="普通用户";
				#region 判断当前用户...
				if(landFrame.strName.Equals("管理员"))
				{
					this.btnAdd.Enabled=true;
					this.btnCancel.Enabled=true;
					this.btnDelete.Enabled=true;
					this.btnModify.Enabled=true;
					this.textPeodomStatus.Cursor=System.Windows.Forms.Cursors.IBeam;
					this.textPeodomName.Cursor=System.Windows.Forms.Cursors.IBeam;
					this.textPeodomID.Cursor=System.Windows.Forms.Cursors.IBeam;
				}
				else
				{
					this.btnAdd.Enabled=true;
					this.btnCancel.Enabled=true;
					this.btnDelete.Enabled=false;
					this.btnModify.Enabled=false;
					this.textPeodomStatus.Cursor=System.Windows.Forms.Cursors.IBeam;
					this.textPeodomName.Cursor=System.Windows.Forms.Cursors.IBeam;
					this.textPeodomID.Cursor=System.Windows.Forms.Cursors.IBeam;
				}
				#endregion
				#region initStatus
				this.currentUser.Text="当前用户:"+landFrame.strName;
				#endregion
				#region initTime
				this.currentPeodom.Text="操作权限:"+this.dataGrid[this.dataGrid.CurrentRowIndex,1];
				this.dateLabel.Text="当前日期:"+System.DateTime.Now.ToLongDateString().Trim();
				//this.TimeLabel.Text="当前时间:"+dealTime.dealTime.dealTimeString(System.DateTime.Now.Hour,System.DateTime.Now.Minute,System.DateTime.Now.Second).Trim();
				#endregion
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			#endregion
		}
		#endregion
		#region 光标移动变化...
		private void btnCancel_MouseLeave(object sender, System.EventArgs e)
		{
		    ButtonVarible.buttonVarble.MouseLeaved(sender,e);
		}

		private void btnCancel_MouseEnter(object sender, System.EventArgs e)
		{
		    ButtonVarible.buttonVarble.MouseEntered(sender,e);
		}
		private void textPeodomID_MouseLeave(object sender, System.EventArgs e)
		{
			MouseStyle.TextBox.MouseLeaved(sender,e);
		}

		private void textPeodomID_MouseEnter(object sender, System.EventArgs e)
		{
			MouseStyle.TextBox.MouseEntered(sender,e);
		}
		#endregion
		#region  添加事件...
		private void btnAdd_Click(object sender, System.EventArgs e)
		{
		   this.cmOrder.AddNew();
		   this.SetModify(true);
		   this.textPeodomID.Text="";
		   this.textPeodomName.Text="";
		}
		#endregion
		#region 修改事件...
		private void btnModify_Click(object sender, System.EventArgs e)
		{
		    this.SetModify(true);
		}
		#endregion
		#region  删除事件....
		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			this.SetModify(false);
			if(this.cmOrder.Count>0)
			{
				this.cmOrder.RemoveAt(this.cmOrder.Position);
				this.sqlDataAdapter.Update(this.system_PopedomSet);
			}
			else
			{
				//MessageBox.Show(this,"表已经没有数据啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				return;
			}
		}
		#endregion
		#region 取消事件...
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			if(this.CheckNull().Equals(true))
			{
				return;
			}
			else if(this.Alreadly().Equals(true))
			{
				return;
			}
			else
			{
				this.cmOrder.EndCurrentEdit();
				if(this.system_PopedomSet.GetChanges()!=null)
				{
					try
					{
						this.sqlDataAdapter.Update(this.system_PopedomSet);
						this.SetModify(false);
					}
					catch(Exception ele)
					{
						this.system_PopedomSet.RejectChanges();
						ele.ToString();
					}
				}
			}
		}
		#endregion
		#region CheckNull()
		private bool CheckNull()
		{
           bool t=false;
			if(this.textPeodomID.Text.Equals(""))
			{
				MessageBox.Show(this,"编号不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				t=true;
				this.textPeodomID.Focus();
			}
			else if(this.textPeodomName.Text.Equals(""))
			{
				MessageBox.Show(this,"编号不能为空!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				t=true;
				this.textPeodomName.Focus();
			}
			
		   return t;
		}
		#endregion
		#region   SetModify()
		private void SetModify(bool f)
		{
            this.textPeodomID.Enabled=f;
			this.textPeodomName.Enabled=f;
		}
		#endregion
		#region  IFAlreadly()
		private bool Alreadly()
		{
			bool f=false;
			try
			{
                DataTable tempTablePeodomTable=new DataTable();
				tempTablePeodomTable=DataConnection.DataConnection.ExcuteSql("select * from System_PopedomTable","System_PopedomTable");
				for(int i=0;i<tempTablePeodomTable.Rows.Count;i++)
				{
					if(tempTablePeodomTable.Rows[i][0].ToString().Trim().Equals(this.textPeodomID.Text.ToString()) && tempTablePeodomTable.Rows[i][1].ToString().Trim().Equals(this.textPeodomName.Text.ToString().Trim()))
					{
                        MessageBox.Show(this,"此权限已经存在啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
						f=true;
						this.textPeodomID.Text="";
						this.textPeodomName.Text="";
						this.textPeodomID.Focus();
						return f;
					}
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			return f;
		}
		#endregion
		#region 当前浏览权限列表时的事件...
		private void dataGrid_CurrentCellChanged(object sender, System.EventArgs e)
		{
		    this.currentPeodom.Text="操作权限:"+this.dataGrid[this.dataGrid.CurrentRowIndex,1];
		}
		#endregion
		#region 处理时间事件....
		private void currentTime_Tick(object sender, System.EventArgs e)
		{
			this.TimeLabel.Text="当前时间:"+dealTime.dealTime.dealTimeString(System.DateTime.Now.Hour,System.DateTime.Now.Minute,System.DateTime.Now.Second).Trim();
		}
		#endregion
	}
}

⌨️ 快捷键说明

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