📄 buybooks.cs
字号:
this.textBox4.Text = "";
this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged);
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(88, 112);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(320, 21);
this.textBox3.TabIndex = 2;
this.textBox3.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(88, 71);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(136, 21);
this.textBox2.TabIndex = 1;
this.textBox2.Text = "";
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(88, 30);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(208, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(24, 237);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(54, 17);
this.label9.TabIndex = 8;
this.label9.Text = "出版日期";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(24, 155);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(29, 17);
this.label8.TabIndex = 7;
this.label8.Text = "ISBN";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(24, 114);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(29, 17);
this.label7.TabIndex = 6;
this.label7.Text = "书名";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(256, 196);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(29, 17);
this.label6.TabIndex = 5;
this.label6.Text = "单价";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(24, 196);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(42, 17);
this.label5.TabIndex = 4;
this.label5.Text = "出版社";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(257, 155);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(29, 17);
this.label4.TabIndex = 3;
this.label4.Text = "作者";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(24, 73);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(42, 17);
this.label2.TabIndex = 1;
this.label2.Text = "分类号";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(24, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(54, 17);
this.label1.TabIndex = 0;
this.label1.Text = "图书条码";
//
// btnAddNewBook
//
this.btnAddNewBook.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnAddNewBook.Location = new System.Drawing.Point(272, 408);
this.btnAddNewBook.Name = "btnAddNewBook";
this.btnAddNewBook.TabIndex = 10;
this.btnAddNewBook.Text = "新增";
this.btnAddNewBook.Click += new System.EventHandler(this.btnAddNewBook_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnCancel.Location = new System.Drawing.Point(360, 408);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 11;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// label12
//
this.label12.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label12.ForeColor = System.Drawing.Color.Red;
this.label12.Location = new System.Drawing.Point(16, 408);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(200, 23);
this.label12.TabIndex = 3;
this.label12.Text = "2 ISBN格式:ISBN 7-302-06743-0";
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label18
//
this.label18.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label18.ForeColor = System.Drawing.Color.Red;
this.label18.Location = new System.Drawing.Point(16, 376);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(256, 23);
this.label18.TabIndex = 17;
this.label18.Text = "1 分类号根据《中国图书馆图书分类法》编号";
this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// BuyBooks
//
this.AcceptButton = this.btnAddNewBook;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(450, 448);
this.ControlBox = false;
this.Controls.Add(this.label18);
this.Controls.Add(this.label12);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnAddNewBook);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "BuyBooks";
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "新增图书";
this.Load += new System.EventHandler(this.BuyBooks_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 取消
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCancel_Click(object sender, System.EventArgs e)
{
Global.sbpGlobal.Text = "就绪";
this.Close();
}
/// <summary>
/// 新增
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnAddNewBook_Click(object sender, System.EventArgs e)
{
if(isUpdate)
{
if(textBox1.Text == "")
{
MessageBox.Show("图书条码不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox1.Focus();
return;
}
if(textBox2.Text == "")
{
MessageBox.Show("分类号不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox2.Focus();
return;
}
if(textBox3.Text == "")
{
MessageBox.Show("图书名称不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox3.Focus();
return;
}
if(textBox4.Text == "")
{
MessageBox.Show("图书ISBN不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox4.Focus();
return;
}
if(textBox5.Text == "")
{
MessageBox.Show("图书作者不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox5.Focus();
return;
}
if(textBox6.Text == "")
{
MessageBox.Show("图书单价不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox6.Focus();
return;
}
if(comboBox1.Text == "")
{
MessageBox.Show("出版社不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
comboBox1.Focus();
return;
}
if(comboBox2.Text == "")
{
MessageBox.Show("图书类型不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
comboBox2.Focus();
return;
}
if(comboBox3.Text == "")
{
MessageBox.Show("图书存放位置不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
comboBox3.Focus();
return;
}
string str = "";
str = "update 图书资料 set 条形码=@条形码,分类号=@分类号,书名=@书名,ISBN=@ISBN,作者=@作者,单价=@单价,出版社=@出版社,出版日期=@出版日期,图书类型=@图书类型,编码日期=@编码日期,入库日期=@入库日期,书架名称=@书架名称 "
+ "where 条形码='" + bookt + "'";
cmd.CommandText = str;
cmd.Parameters.Add(new SqlParameter("@条形码",SqlDbType.VarChar,20)).Value = textBox1.Text;
cmd.Parameters.Add(new SqlParameter("@分类号",SqlDbType.VarChar,20)).Value = textBox2.Text;
cmd.Parameters.Add(new SqlParameter("@书名",SqlDbType.VarChar,20)).Value = textBox3.Text;
cmd.Parameters.Add(new SqlParameter("@ISBN",SqlDbType.VarChar,20)).Value = textBox4.Text;
cmd.Parameters.Add(new SqlParameter("@作者",SqlDbType.VarChar,20)).Value = textBox5.Text;
cmd.Parameters.Add(new SqlParameter("@单价",SqlDbType.Money,20)).Value = Convert.ToDecimal(textBox6.Text);
cmd.Parameters.Add(new SqlParameter("@出版社",SqlDbType.VarChar,20)).Value = comboBox1.Text;
cmd.Parameters.Add(new SqlParameter("@出版日期",SqlDbType.VarChar,20)).Value = dateTimePicker1.Value.ToShortDateString();
cmd.Parameters.Add(new SqlParameter("@图书类型",SqlDbType.VarChar,20)).Value = comboBox2.Text;
cmd.Parameters.Add(new SqlParameter("@编码日期",SqlDbType.VarChar,20)).Value = dateTimePicker2.Value.ToShortDateString();
cmd.Parameters.Add(new SqlParameter("@入库日期",SqlDbType.VarChar,20)).Value = dateTimePicker3.Value.ToShortDateString();
cmd.Parameters.Add(new SqlParameter("@书架名称",SqlDbType.VarChar,20)).Value = comboBox3.Text;
try
{
cmd.ExecuteNonQuery();
MessageBox.Show("成功修改记录!","提示",MessageBoxButtons.OK);
this.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"错误");
initializeScreen(bookt);
}
}
else
{
if(textBox1.Text == "")
{
MessageBox.Show("图书条码不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox1.Focus();
return;
}
if(textBox2.Text == "")
{
MessageBox.Show("分类号不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox2.Focus();
return;
}
if(textBox3.Text == "")
{
MessageBox.Show("图书名称不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox3.Focus();
return;
}
if(textBox4.Text == "")
{
MessageBox.Show("图书ISBN不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox4.Focus();
return;
}
if(textBox5.Text == "")
{
MessageBox.Show("图书作者不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox5.Focus();
return;
}
if(textBox6.Text == "")
{
MessageBox.Show("图书单价不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox6.Focus();
return;
}
if(comboBox1.Text == "")
{
MessageBox.Show("出版社不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
comboBox1.Focus();
return;
}
if(comboBox2.Text == "")
{
MessageBox.Show("图书类型不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
comboBox2.Focus();
return;
}
if(comboBox3.Text == "")
{
MessageBox.Show("图书存放位置不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
comboBox3.Focus();
return;
}
string str = "";
str = "select * from 图书资料 where 条形码='" + textBox1.Text + "'";
cmd.CommandText = str;
try
{
dr = cmd.ExecuteReader();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -