📄 lead.cs
字号:
this.label2.Text = "图书编号:";
//
// button2
//
this.button2.Location = new System.Drawing.Point(96, 312);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 24);
this.button2.TabIndex = 4;
this.button2.Text = "选择阅读者";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// list
//
this.list.CaptionVisible = false;
this.list.DataMember = "";
this.list.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.list.Location = new System.Drawing.Point(8, 160);
this.list.Name = "list";
this.list.Size = new System.Drawing.Size(648, 144);
this.list.TabIndex = 6;
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(8, 312);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(80, 21);
this.textBox7.TabIndex = 7;
this.textBox7.Text = "";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button3);
this.groupBox2.Controls.Add(this.label15);
this.groupBox2.Controls.Add(this.label14);
this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Controls.Add(this.label12);
this.groupBox2.Controls.Add(this.label11);
this.groupBox2.Controls.Add(this.textBox12);
this.groupBox2.Controls.Add(this.textBox11);
this.groupBox2.Controls.Add(this.textBox10);
this.groupBox2.Controls.Add(this.textBox9);
this.groupBox2.Controls.Add(this.textBox8);
this.groupBox2.Location = new System.Drawing.Point(8, 344);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(648, 112);
this.groupBox2.TabIndex = 8;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "阅读者信息";
//
// button3
//
this.button3.Location = new System.Drawing.Point(352, 48);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(80, 24);
this.button3.TabIndex = 11;
this.button3.Text = "未还书明细";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// label15
//
this.label15.Location = new System.Drawing.Point(200, 24);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(48, 16);
this.label15.TabIndex = 10;
this.label15.Text = "共借书";
//
// label14
//
this.label14.Location = new System.Drawing.Point(200, 56);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(48, 16);
this.label14.TabIndex = 9;
this.label14.Text = "未还书";
//
// label13
//
this.label13.Location = new System.Drawing.Point(16, 88);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(56, 16);
this.label13.TabIndex = 8;
this.label13.Text = "身份证号";
//
// label12
//
this.label12.Location = new System.Drawing.Point(16, 56);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(48, 16);
this.label12.TabIndex = 7;
this.label12.Text = "姓别";
//
// label11
//
this.label11.Location = new System.Drawing.Point(16, 24);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(56, 16);
this.label11.TabIndex = 6;
this.label11.Text = "借书证号";
//
// textBox12
//
this.textBox12.Enabled = false;
this.textBox12.Location = new System.Drawing.Point(264, 48);
this.textBox12.Name = "textBox12";
this.textBox12.Size = new System.Drawing.Size(72, 21);
this.textBox12.TabIndex = 4;
this.textBox12.Text = "";
//
// textBox11
//
this.textBox11.Enabled = false;
this.textBox11.Location = new System.Drawing.Point(264, 16);
this.textBox11.Name = "textBox11";
this.textBox11.Size = new System.Drawing.Size(72, 21);
this.textBox11.TabIndex = 3;
this.textBox11.Text = "";
//
// textBox10
//
this.textBox10.Enabled = false;
this.textBox10.Location = new System.Drawing.Point(72, 80);
this.textBox10.Name = "textBox10";
this.textBox10.Size = new System.Drawing.Size(360, 21);
this.textBox10.TabIndex = 2;
this.textBox10.Text = "";
//
// textBox9
//
this.textBox9.Enabled = false;
this.textBox9.Location = new System.Drawing.Point(72, 48);
this.textBox9.Name = "textBox9";
this.textBox9.Size = new System.Drawing.Size(72, 21);
this.textBox9.TabIndex = 1;
this.textBox9.Text = "";
//
// textBox8
//
this.textBox8.Enabled = false;
this.textBox8.Location = new System.Drawing.Point(72, 16);
this.textBox8.Name = "textBox8";
this.textBox8.Size = new System.Drawing.Size(72, 21);
this.textBox8.TabIndex = 0;
this.textBox8.Text = "";
//
// button4
//
this.button4.Location = new System.Drawing.Point(576, 312);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(72, 24);
this.button4.TabIndex = 9;
this.button4.Text = "借书";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// lead
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(664, 462);
this.Controls.Add(this.button4);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.textBox7);
this.Controls.Add(this.list);
this.Controls.Add(this.button2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label1);
this.Name = "lead";
this.Text = "借书窗口";
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.list)).EndInit();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void LoadSelectItem()
{
//载入类别
DataSet ds1 = Public.GetDireItem( );
if(ds1 != null)
{ this.comboBox1.Items.Add("");
for(int i=0;i<ds1.Tables[0].Rows.Count;i++)
{
DataRow row = ds1.Tables[0].Rows[i];
this.comboBox1.Items.Add(row["name"].ToString());
}
comboBox1.SelectedIndex=0;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
codeStr=null;
nameStr=null;
authorStr=null;
pressStr=null;
memotxtStr=null;
costStr=null;
outdateStr=null;
ordernameStr=null;
if (this.textBox1.Text !="") codeStr =" a.code like '%" + this.textBox1.Text.Trim() +"%'" ;
if (this.textBox2.Text !="") nameStr =" a.name like '%" + this.textBox2.Text.Trim() +"%'" ;
if (this.textBox3.Text !="") authorStr =" a.author like '%" + this.textBox3.Text.Trim() +"%'" ;
if (this.textBox4.Text !="") pressStr =" a.press like '%" + this.textBox4.Text.Trim() +"%'" ;
if (this.textBox5.Text !="") memotxtStr =" a.memotxt like '%" + this.textBox5.Text.Trim() +"%'" ;
if (this.textBox6.Text !="") costStr =" a.cost " +this.comboBox2.Text + Convert.ToInt32(textBox6.Text.Trim()) ;
if (this.checkBox1.Checked==true) outdateStr =" a.outdate between '" + dtp1.Text +"' and '" +dtp2.Text +"'";
if (this.comboBox1.Text.Trim()!="" )
{
try
{
string sql = "select * from orders where name='"+ comboBox1.SelectedItem.ToString().Trim() +"'";
OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
ds = new DataSet();
ad.Fill(ds,"orders");
if(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count == 1)
{
DataRow row = ds.Tables[0].Rows[0];
ordernameStr = " a.ordercode = " + row["id"].ToString() ;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
LoadListForList();
}
public void LoadListForList()
{
try
{
string sqltem=" and ";
if (this.codeStr !=null || this.nameStr !=null || this.authorStr!=null || this.pressStr!=null || this.outdateStr !=null || this.costStr !=null || this.ordernameStr!=null || this.memotxtStr !=null )
{
if (this.codeStr !=null) sqltem=sqltem + this.codeStr;
if (this.nameStr !=null)
{
if (sqltem==" and ")
{ sqltem=sqltem + this.nameStr;}
else {sqltem=sqltem +" and "+ this.nameStr;}
}
if (this.authorStr !=null)
{
if (sqltem==" and ")
{ sqltem=sqltem + this.authorStr;}
else {sqltem=sqltem +" and "+ this.authorStr;}
}
if (this.pressStr !=null)
{
if (sqltem==" and ")
{ sqltem=sqltem + this.pressStr;}
else {sqltem=sqltem +" and "+ this.pressStr;}
}
if (this.outdateStr !=null)
{
if (sqltem==" and ")
{ sqltem=sqltem + this.outdateStr;}
else {sqltem=sqltem +" and "+ this.outdateStr;}
}
if (this.costStr !=null)
{
if (sqltem==" and ")
{ sqltem=sqltem + this.codeStr;}
else {sqltem=sqltem +" and "+ this.costStr;}
}
if (this.ordernameStr !=null)
{
if (sqltem==" and ")
{ sqltem=sqltem + this.ordernameStr;}
else {sqltem=sqltem +" and "+ this.ordernameStr;}
}
if (this.memotxtStr !=null)
{
if (sqltem==" and ")
{ sqltem=sqltem + this.memotxtStr;}
else {sqltem=sqltem +" and "+ this.memotxtStr;}
}
}
else { sqltem="";}
if(this.list.DataSource != null) ((DataTable)this.list.DataSource).Rows.Clear();
string sql = "select a.id as 自动编号,a.code as 编号,a.name as 名称,a.author as 作者,a.press as 出版社,a.outdate as 出版日期,a.memotxt as 内容简介,a.cost as 价格,a.lost as 状态,b.name as 图书类别 from book a,orders b where a.lost='正常' and a.ordercode=b.id " +sqltem +" order by a.code ";
ds = new DataSet();
OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
ad.Fill( ds,"book");
this.list.SetDataBinding(ds.Tables[0],"");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
reader readerFrm =new reader(true,"lead");
readerFrm.ShowDialog();
setWareData();
string sql = "select * from lend where readerid = '" + autoId +"'";
OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
DataSet ds = new DataSet();
ad.Fill(ds,"list");
this.textBox11.Text =ds.Tables[0].Rows.Count.ToString() ;
sql = "select * from lend where readerid = '" + autoId +"' and bakdate is null";
ad = new OleDbDataAdapter(sql,Public.conn);
ds.Clear();
ad.Fill(ds,"list");
this.textBox12.Text =ds.Tables[0].Rows.Count.ToString() ;
}
public void setWareData()
{
this.textBox7.Text = readerDataArray[1];
this.textBox8.Text = readerDataArray[0];
this.textBox9.Text = readerDataArray[2];
this.textBox10.Text = readerDataArray[3];
}
//借书
private void button4_Click(object sender, System.EventArgs e)
{
if(MessageBox.Show("真的借出吗?","提示",MessageBoxButtons.YesNo)==DialogResult.Yes ){
if (ds.Tables[0].Rows.Count >0 )
{
try
{
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
string sql=" insert into lend (code,readerid,outdate) values ('" + ds.Tables[0].Rows[i][1].ToString() +"','"+ readerDataArray[0] +"','" + System.DateTime.Now.ToString() +"')";
Public.ExeSql(sql);}
MessageBox.Show("图书成功借出","提示",MessageBoxButtons.OK);
if(this.list.DataSource != null) ((DataTable)this.list.DataSource).Rows.Clear();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return;
}
}
}
}
private void button3_Click(object sender, System.EventArgs e)
{
if(this.textBox12.Text.Trim()!="" && Int32.Parse(this.textBox12.Text.Trim())!=0)
{
FormList listfrm =new FormList(readerDataArray[0],false);
listfrm.ShowDialog();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -