📄 usercontrol1.cs
字号:
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(120, 23);
this.dateTimePicker1.TabIndex = 16;
//
// comboBox3
//
this.comboBox3.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox3.Items.AddRange(new object[] {
"男",
"女"});
this.comboBox3.Location = new System.Drawing.Point(112, 176);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(48, 21);
this.comboBox3.TabIndex = 15;
this.comboBox3.Text = "男";
//
// comboBox4
//
this.comboBox4.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox4.Items.AddRange(new object[] {
"学生",
"教师",
"其它"});
this.comboBox4.Location = new System.Drawing.Point(384, 184);
this.comboBox4.Name = "comboBox4";
this.comboBox4.Size = new System.Drawing.Size(72, 21);
this.comboBox4.TabIndex = 15;
this.comboBox4.Text = "学生";
//
// comboBox5
//
this.comboBox5.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox5.Items.AddRange(new object[] {
"5",
"8"});
this.comboBox5.Location = new System.Drawing.Point(624, 184);
this.comboBox5.Name = "comboBox5";
this.comboBox5.Size = new System.Drawing.Size(48, 21);
this.comboBox5.TabIndex = 15;
this.comboBox5.Text = "5";
//
// comboBox6
//
this.comboBox6.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox6.Items.AddRange(new object[] {
"计算机学院",
"网络学院",
"艺术学院",
"能环学院",
"土木工程学院",
"汽车与交通学院",
"生物工程学院"});
this.comboBox6.Location = new System.Drawing.Point(544, 136);
this.comboBox6.Name = "comboBox6";
this.comboBox6.Size = new System.Drawing.Size(160, 21);
this.comboBox6.TabIndex = 15;
this.comboBox6.Text = "计算机学院";
//
// textBox4
//
this.textBox4.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox4.Location = new System.Drawing.Point(112, 64);
this.textBox4.Name = "textBox4";
this.textBox4.TabIndex = 14;
this.textBox4.Text = "";
//
// textBox5
//
this.textBox5.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox5.Location = new System.Drawing.Point(352, 224);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(144, 23);
this.textBox5.TabIndex = 14;
this.textBox5.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(328, 264);
this.button1.Name = "button1";
this.button1.TabIndex = 17;
this.button1.Text = "修改";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(440, 264);
this.button2.Name = "button2";
this.button2.TabIndex = 17;
this.button2.Text = "删除";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// numericUpDown1
//
this.numericUpDown1.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.numericUpDown1.Location = new System.Drawing.Point(336, 136);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(40, 23);
this.numericUpDown1.TabIndex = 19;
this.numericUpDown1.Value = new System.Decimal(new int[] {
19,
0,
0,
0});
//
// label14
//
this.label14.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label14.Location = new System.Drawing.Point(536, 224);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(120, 23);
this.label14.TabIndex = 20;
this.label14.Text = "累计借书 ";
//
// UserControl1
//
this.Controls.Add(this.label14);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.button1);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label13);
this.Controls.Add(this.label12);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.comboBox3);
this.Controls.Add(this.comboBox4);
this.Controls.Add(this.comboBox5);
this.Controls.Add(this.comboBox6);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.button2);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(728, 312);
this.Load += new System.EventHandler(this.UserControl1_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
}
#endregion
public void readinfo()
{
if(this.UserType=="reader"||this.UserType=="operator")
{
公共数据dll.Store.ds.Clear();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
公共数据dll.Store.sqlStr="select * from readerinfo where 证件号='"+公共数据dll.Store.str_temp+"'";
公共数据dll.Store.myDataAdapter=new System.Data.SqlClient.SqlDataAdapter(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
公共数据dll.Store.cb =new System.Data.SqlClient.SqlCommandBuilder(公共数据dll.Store.myDataAdapter);
公共数据dll.Store.myDataAdapter.Fill(公共数据dll.Store.ds,"readerinfo");
foreach(DataRow dr in 公共数据dll.Store.ds.Tables["readerinfo"].Rows)
{
textBox4.Text=dr["姓名"].ToString();
textBox2.Text=dr["密码"].ToString();//////////////////
textBox1.Text=dr["证件号"].ToString();
comboBox1.Text=dr["文化程度"].ToString();
dateTimePicker1.Text=dr["出生日期"].ToString();
decimal year=(decimal)int.Parse(dr["年龄"].ToString());
numericUpDown1.Value=year;
comboBox6.Text=dr["工作单位"].ToString();
comboBox3.Text=dr["性别"].ToString();
comboBox4.Text=dr["职业"].ToString();
comboBox5.Text=dr["最大借书量"].ToString();
textBox3.Text=dr["电话"].ToString();////////////////////////////
textBox5.Text=dr["E-MAIL"].ToString();/////////////////////////
}
公共数据dll.Store.cn.Close();/////////关闭连接
}
//设置访问权限
if(this.UserType=="reader"|| this.UserType=="operator")
{
textBox4.Enabled=false;
if(this.UserType=="reader")
{
textBox1.Enabled=false;
}
comboBox1.Enabled=false;
dateTimePicker1.Enabled=false;
numericUpDown1.Enabled=false;
comboBox6.Enabled=false;
comboBox3.Enabled=false;
comboBox4.Enabled=false;
comboBox5.Enabled=false;
this.button2.Enabled=false;
if(this.UserType=="operator")
{
textBox2.Enabled=false;
textBox3.Enabled=false;
textBox5.Enabled=false;
this.button1.Enabled=false;
this.button2.Enabled=false;
}
}
}
private void UserControl1_Load(object sender, System.EventArgs e)
{
this.readinfo();
}
private void button1_Click(object sender, System.EventArgs e)//修改读者信息
{
try
{
公共数据dll.Store.cn.Open();
公共数据dll.Store.sqlStr="update readerinfo set 密码='"+textBox2.Text+"', 电话='"+textBox3.Text+"', [E-MAIL]='"+textBox5.Text+"',姓名='"+this.textBox4.Text+"',证件号='"+this.textBox1.Text+"',文化程度='"+comboBox1.Text+"',出生日期='"+dateTimePicker1.Value+"',年龄='"+numericUpDown1.Value+"',工作单位='"+comboBox6.Text+"',性别='"+comboBox3.Text+"',职业='"+comboBox4.Text+"',最大借书量='"+comboBox5.Text+"' where 证件号='"+公共数据dll.Store.str_temp+"'";
MessageBox.Show(公共数据dll.Store.sqlStr);
公共数据dll.Store.cmd=new System.Data.SqlClient.SqlCommand(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
if(公共数据dll.Store.cmd.ExecuteNonQuery()==1)
MessageBox.Show("修改成功!","success",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
公共数据dll.Store.cn.Close();
}
private void button2_Click(object sender, System.EventArgs e)/////删除读者记录///////系统管理员权限
{
公共数据dll.Store.cn.Open();
公共数据dll.Store.sqlStr="delete from readerinfo where 证件号='"+公共数据dll.Store.str_temp+"'";
MessageBox.Show(公共数据dll.Store.sqlStr);
DialogResult re=MessageBox.Show("警告:你将会彻底读者:"+公共数据dll.Store.str_temp+"的所有信息!","警告",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
if(re==DialogResult.OK)
{
公共数据dll.Store.cmd=new System.Data.SqlClient.SqlCommand(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
if(公共数据dll.Store.cmd.ExecuteNonQuery()==1)
MessageBox.Show("删除成功!","success",MessageBoxButtons.OK,MessageBoxIcon.Information);
else
MessageBox.Show("删除出错!");
}
公共数据dll.Store.cn.Close();
}
private void button3_Click(object sender, System.EventArgs e)
{
}
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)//操作员录入读者证件号
{
if(this.UserType!="operator")return;
if(e.KeyValue==13)
{
if(this.textBox1.Text=="")
{
MessageBox.Show("请输入读者证件号");
return;
}
公共数据dll.Store.cn.Open();
公共数据dll.Store.str_temp=textBox1.Text;
this.readinfo();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -