manage_form.cs

来自「第三方物流信息管理平台 1、数据库配置: 需要打开MS SQL SERVE」· CS 代码 · 共 516 行 · 第 1/2 页

CS
516
字号
			this.label6.Location = new System.Drawing.Point(16, 256);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(136, 24);
			this.label6.TabIndex = 6;
			this.label6.Text = "管理员电子邮件";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(24, 296);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(216, 21);
			this.textBox2.TabIndex = 7;
			this.textBox2.Text = "";
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(96, 80);
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(160, 21);
			this.textBox3.TabIndex = 8;
			this.textBox3.Text = "";
			// 
			// textBox4
			// 
			this.textBox4.Location = new System.Drawing.Point(96, 120);
			this.textBox4.Name = "textBox4";
			this.textBox4.Size = new System.Drawing.Size(160, 21);
			this.textBox4.TabIndex = 9;
			this.textBox4.Text = "";
			// 
			// textBox5
			// 
			this.textBox5.Location = new System.Drawing.Point(96, 168);
			this.textBox5.Name = "textBox5";
			this.textBox5.Size = new System.Drawing.Size(160, 21);
			this.textBox5.TabIndex = 10;
			this.textBox5.Text = "";
			// 
			// textBox6
			// 
			this.textBox6.Location = new System.Drawing.Point(96, 216);
			this.textBox6.Name = "textBox6";
			this.textBox6.Size = new System.Drawing.Size(160, 21);
			this.textBox6.TabIndex = 11;
			this.textBox6.Text = "";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(264, 32);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(24, 24);
			this.label7.TabIndex = 12;
			this.label7.Text = "*";
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(264, 80);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(24, 24);
			this.label8.TabIndex = 13;
			this.label8.Text = "*";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(264, 120);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(24, 24);
			this.label9.TabIndex = 14;
			this.label9.Text = "*";
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(264, 168);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(24, 24);
			this.label10.TabIndex = 15;
			this.label10.Text = "*";
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(256, 296);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(24, 24);
			this.label11.TabIndex = 16;
			this.label11.Text = "*";
			// 
			// manage_Form
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(672, 421);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.groupBox1,
																		  this.dataGrid1,
																		  this.toolBar1});
			this.Name = "manage_Form";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "管理员信息维护";
			this.Load += new System.EventHandler(this.manage_Form_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void DataGridStateControl()
		{
			
			DataGridTableStyle ts = new DataGridTableStyle();
			ts.AlternatingBackColor = Color.LightGray;
			ts.MappingName = this.ds.Tables[0].TableName;
			ts.AllowSorting = false;
			this.dataGrid1.TableStyles.Add(ts);
		}

		private void DataBingingsFunction()
		{
			this.textBox1.DataBindings.Add("Text",ds.Tables[0],"管理员帐号");

			this.textBox2.DataBindings.Add("Text",ds.Tables[0],"管理员电子邮件");

			this.textBox3.DataBindings.Add("Text",ds.Tables[0],"管理员姓名");

			this.textBox4.DataBindings.Add("Text",ds.Tables[0],"所属部门");

			this.textBox5.DataBindings.Add("Text",ds.Tables[0],"管理员密码");

			this.textBox6.DataBindings.Add("Text",ds.Tables[0],"管理员电话");

		}

		private void manage_Form_Load(object sender, System.EventArgs e)
		{
			
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			string email=this.textBox2.Text.Trim();
			char[] emailchar=new char[email.Length];
			bool ss=false;
			
			
			if(e.Button.ToolTipText=="退出")
			{
				this.Close();
			}
			

			if (e.Button.ToolTipText == "新增")
			{
				cmAmend.AddNew();
				return;
			}
			if (e.Button.ToolTipText == "删除")
			{
				if (MessageBox.Show("      确实要删除这条记录吗?","询问",MessageBoxButtons.YesNo) == DialogResult.Yes)
				{
					try
					{
						if (cmAmend.Count > 0)
							cmAmend.RemoveAt(cmAmend.Position);
						else
						{
							MessageBox.Show("没有可以删除的数据","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
						}
					}
					catch(Exception express)
					{
						MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					}
					return;
				}
			}
			if (e.Button.ToolTipText == "修改")//保存对数据所作的修改
			{
				try
				{
					int row = this.dataGrid1.CurrentCell.RowNumber;
					//将当前所在行往下移动一行,为便于实现同步保存
					//(否则会出现修改的最后一行无法保存,因为它还处于编辑状态)
					this.dataGrid1.CurrentCell = new DataGridCell(row+1,0); 
					if (this.ds.HasChanges())
					{
						this.link.UpdateDataBase(this.ds.GetChanges(),sendTableName);
						MessageBox.Show("数据修改成功!","信息");
					}
					else
					{
						MessageBox.Show("没有需要修改的数据!");
						return;
					}
				}
				catch
				{
					MessageBox.Show("数据保存失败,请确认所有信息输入完整且正确!","提示");
					return;
				}
			}
			if (e.Button.ToolTipText == "提交")
			{
				if (this.textBox1.Text.Trim() == ""||this.textBox2.Text.Trim()==""||this.textBox3.Text.Trim()==""||this.textBox4.Text.Trim()==""||this.textBox5.Text.Trim()=="")//检查不能为空的字段
				{
					MessageBox.Show("带*号的栏目不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					return;
				}
				 emailchar=email.ToCharArray();
				
				for(int i=0;i<email.Length;i++)
				{
					Console.Write(emailchar[i]);
					if(emailchar[i]=='@')
					ss=true;
					else
						ss=false;
						
				}
				if(!ss)
				{
					MessageBox.Show("请输入正确的邮件地址!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					return;
				}
				
				cmAmend.EndCurrentEdit();//结束当前编辑操作并提交修改
				if (ds.GetChanges() != null)
				{
					try
					{
						this.link.UpdateDataBase(this.ds.GetChanges(),sendTableName);
					}
					catch(Exception express)
					{
						MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
						this.ds.Tables [0].RejectChanges();
					}
					
				}
				return;		
			}



		}
	
	
	
	
	
	
	
	
	
	
	
	
	}
}

⌨️ 快捷键说明

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