📄 bookcategorym.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 BookCategoryM : Form
{
public BookCategoryM()
{
InitializeComponent();
}
private void BookCategoryM_Load(object sender, EventArgs e)
{
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 button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书分类索引不能为空!", "提示");
textBox1.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
string temp = "exec BookIndex_Insert '"
+ textBox1.Text.ToString().Trim() + "','"
+ textBox2.Text.ToString().Trim() + "'";
if (myConnData.Command(temp))
MessageBox.Show("添加成功!");
else
MessageBox.Show("添加失败!");
textBox1.Text = Convert.ToString(Convert.ToInt32(textBox1.Text) + 1);
textBox2.Text = "";
textBox1.Focus();
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
private void button7_Click(object sender, EventArgs e)
{
if (textBox5.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书分类索引不能为空!", "提示");
textBox5.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
SqlCommand mySqlCommand = new SqlCommand(@"
select *
from BookIndex", myConnData.ConnectDB());
SqlDataReader myDataReader = mySqlCommand.ExecuteReader();
while (myDataReader.Read())
{
if (myDataReader.GetValue(0).ToString().Trim() == textBox5.Text.ToString().Trim())
{
textBox3.Text = myDataReader.GetValue(1).ToString();
return;
}
else
{
continue;
}
}
MessageBox.Show("此用图书分类索引不存在,请重新输入!");
textBox5.Text = Convert.ToString(Convert.ToInt32(textBox5.Text) + 1);
textBox3.Text = "";
textBox3.Focus();
return;
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox5.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书分类索引不能为空!", "提示");
textBox5.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
string temp = "exec BookIndex_Update '"
+ textBox5.Text.ToString().Trim() + "','"
+ textBox3.Text.ToString().Trim() + "'";
if (myConnData.Command(temp))
MessageBox.Show("修改成功!");
else
MessageBox.Show("修改失败!");
textBox5.Text = Convert.ToString(Convert.ToInt32(textBox5.Text) + 1);
textBox3.Text = "";
textBox5.Focus();
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
private void button8_Click(object sender, EventArgs e)
{
if (textBox6.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书分类索引不能为空!", "提示");
textBox6.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
SqlCommand mySqlCommand = new SqlCommand(@"
select *
from BookIndex", myConnData.ConnectDB());
SqlDataReader myDataReader = mySqlCommand.ExecuteReader();
while (myDataReader.Read())
{
if (myDataReader.GetValue(0).ToString().Trim() == textBox6.Text.ToString().Trim())
{
textBox4.Text = myDataReader.GetValue(1).ToString();
return;
}
else
{
continue;
}
}
MessageBox.Show("此用图书分类索引不存在,请重新输入!");
textBox6.Text = Convert.ToString(Convert.ToInt32(textBox6.Text) + 1);
textBox4.Text = "";
textBox4.Focus();
return;
}
private void button5_Click(object sender, EventArgs e)
{
if (textBox6.Text.Trim().Length == 0)
{
MessageBox.Show("输入的图书分类索引不能为空!", "提示");
textBox6.Focus();
return;
}
MyClass.ConnData myConnData = new BooksM.MyClass.ConnData();
string temp = "delete "
+" from BookIndex "
+ " where BookCategoryID='" + textBox6.Text.ToString().Trim() + "'";
if (myConnData.Command(temp))
MessageBox.Show("删除成功!");
else
MessageBox.Show("删除失败!");
textBox6.Text = Convert.ToString(Convert.ToInt32(textBox6.Text) + 1);
textBox4.Text = "";
textBox6.Focus();
}
private void button6_Click(object sender, EventArgs e)
{
Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -