圖書管理系統(tǒng)C++源代碼
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1 public partial class Form_BuyAndSale : Form public Form_BuyAndSale() InitializeComponent(); SQL sql; string lastSQL = "" public void show() listBox1.Items.Clear(); listBox2.Items.Clear(); listBox3.Items.Clear(); if (sql.rows.GetLength(0) != 0) for (int i = 0; i < sql.rows.GetLength(0); i+) listBox1.Items.Add(sql.rowsi, 0.ToString(); listBox2.Items.Add(sql.rowsi, 1.ToString(); listBox3.Items.Add(sql.rowsi, 2.ToString(); else listBox1.Text = "" listBox2.Text = "" listBox3.Text = "" MessageBox.Show("無符合查詢條件的結(jié)果!", "提示"); private void Form_BuyAndSale_Load(object sender, EventArgs e) /將窗體的任務(wù)欄隱藏 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; sql = new SQL(Form_load .connectionString ); sql.ExecuteSQL("select * from ts_tushuxiaoshou"); show(); lastSQL = "select * from ts_tushuxiaoshou " private void butThisQuarter_Click(object sender, EventArgs e) int month = System.DateTime.Now.Month; int space = (3 - month % 3) % 3; string min = System.DateTime.Now.Year.ToString() + STR.add0(Convert.ToString(month + space - 2) + "00" string max = System.DateTime.Now.Year.ToString() + STR.add0(Convert.ToString(month + space) + "99" sql.ExecuteSQL("select * from ts_tushuxiaoshou where saledate>" + min + " and saledate<" + max + ""); show(); lastSQL = "select * from ts_tushuxiaoshou where saledate>" + min + " and saledate<" + max + "" private void butThisYear_Click(object sender, EventArgs e) string min = System.DateTime.Now.Year.ToString() + "0000" string max = System.DateTime.Now.Year.ToString() + "9999" sql.ExecuteSQL("select * from ts_tushuxiaoshou where saledate>" + min + " and saledate<" + max + ""); show(); lastSQL = "select * from ts_tushuxiaoshou where saledate>" + min + " and saledate<" + max + "" private void butAll_Click(object sender, EventArgs e) sql.ExecuteSQL("select * from ts_tushuxiaoshou"); show(); lastSQL = "select * from ts_tushuxiaoshou " private void butSearch_Click(object sender, EventArgs e) try int.Parse(Min.Text); int.Parse(Max.Text); catch MessageBox.Show("數(shù)值格式不正確!"); Min.Text = "" Max.Text = "" return; if (int.Parse(Min.Text) > int.Parse(Max.Text) MessageBox.Show("最小值應(yīng)小于或等于最大值!", "提示"); Min.Text = "" Max.Text = "" return; sql.ExecuteSQL("select * from ts_tushuxiaoshou where salequantity between " + Min.Text + " and " + Max.Text); show(); lastSQL = "select * from ts_tushuxiaoshou where salequantity between " + Min.Text + " and " + Max.Text; private void button1_Click(object sender, EventArgs e) this.Close(); using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1 public partial class Form_Customer : Form public Form_Customer() InitializeComponent(); SQL sql; string oldcustomerID = "" public static string CUSTOMERID = "" public static string CUSTOMERNAME = "" public void show() if (sql.rows.GetLength(0) != 0) customerID.Text = sql.rowssql.getPos(), 0.ToString(); customername.Text = sql.rowssql.getPos(), 1.ToString(); customerinfo.Text = sql.rowssql.getPos(), 2.ToString(); customeraddress.Text = sql.rowssql.getPos(), 3.ToString(); customertelephone.Text = sql.rowssql.getPos(), 4.ToString(); customersex.Text = sql.rowssql.getPos(), 5.ToString(); customeremail.Text = sql.rowssql.getPos(), 6.ToString(); else customerID.Text = "" customername.Text = "" customerinfo.Text = "" customeraddress.Text = "" customertelephone.Text = "" customersex.Text = "" customeremail.Text = "" MessageBox.Show("無符合查詢條件的結(jié)果!", "提示"); CUSTOMERID = customerID.Text; CUSTOMERNAME = customername.Text; private void Form_Customer_Load(object sender, EventArgs e) /將窗體的任務(wù)欄隱藏 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; sql = new SQL(Form_load .connectionString ); sql.ExecuteSQL("select * from ts_kehu order by customerID"); show(); private void AddOrder_Click(object sender, EventArgs e) if (customerID.Text != "") Form_Customer_AddOrder child = new Form_Customer_AddOrder(); child.ShowDialog(); else MessageBox.Show("請先選擇一個客戶!", "提示"); private void butAlter_Click(object sender, EventArgs e) if (butAlter.Text = "修改") butAlter.Text = "更新" oldcustomerID = customerID.Text; customerID.ReadOnly = false; customername.ReadOnly = false; customerinfo.ReadOnly = false; customeraddress.ReadOnly = false; customertelephone.ReadOnly = false; customersex.ReadOnly = false; customeremail.ReadOnly = false; butAdd.Enabled = false; butDelete.Enabled = false; butFirst.Enabled = false; butPrev.Enabled = false; butNext.Enabled = false; butLast.Enabled = false; butSearch.Enabled = false; butLookOverOrders.Enabled = false; butShowAll.Enabled = false; AddOrder.Enabled = false; else if (sql.ExecuteSQL("update ts_kehu set customerID=" + customerID.Text + ",customername=" + customername.Text + ",customerinfo=" + customerinfo.Text + ",customeraddress=" + customeraddress.Text + ",customertelephone=" + customertelephone.Text + ",customersex=" + customersex.Text + ",customeremail=" + customeremail.Text + " where customerID=" + oldcustomerID + "") = false | sql.ExecuteSQL("update ts_kehudingdan set customerID=" + customerID.Text + " where customerID=" + oldcustomerID + "") = false) show(); else CUSTOMERID = customerID.Text; CUSTOMERNAME = customername.Text; customerID.ReadOnly = true; customername.ReadOnly = true; customerinfo.ReadOnly = true; customeraddress.ReadOnly = true; customertelephone.ReadOnly = true; customersex.ReadOnly = true; customeremail.ReadOnly = true; butAlter.Text = "修改" butAdd.Enabled = true; butDelete.Enabled = true; butFirst.Enabled = true; butPrev.Enabled = true; butNext.Enabled = true; butLast.Enabled = true; butSearch.Enabled = true; butLookOverOrders.Enabled = true; AddOrder.Enabled = true; butShowAll.Enabled = true; private void butAdd_Click(object sender, EventArgs e) try if (butAdd.Text = "添加") butAdd.Text = "提交" customerID.Text = "" customername.Text = "" customerinfo.Text = "" customeraddress.Text = "" customertelephone.Text = "" customersex.Text = "" customeremail.Text = "" customerID.ReadOnly = false; customername.ReadOnly = false; customerinfo.ReadOnly = false; customeraddress.ReadOnly = false; customertelephone.ReadOnly = false; customersex.ReadOnly = false; customeremail.ReadOnly = false; butAlter.Enabled = false; butDelete.Enabled = false; butFirst.Enabled = false; butPrev.Enabled = false; butNext.Enabled = false; butLast.Enabled = false; butSearch.Enabled = false; butLookOverOrders.Enabled = false; AddOrder.Enabled = false; butShowAll.Enabled = false; else if (this.customeraddress.Text = "") MessageBox.Show("請輸入完整信息!"); else if (this.customeremail.Text = "") MessageBox.Show("請輸入完整信息!"); else if (this.customerID.Text = "") MessageBox.Show("請輸入完整信息"); else if (this.customerinfo.Text = "") MessageBox.Show("請輸入完整信息!"); else if (this.customername.Text = "") MessageBox.Show("請輸入完整信息!"); else if (this.customersex.Text = "") MessageBox.Show("請輸入完整信息!"); else if (sql.ExecuteSQL("insert into ts_kehu values(" + customerID.Text + "," + customername.Text + "," + customerinfo.Text + "," + customeraddress.Text + "," + customertelephone.Text + "," + customersex.Text + "," + customeremail.Text + ")") = false) show(); else CUSTOMERID = customerID.Text; CUSTOMERNAME = customername.Text; customerID.ReadOnly = true; customername.ReadOnly = true; customerinfo.ReadOnly = true; customeraddress.ReadOnly = true; customertelephone.ReadOnly = true; customersex.ReadOnly = true; customeremail.ReadOnly = true; butAdd.Text = "添加" butAlter.Enabled = true; butDelete.Enabled = true; butFirst.Enabled = true; butPrev.Enabled = true; butNext.Enabled = true; butLast.Enabled = true; butSearch.Enabled = true; butLookOverOrders.Enabled = true; AddOrder.Enabled = true; butShowAll.Enabled = true; catch (Exception e1) MessageBox.Show(e1.Message); private void butDelete_Click(object sender, EventArgs e) sql.ExecuteSQL("delete from ts_kehu where customerID=" + customerID.Text + ""); show(); private void butShowAll_Click(object sender, EventArgs e) sql.ExecuteSQL("select * from ts_kehu order by customerID"); show(); private void butSearch_Click(object sender, EventArgs e) if (comboBox1.Text = "客戶名稱") if (comboBox2.Text = "精確") sql.ExecuteSQL("select * from ts_kehu where customername=" + textForSearch.Text + " order by customerID"); show(); else sql.ExecuteSQL("select * from ts_kehu where customername like %" + textForSearch.Text + "% order by customerID"); show(); else if (comboBox2.Text = "精確") sql.ExecuteSQL("select * from ts_kehu where customeremail=" + textForSearch.Text + " order by customerID"); show(); else sql.ExecuteSQL("select * from ts_kehu where customeremail like %" + textForSearch.Text + "% order by customerID"); show(); private void butFirst_Click(object sender, EventArgs e) sql.pointToFirst(); show(); private void butPrev_Click(object sender, EventArgs e) sql.pointToPrev(); show(); private void butNext_Click(object sender, EventArgs e) sql.pointToNext(); show(); private void butLast_Click(object sender, EventArgs e) sql.pointToLast(); show(); private void butLookOverOrders_Click(object sender, EventArgs e) Form_Customer_LookOverOrders child = new Form_Customer_LookOverOrders(); child.ShowDialog(); private void button1_Click(object sender, EventArgs e) this.Close(); using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1 public partial class Form_Customer : Form public Form_Customer() InitializeComponent(); SQL sql; string oldcustomerID = "" public static string CUSTOMERID = "" public static string CUSTOMERNAME = "" public void show() if (sql.rows.GetLength(0) != 0) customerID.Text = sql.rowssql.getPos(), 0.ToString(); customername.Text = sql.rowssql.getPos(), 1.ToString(); customerinfo.Text = sql.rowssql.getPos(), 2.ToString(); customeraddress.Text = sql.rowssql.getPos(), 3.ToString(); customertelephone.Text = sql.rowssql.getPos(), 4.ToString(); customersex.Text = sql.rowssql.getPos(), 5.ToString(); customeremail.Text = sql.rowssql.getPos(), 6.ToString(); else customerID.Text = "" customername.Text = "" customerinfo.Text = "" customeraddress.Text = "" customertelephone.Text = "" customersex.Text = "" customeremail.Text = "" MessageBox.Show("無符合查詢條件的結(jié)果!", "提示"); CUSTOMERID = customerID.Text; CUSTOMERNAME = customername.Text; private void Form_Customer_Load(object sender, EventArgs e) /將窗體的任務(wù)欄隱藏 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; sql = new SQL(Form_load .connectionString ); sql.ExecuteSQL("select * from ts_kehu order by customerID"); show(); private void AddOrder_Click(object sender, EventArgs e) if (customerID.Text != "") Form_Customer_AddOrder child = new Form_Customer_AddOrder(); child.ShowDialog(); else MessageBox.Show("請先選擇一個客戶!", "提示"); private void butAlter_Click(object sender, EventArgs e) if (butAlter.Text = "修改") butAlter.Text = "更新" oldcustomerID = customerID.Text; customerID.ReadOnly = false; customername.ReadOnly = false; customerinfo.ReadOnly = false; customeraddress.ReadOnly = false; customertelephone.ReadOnly = false; customersex.ReadOnly = false; customeremail.ReadOnly = false; butAdd.Enabled = false; butDelete.Enabled = false; butFirst.Enabled = false; butPrev.Enabled = false; butNext.Enabled = false; butLast.Enabled = false; butSearch.Enabled = false; butLookOverOrders.Enabled = false; butShowAll.Enabled = false; AddOrder.Enabled = false; else if (sql.ExecuteSQL("update ts_kehu set customerID=" + customerID.Text + ",customername=" + customername.Text + ",customerinfo=" + customerinfo.Text + ",customeraddress=" + customeraddress.Text + ",customertelephone=" + customertelephone.Text + ",customersex=" + customersex.Text + ",customeremail=" + customeremail.Text + " where customerID=" + oldcustomerID + "") = false | sql.ExecuteSQL("update ts_kehudingdan set customerID=" + customerID.Text