📄 cardm.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 BooksM.CardManagement
{
public partial class CardM : Form
{
public CardM()
{
InitializeComponent();
}
private void CardM_Load(object sender, EventArgs e)
{
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
DataSet myDataSet = new DataSet();
string str = "select * from BookIndex";
myDataSet = myConnData.MyDataSet(str);
this.comboBox1.DataSource = myDataSet.Tables[0];
this.comboBox1.DisplayMember = "CategoryDes";
this.comboBox1.ValueMember = "BookCategoryID";
this.comboBox2.DataSource = myDataSet.Tables[0];
this.comboBox2.DisplayMember = "CategoryDes";
this.comboBox2.ValueMember = "BookCategoryID";
this.comboBox3.DataSource = myDataSet.Tables[0];
this.comboBox3.DisplayMember = "CategoryDes";
this.comboBox3.ValueMember = "BookCategoryID";
textBox6.Text = DateTime.Now.ToString();
textBox10.Text = DateTime.Now.ToString();
MainManage myMainManage = new MainManage();
if (myMainManage.GetTabPage == 1)
{
this.tabControl1.SelectedTab = tabPage1;
}
else if (myMainManage.GetTabPage == 2)
this.tabControl1.SelectedTab = tabPage2;
else if (myMainManage.GetTabPage == 3)
this.tabControl1.SelectedTab = tabPage3;
else
this.tabControl1.SelectedTab = tabPage1;
}
private void button9_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书编号不能为空!", "提示");
textBox1.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
SqlCommand mySqlCommand = new SqlCommand(@"
select *
from BookCardInfor", myConnData.ConnectDB());
SqlDataReader myDataReader = mySqlCommand.ExecuteReader();
while (myDataReader.Read())
{
if (myDataReader.GetValue(0).ToString().Trim() == textBox1.Text.ToString().Trim())
{
MessageBox.Show("此用图书编号不可用!");
return;
}
else
{
continue;
}
}
MessageBox.Show("此用图书编号可用!");
this.comboBox1.Focus();
return;
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书编号不能为空!", "提示");
textBox1.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
if (textBox3.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书名称不能为空!", "提示");
textBox3.Focus();
return;
}
string temp = "exec BookCardInfor_Insert '"
+ textBox1.Text.ToString().Trim() + "','"
+ this.comboBox1.SelectedValue.ToString().Trim()+ "','"
+ textBox3.Text.ToString().Trim() + "','"
+ textBox4.Text.ToString().Trim() + "','"
+ textBox5.Text.ToString().Trim() + "','"
+ textBox6.Text.ToString().Trim() + "',"
+ Convert.ToDecimal(textBox11.Text.Trim())+",'"//
+textBox7.Text.ToString().Trim() + "',"
+ textBox8.Text.ToString().Trim() + ","
+ textBox9.Text.ToString().Trim() + ",'"
+ textBox10.Text.ToString().Trim() + "'";
if (myConnData.Command(temp))
{
MessageBox.Show("添加成功!");
textBox1.Text = Convert.ToString(Convert.ToInt32(textBox1.Text) + 1);
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = DateTime.Now.ToString();
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
textBox10.Text = DateTime.Now.ToString();
textBox11.Text = "";
textBox1.Focus();
}
else
MessageBox.Show("添加失败!");
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
private void button8_Click(object sender, EventArgs e)
{
textBox20.Text = "";
textBox19.Text = "";
textBox18.Text = "";
textBox17.Text = "";
textBox12.Text = "";
textBox16.Text = "";
textBox15.Text = "";
textBox14.Text = "";
textBox13.Text = "";
if (textBox22.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书编号不能为空!", "提示");
textBox22.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
SqlCommand mySqlCommand = new SqlCommand(@"
select *
from BookCardInfor", myConnData.ConnectDB());
SqlDataReader myDataReader = mySqlCommand.ExecuteReader();
while (myDataReader.Read())
{
if (myDataReader.GetValue(0).ToString().Trim() == textBox22.Text.ToString().Trim())
{
this.comboBox2.SelectedValue = myDataReader.GetValue(1).ToString();
textBox20.Text = myDataReader.GetValue(2).ToString();
textBox19.Text = myDataReader.GetValue(3).ToString();
textBox18.Text = myDataReader.GetValue(4).ToString();
textBox17.Text = myDataReader.GetValue(5).ToString();
textBox12.Text = myDataReader.GetValue(6).ToString();
textBox16.Text = myDataReader.GetValue(7).ToString();
textBox15.Text = myDataReader.GetValue(8).ToString();
textBox14.Text = myDataReader.GetValue(9).ToString();
textBox13.Text = myDataReader.GetValue(10).ToString();
return;
}
else
{
continue;
}
}
MessageBox.Show("此用图书编号不存在!");
return;
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox22.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书分类索引不能为空!", "提示");
textBox22.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
string temp = "exec BookCardInfor_update '"
+ textBox22.Text.ToString().Trim() + "',"
+this.comboBox2.SelectedValue+ ",'"
+ textBox20.Text.ToString().Trim() + "','"
+ textBox19.Text.ToString().Trim() + "','"
+textBox18.Text.ToString().Trim() + "','"
+textBox17.Text.ToString().Trim() + "',"
+textBox12.Text.ToString().Trim() + ",'"
+textBox16.Text.ToString().Trim() + "',"
+textBox15.Text.ToString().Trim() + ","
+textBox14.Text.ToString().Trim() + ",'"
+ textBox13.Text.ToString().Trim() + "'";
if (myConnData.Command(temp))
MessageBox.Show("修改成功!");
else
MessageBox.Show("修改失败!");
textBox22.Text = Convert.ToString(Convert.ToInt32(textBox22.Text) + 1);
textBox20.Text = "";
textBox19.Text = "";
textBox18.Text = "";
textBox17.Text = "";
textBox12.Text = "";
textBox16.Text = "";
textBox15.Text = "";
textBox14.Text = "";
textBox13.Text = "";
textBox22.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void button7_Click(object sender, EventArgs e)
{
textBox31.Text = "";
textBox30.Text = "";
textBox29.Text = "";
textBox28.Text = "";
textBox27.Text = "";
textBox26.Text = "";
textBox25.Text = "";
textBox24.Text = "";
textBox23.Text = "";
if (textBox33.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书编号不能为空!", "提示");
textBox33.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
SqlCommand mySqlCommand = new SqlCommand(@"
select *
from BookCardInfor", myConnData.ConnectDB());
SqlDataReader myDataReader = mySqlCommand.ExecuteReader();
while (myDataReader.Read())
{
if (myDataReader.GetValue(0).ToString().Trim() == textBox33.Text.ToString().Trim())
{
this.comboBox3.SelectedValue = myDataReader.GetValue(1).ToString();
textBox31.Text = myDataReader.GetValue(2).ToString();
textBox30.Text = myDataReader.GetValue(3).ToString();
textBox29.Text = myDataReader.GetValue(4).ToString();
textBox28.Text = myDataReader.GetValue(5).ToString();
textBox23.Text = myDataReader.GetValue(6).ToString();
textBox27.Text = myDataReader.GetValue(7).ToString();
textBox26.Text = myDataReader.GetValue(8).ToString();
textBox25.Text = myDataReader.GetValue(9).ToString();
textBox24.Text = myDataReader.GetValue(10).ToString();
return;
}
else
{
continue;
}
}
MessageBox.Show("此用图书编号不存在!");
return;
}
private void button6_Click(object sender, EventArgs e)
{
if (textBox33.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书分类索引不能为空!", "提示");
textBox33.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
string temp = "delete "
+ " from BookCardInfor "
+ " where BookID='" + textBox33.Text.ToString().Trim() + "'";
if (myConnData.Command(temp))
MessageBox.Show("删除成功!");
else
MessageBox.Show("删除失败!");
textBox33.Text = Convert.ToString(Convert.ToInt32(textBox33.Text) + 1);
this.comboBox3.SelectedText = "";
textBox31.Text = "";
textBox30.Text = "";
textBox29.Text = "";
textBox28.Text = "";
textBox27.Text = "";
textBox26.Text = "";
textBox25.Text = "";
textBox24.Text = "";
textBox23.Text = "";
textBox33.Focus();
}
private void button5_Click(object sender, EventArgs e)
{
Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -