📄 tushubianmaruku.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace tsh
{
public partial class tushubianmaruku : Form
{
public tushubianmaruku()
{
InitializeComponent();
}
private bool old = false;
DB.ClsSQL sql = new DB.ClsSQL(".", "mylw", "sa", "", 3);
DataSet ds;
private void textBbh_KeyDown(object sender, KeyEventArgs e)
{
//e.KeyCode.ToString() == "Enter" ||
if (e.KeyCode.ToString() == "Down")
{
if (textBbh.Text == "")
{
MessageBox.Show("图书编号不能为空,请输入图书编号!!", "提示");
textBbh.Focus();
}
else
{
string s = "select * from book where tushubianhao='" + textBbh.Text.Trim() + "'";
ds = sql.DBToDS(s, "book");
int n = ds.Tables["book"].Rows.Count;
if (n != 0)
{
old = true;
labelmessg.Visible = true;
labelmessg.Text = "旧书信息,输入购入数量";
textBbh.Enabled = false;
textBflh.Text = ds.Tables["book"].Rows[0]["fenleihao"].ToString();
textBshm.Text = ds.Tables["book"].Rows[0]["shuming"].ToString();
textBlb.Text = ds.Tables["book"].Rows[0]["leibie"].ToString();
textBzzh.Text = ds.Tables["book"].Rows[0]["zuozhe"].ToString();
textBchbsh.Text = ds.Tables["book"].Rows[0]["chubanshe"].ToString();
textBbc.Text = ds.Tables["book"].Rows[0]["banci"].ToString();
textBkb.Text = ds.Tables["book"].Rows[0]["kaiben"].ToString();
textBzsh.Text = ds.Tables["book"].Rows[0]["zishu"].ToString();
textBjg.Text = ds.Tables["book"].Rows[0]["jiage"].ToString();
textBkcsh.Text = ds.Tables["book"].Rows[0]["kucunshu"].ToString();
textBgrsh.Enabled = true;
textBgrsh.Focus();
}
else
{
old = false;
labelmessg.Visible = true;
labelmessg.Text = "新增图书,输入各项信息";
textBbh.Enabled = false;
textBflh.Enabled = true;
textBflh.Focus();
}
}
}
}
private void buttbc_Click(object sender, EventArgs e)
{
if (old == false)
{
string s1 = "insert into book (tushubianhao,fenleihao,shuming,leibie,zuozhe,chubanshe,banci,kaiben,zishu,jiage,kucunshu,zaikushu) values ('" + textBbh.Text.Trim() + "','" + textBflh.Text.Trim() + "','" + textBshm.Text.Trim() + "','" + textBlb.Text.Trim() + "','" + textBzzh.Text.Trim() + "','" + textBchbsh.Text.Trim() + "','" + textBbc.Text.Trim() + "','" + textBkb.Text.Trim() + "','" + textBzsh.Text.Trim() + "'," + float.Parse(textBjg.Text.Trim())+ "," + int.Parse(textBgrsh.Text.Trim())+ "," + int.Parse(textBgrsh.Text.Trim())+")";
sql.SQLCommand(s1);
// MessageBox.Show("旧书入库添加成功!!", "信息提示");
}
else
{
int grshu = int.Parse(textBgrsh.Text);
string s2 = "update book set zaikushu=zaikushu+" + grshu + ",kucunshu=kucunshu+" + grshu + " where tushubianhao='" + textBbh.Text.Trim() + "'";
sql.SQLCommand(s2);
//MessageBox.Show("新增图书入库成功!!", "信息提示");
}
MessageBox.Show("已成功保存图书信息。", "提示");
buttqx_Click(null, null);
}
private void buttqx_Click(object sender, EventArgs e)
{
textBbh.Text = "";
textBbh.Enabled = true;
textBbh.Focus();
textBflh.Text ="";
textBflh.Enabled = false;
textBshm.Text = "";
textBshm.Enabled = false;
textBlb.Text ="";
textBlb.Enabled = false;
textBzzh.Text ="";
textBzzh.Enabled = false;
textBchbsh.Text ="";
textBchbsh.Enabled = false;
textBbc.Text ="";
textBbc.Enabled = false;
textBkb.Text ="";
textBkb.Enabled = false;
textBzsh.Text ="";
textBzsh.Enabled = false;
textBjg.Text ="";
textBjg.Enabled = false;
textBkcsh.Text = "";
textBkcsh.Enabled = false;
textBgrsh.Text = "";
textBgrsh.Enabled = false;
labelmessg.Visible = false;
}
private void butttch_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void textBbh_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(((e.KeyChar >= '0') && (e.KeyChar <= '9')) || e.KeyChar <= 31))
e.Handled = true;
if (e.KeyChar==13)
{
if (textBbh.Text == "")
{
MessageBox.Show("图书编号不能为空,请输入图书编号!!", "提示");
textBbh.Focus();
}
else
{
string s = "select * from book where tushubianhao='" + textBbh.Text.Trim() + "'";
ds = sql.DBToDS(s, "book");
int n = ds.Tables["book"].Rows.Count;
if (n != 0)
{
old = true;
labelmessg.Visible = true;
labelmessg.Text = "旧书信息,输入购入数量";
textBbh.Enabled = false;
textBflh.Text = ds.Tables["book"].Rows[0]["fenleihao"].ToString();
textBshm.Text = ds.Tables["book"].Rows[0]["shuming"].ToString();
textBlb.Text = ds.Tables["book"].Rows[0]["leibie"].ToString();
textBzzh.Text = ds.Tables["book"].Rows[0]["zuozhe"].ToString();
textBchbsh.Text = ds.Tables["book"].Rows[0]["chubanshe"].ToString();
textBbc.Text = ds.Tables["book"].Rows[0]["banci"].ToString();
textBkb.Text = ds.Tables["book"].Rows[0]["kaiben"].ToString();
textBzsh.Text = ds.Tables["book"].Rows[0]["zishu"].ToString();
textBjg.Text = ds.Tables["book"].Rows[0]["jiage"].ToString();
textBkcsh.Text = ds.Tables["book"].Rows[0]["kucunshu"].ToString();
textBgrsh.Enabled = true;
textBgrsh.Focus();
}
else
{
old = false;
labelmessg.Visible = true;
labelmessg.Text = "新增图书,输入各项信息";
textBbh.Enabled = false;
textBflh.Enabled = true;
textBflh.Focus();
}
}
}
}
private void textBgrsh_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(((e.KeyChar >= '0') && (e.KeyChar <= '9')) || e.KeyChar <= 31))
e.Handled = true;
if (e.KeyChar == 13)
{
if (textBgrsh.Text == "")
{
MessageBox.Show("图书购入数不能为空,请输入图书购入数!!", "提示");
textBgrsh.Focus();
}
else
{
textBgrsh.Enabled = false;
buttbc.Enabled = true;
buttbc.Focus();
}
}
}
private void tushubianmaruku_Load(object sender, EventArgs e)
{
labelmessg.Visible = false;
}
private void textBflh_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBflh.Text == "")
{
MessageBox.Show("图书分类号不能为空,请输入图书分类号!!", "提示");
textBflh.Focus();
}
else
{
textBflh.Enabled = false;
textBshm.Enabled = true;
textBshm.Focus();
}
}
}
private void textBshm_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBshm.Text == "")
{
MessageBox.Show("图书书名不能为空,请输入图书书名!!", "提示");
textBshm.Focus();
}
else
{
textBshm.Enabled = false;
textBlb.Enabled = true;
textBlb.Focus();
}
}
}
private void textBlb_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBlb.Text == "")
{
MessageBox.Show("图书类别不能为空,请输入图书类别!!", "提示");
textBlb.Focus();
}
else
{
textBlb.Enabled = false;
textBzzh.Enabled = true;
textBzzh.Focus();
}
}
}
private void textBzzh_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBzzh.Text == "")
{
MessageBox.Show("图书作者不能为空,请输入图书作者!!", "提示");
textBzzh.Focus();
}
else
{
textBzzh.Enabled = false;
textBchbsh.Enabled = true;
textBchbsh.Focus();
}
}
}
private void textBchbsh_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBchbsh.Text == "")
{
MessageBox.Show("图书出版社不能为空,请输入图书出版社!!", "提示");
textBchbsh.Focus();
}
else
{
textBchbsh.Enabled = false;
textBbc.Enabled = true;
textBbc.Focus();
}
}
}
private void textBbc_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBbc.Text == "")
{
MessageBox.Show("图书版次不能为空,请输入图书版次!!", "提示");
textBbc.Focus();
}
else
{
textBbc.Enabled = false;
textBkb.Enabled = true;
textBkb.Focus();
}
}
}
private void textBkb_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBkb.Text == "")
{
MessageBox.Show("图书开本不能为空,请输入图书开本!!", "提示");
textBkb.Focus();
}
else
{
textBkb.Enabled = false;
textBzsh.Enabled = true;
textBzsh.Focus();
}
}
}
private void textBzsh_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBzsh.Text == "")
{
MessageBox.Show("图书字数不能为空,请输入图书字数!!", "提示");
textBzsh.Focus();
}
else
{
textBzsh.Enabled = false;
textBjg.Enabled = true;
textBjg.Focus();
}
}
}
private void textBjg_KeyPress(object sender, KeyPressEventArgs e)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -