📄 reader.cs
字号:
this.label2.Location = new System.Drawing.Point(16, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 16);
this.label2.TabIndex = 2;
this.label2.Text = "姓名:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(80, 24);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(104, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "textBox1";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 16);
this.label1.TabIndex = 0;
this.label1.Text = "借书证号:";
//
// button6
//
this.button6.Location = new System.Drawing.Point(304, 8);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(72, 24);
this.button6.TabIndex = 3;
this.button6.Text = "查询";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(208, 8);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(88, 21);
this.textBox4.TabIndex = 4;
this.textBox4.Text = "";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(64, 8);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(104, 21);
this.textBox5.TabIndex = 5;
this.textBox5.Text = "";
//
// label6
//
this.label6.Location = new System.Drawing.Point(8, 16);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(56, 16);
this.label6.TabIndex = 6;
this.label6.Text = "借书证号";
//
// label7
//
this.label7.Location = new System.Drawing.Point(176, 16);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(32, 16);
this.label7.TabIndex = 7;
this.label7.Text = "姓名";
//
// button7
//
this.button7.Location = new System.Drawing.Point(304, 304);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(72, 24);
this.button7.TabIndex = 8;
this.button7.Text = "选择确定";
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// reader
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(656, 334);
this.Controls.Add(this.button7);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.button6);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.list);
this.Name = "reader";
this.Text = "阅读者窗口";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
inifor();
this.button1.Enabled =false;
this.button2.Enabled =false;
this.button3.Enabled =false;
this.button4.Enabled =true;
this.button5.Enabled =true;
}
private void inifor()
{
this.textBox1.Text ="";
this.textBox2.Text ="";
this.textBox3.Text ="";
this.label5.Text ="";
this.comboBox1.SelectedIndex=0;
}
private void button5_Click(object sender, System.EventArgs e)
{
inifor();
this.button1.Enabled =true;
this.button2.Enabled =false;
this.button3.Enabled =false;
this.button4.Enabled =false;
this.button5.Enabled =true;
}
private void button2_Click(object sender, System.EventArgs e)
{
this.button1.Enabled =false;
this.button2.Enabled =false;
this.button3.Enabled =false;
this.button4.Enabled =true;
this.button5.Enabled =true;
}
private void button3_Click(object sender, System.EventArgs e)
{
if(Convert.ToInt32(label5.Text.Trim()) >0 && MessageBox.Show("删除后不可恢复,确定删除吗?","删除确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK){
try
{
string sql = "delete from reader where id="+ Convert.ToInt32(label5.Text.Trim()) ;
Public.ExeSql(sql);
}
catch{}
DataBinder("");
}
}
private void button4_Click(object sender, System.EventArgs e)
{
try
{
if (this.label5.Text =="")
{
string sql = "insert into reader(readerId,name,sex,idcardno) values('" + this.textBox1.Text.Trim() +"','" + this.textBox2.Text.Trim() +"','" + this.comboBox1.Text +"','" + this.textBox3.Text.Trim() +"')";
Public.ExeSql(sql);
}
else
{
string sql = "update reader set readerId = '" + this.textBox1.Text.Trim() +"',name='" + this.textBox2.Text.Trim() +"',sex='" + this.comboBox1.Text +"',idcardno='" + this.textBox3.Text.Trim() +"' where id=" + Convert.ToInt32(label5.Text.Trim());
Public.ExeSql(sql);
}
}
catch{}
button5_Click(sender,e);
DataBinder("");
}
private void listView2_DoubleClick(object sender, System.EventArgs e)
{
}
private void inilist()
{
try
{
string sql = "select id as 自动编号,readerId as 借书证号,name as 姓名,sex as 姓别,idcardno as 身份证号 from reader ";
System.Data.OleDb.OleDbCommand MyCmd=new OleDbCommand(sql,Public.conn);
Public.conn.Open();
//OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
System.Data.OleDb.OleDbDataReader mydataread = MyCmd.ExecuteReader();
// mydataread = MyCmd.ExecuteReader();
//
//// string[] head =new string[5];
list.Columns.Clear();
// for (int ihead=0;ihead< mydataread.FieldCount - 1;ihead++)
// {
// list.Columns.Add(mydataread.GetName(iHead), 100, HorizontalAlignment.Center);}
try
{
while(mydataread.Read())
{
ListViewItem ListDatas = new ListViewItem(mydataread[0].ToString());
if (mydataread.FieldCount > 0)
{
string[] DataList = new string[mydataread.FieldCount];
for (int i=1; i<mydataread.FieldCount;i++)
{
DataList[i-1] = mydataread[i].ToString();
}
ListDatas.SubItems.AddRange(DataList);
}
list.Items.Add(ListDatas);
}
}
catch
{ return ;}
Public.conn.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return;
}
}
private void DataBinder(string strSql)
{
this.list.Items.Clear();
string sql ="select id as 自动编号,readerId as 借书证号,name as 姓名,sex as 姓别,idcardno as 身份证号 from reader " + strSql ;
Public.conn.Open();
OleDbDataAdapter odp = new OleDbDataAdapter(sql,Public.conn);
DataSet ds = new DataSet();
odp.Fill(ds,"ExamItem");
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
DataRow row = ds.Tables[0].Rows[i];
string[] values = new string[5];
values[0] = row["自动编号"].ToString();
values[1] = row["借书证号"].ToString();
values[2] = row["姓名"].ToString();
values[3] = row["姓别"].ToString();
values[4] = row["身份证号"].ToString();
ListViewItem lvi = new ListViewItem(values);
lvi.Tag = row["自动编号"].ToString();
this.list.Items.Add(lvi);
this.list.Columns[0].Width=0;
}
Public.conn.Close();
}
private void list_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.list.Items.Count > 0 )
{
if(this.list.SelectedItems.Count > 0)
{ string myid = ((ListViewItem)this.list.Items[this.list.SelectedItems[0].Index]).Tag.ToString();
this.label5.Text =myid;
this.textBox1.Text =this.list.SelectedItems[0].SubItems[1].Text.ToString();
this.textBox2.Text =this.list.SelectedItems[0].SubItems[2].Text.ToString();
this.textBox3.Text =this.list.SelectedItems[0].SubItems[4].Text.ToString();
this.comboBox1.Text =this.list.SelectedItems[0].SubItems[3].Text.ToString();
this.button2.Enabled =true;
this.button3.Enabled =true;
}
}
}
private void button6_Click(object sender, System.EventArgs e)
{
string sql =" where readerId like'%" + this.textBox5.Text.Trim() + "%' and name like'%" + this.textBox4.Text.Trim() + "%' ";
DataBinder(sql);
}
private void button7_Click(object sender, System.EventArgs e)
{
//lead leadfrm =new lead();
if(this.list.Items.Count > 0 )
{
if(this.list.SelectedItems.Count > 0)
{
if (frm_Name =="lead")
{
lead.autoId =this.list.SelectedItems[0].SubItems[1].Text.ToString();;
lead.readerDataArray[0] =this.list.SelectedItems[0].SubItems[1].Text.ToString();
lead.readerDataArray[1] =this.list.SelectedItems[0].SubItems[2].Text.ToString();
lead.readerDataArray[2] =this.list.SelectedItems[0].SubItems[3].Text.ToString();
lead.readerDataArray[3] =this.list.SelectedItems[0].SubItems[4].Text.ToString();
}
else if(frm_Name =="returnFrm")
{
returnFrm.autoId =this.list.SelectedItems[0].SubItems[1].Text.ToString();;
returnFrm.readerDataArray[0] =this.list.SelectedItems[0].SubItems[1].Text.ToString();
returnFrm.readerDataArray[1] =this.list.SelectedItems[0].SubItems[2].Text.ToString();
returnFrm.readerDataArray[2] =this.list.SelectedItems[0].SubItems[3].Text.ToString();
returnFrm.readerDataArray[3] =this.list.SelectedItems[0].SubItems[4].Text.ToString();
}
}
}
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -