📄 hadlead.cs
字号:
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(120, 21);
this.textBox3.TabIndex = 10;
this.textBox3.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(280, 48);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(120, 21);
this.textBox2.TabIndex = 9;
this.textBox2.Text = "";
//
// label9
//
this.label9.Location = new System.Drawing.Point(8, 96);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(72, 16);
this.label9.TabIndex = 8;
this.label9.Text = "出版时间:";
//
// label8
//
this.label8.Location = new System.Drawing.Point(416, 96);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(72, 16);
this.label8.TabIndex = 7;
this.label8.Text = "图书价格:";
//
// label7
//
this.label7.Location = new System.Drawing.Point(416, 48);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(80, 16);
this.label7.TabIndex = 6;
this.label7.Text = "图书类别:";
//
// label6
//
this.label6.Location = new System.Drawing.Point(416, 72);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 16);
this.label6.TabIndex = 5;
this.label6.Text = "内容简介:";
//
// label5
//
this.label5.Location = new System.Drawing.Point(216, 72);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(64, 16);
this.label5.TabIndex = 4;
this.label5.Text = "出版社:";
//
// label4
//
this.label4.Location = new System.Drawing.Point(8, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 16);
this.label4.TabIndex = 3;
this.label4.Text = "作者:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(216, 48);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 16);
this.label3.TabIndex = 2;
this.label3.Text = "图书名称:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(72, 48);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(120, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 16);
this.label2.TabIndex = 0;
this.label2.Text = "图书编号:";
//
// label11
//
this.label11.Location = new System.Drawing.Point(416, 24);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(72, 16);
this.label11.TabIndex = 21;
this.label11.Text = "图书状态:";
//
// comboBox3
//
this.comboBox3.Items.AddRange(new object[] {
"正常",
"借出",
"作废",
"遗失"});
this.comboBox3.Location = new System.Drawing.Point(488, 24);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(112, 20);
this.comboBox3.TabIndex = 22;
this.comboBox3.Text = "正常";
//
// label12
//
this.label12.Location = new System.Drawing.Point(8, 24);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(88, 16);
this.label12.TabIndex = 23;
//
// hadlead
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(696, 406);
this.Controls.Add(this.label1);
this.Controls.Add(this.list);
this.Controls.Add(this.groupBox1);
this.Name = "hadlead";
this.Text = "hadlead";
((System.ComponentModel.ISupportInitialize)(this.list)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
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;
lostStr=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()) ;
lostStr="a.lost ='" + this.comboBox3.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 || this.lostStr !=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;}
}
if (this.lostStr !=null)
{
if (sqltem==" and ")
{ sqltem=sqltem + this.lostStr;}
else {sqltem=sqltem +" and "+ this.lostStr;}
}
}
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.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],"");
this.label12.Text ="计录数:" + ds.Tables[0].Rows.Count.ToString();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return;
}
}
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;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -