📄 form5.cs
字号:
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// button1
//
this.button1.Location = new System.Drawing.Point(288, 208);
this.button1.Name = "button1";
this.button1.TabIndex = 3;
this.button1.Text = "向上";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(288, 240);
this.button2.Name = "button2";
this.button2.TabIndex = 4;
this.button2.Text = "向下";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(360, 272);
this.button3.Name = "button3";
this.button3.TabIndex = 5;
this.button3.Text = "保存";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(88, 144);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(64, 23);
this.button4.TabIndex = 6;
this.button4.Text = "更新";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.txtunit2);
this.groupBox2.Controls.Add(this.txtpassword2);
this.groupBox2.Controls.Add(this.txtname2);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.button8);
this.groupBox2.Controls.Add(this.button4);
this.groupBox2.Location = new System.Drawing.Point(288, 16);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(160, 184);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "原操作员";
//
// txtunit2
//
this.txtunit2.Location = new System.Drawing.Point(56, 104);
this.txtunit2.Name = "txtunit2";
this.txtunit2.Size = new System.Drawing.Size(96, 21);
this.txtunit2.TabIndex = 5;
this.txtunit2.Text = "";
//
// txtpassword2
//
this.txtpassword2.Location = new System.Drawing.Point(56, 64);
this.txtpassword2.Name = "txtpassword2";
this.txtpassword2.Size = new System.Drawing.Size(96, 21);
this.txtpassword2.TabIndex = 4;
this.txtpassword2.Text = "";
//
// txtname2
//
this.txtname2.Location = new System.Drawing.Point(56, 24);
this.txtname2.Name = "txtname2";
this.txtname2.Size = new System.Drawing.Size(96, 21);
this.txtname2.TabIndex = 3;
this.txtname2.Text = "";
//
// label7
//
this.label7.Location = new System.Drawing.Point(8, 104);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(48, 23);
this.label7.TabIndex = 2;
this.label7.Text = "权限";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label6
//
this.label6.Location = new System.Drawing.Point(8, 64);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(48, 23);
this.label6.TabIndex = 1;
this.label6.Text = "密码";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 24);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(48, 23);
this.label5.TabIndex = 0;
this.label5.Text = "用户名";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// button8
//
this.button8.Location = new System.Drawing.Point(8, 144);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(64, 23);
this.button8.TabIndex = 9;
this.button8.Text = "删除";
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button9
//
this.button9.Location = new System.Drawing.Point(560, 264);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(75, 32);
this.button9.TabIndex = 7;
this.button9.Text = "关闭";
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// linkLabel1
//
this.linkLabel1.LinkColor = System.Drawing.Color.Red;
this.linkLabel1.Location = new System.Drawing.Point(464, 208);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.TabIndex = 8;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "查看权限代号";
this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// Form5
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(648, 314);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.button9);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.label1);
this.ForeColor = System.Drawing.Color.Blue;
this.Name = "Form5";
this.Text = "Form5";
this.Load += new System.EventHandler(this.Form5_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
try
{
this.dataGrid1.UnSelect(this.dataGrid1.CurrentRowIndex);
if(this.dataGrid1.CurrentRowIndex >0)
this.dataGrid1.CurrentRowIndex --;
this.dataGrid1.Select(this.dataGrid1.CurrentRowIndex);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
private void button2_Click(object sender, System.EventArgs e)
{
try
{
this.dataGrid1.CurrentRowIndex = this.BindingContext[dataSet21.Tables["goodpass"]].Position;
this.dataGrid1.UnSelect(this.dataGrid1.CurrentRowIndex);
this.BindingContext[dataSet21.Tables["goodpass"]].Position++;
this.dataGrid1.CurrentRowIndex = this.BindingContext[dataSet21.Tables["goodpass"]].Position;
this.dataGrid1.Select(this.dataGrid1.CurrentRowIndex);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
private void Form5_Load(object sender, System.EventArgs e)
{
this.txtname2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet21.goodpass, "name"));
this.txtpassword2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet21.goodpass, "password"));
this.txtunit2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet21.goodpass, "unit"));
this.sqlDataAdapter1.Fill(dataSet21,"goodpass");
}
private void button3_Click(object sender, System.EventArgs e)
{
try
{
this.dataGrid1.UnSelect (this.dataGrid1.CurrentRowIndex);
this.dataGrid1.Select(this.dataGrid1.CurrentRowIndex);
this.sqlDataAdapter1.Update(dataSet21,"good");
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}
private void button7_Click(object sender, System.EventArgs e)
{
currRow = this.dataSet21.Tables[0].Rows[this.BindingContext[this.dataSet21.Tables[0]].Position];
currRow.Delete();
this.sqlDataAdapter1.Update(dataSet21, "goodpass");
}
private void button6_Click(object sender, System.EventArgs e)
{
try
{
if(txtname.Text!="")
{
DataRow newdr=dataSet21.Tables["goodpass"].NewRow();
if(txtpassword.Text=="")
{
MessageBox.Show("密码不能为空!");
}
else
{
if(txtunit.Text=="")
{
MessageBox.Show("请确定管理权限!");
}
else
{
newdr["name"]=txtname.Text;
newdr["password"]=txtpassword.Text;
newdr["unit"]=txtunit.Text;
dataSet21.Tables["goodpass"].Rows.Add(newdr);
this.sqlDataAdapter1.Fill(dataSet21,"good");
this.sqlDataAdapter1.Update(dataSet21,"good");
MessageBox.Show("添加用户成功!");
}
}
}
else
MessageBox.Show("请输入用户名!");
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}
private void button5_Click(object sender, System.EventArgs e)
{
txtname.Clear();
txtpassword.Clear();
}
private void button9_Click(object sender, System.EventArgs e)
{
this.sqlDataAdapter1.Update(dataSet21, "goodpass");
this.Close();
}
private void button8_Click(object sender, System.EventArgs e)
{
currRow = this.dataSet21.Tables[0].Rows[this.BindingContext[this.dataSet21.Tables[0]].Position];
currRow.Delete();
this.sqlDataAdapter1.Update(dataSet21, "goodpass");
}
private void txtunit_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void button4_Click(object sender, System.EventArgs e)
{
this.sqlDataAdapter1.Update(dataSet21, "goodpass");
}
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
try
{
MessageBox.Show("操作员安照不同的权限登陆到不同的界面:\n\n1.库存界面\n2.销售界面\n3.进货界面\n5.控制台界面\n6.\n7.\n8.");
}
catch(Exception err)
{
}
}
private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -