📄 form_customer_lookoverorders.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace 图书管理系统
{
/// <summary>
/// Form_Customer_LookOverOrders 的摘要说明。
/// </summary>
public class Form_Customer_LookOverOrders : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button butExit;
private System.Windows.Forms.TextBox orderID;
private System.Windows.Forms.Button butUpdate;
private System.Windows.Forms.Button butCommit;
private System.Windows.Forms.Button butLast;
private System.Windows.Forms.Button butFirst;
private System.Windows.Forms.Button butNext;
private System.Windows.Forms.Button butPrev;
private System.Windows.Forms.TextBox orderquantity;
private System.Windows.Forms.TextBox orderprice;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.TextBox customerID;
private System.Windows.Forms.TextBox bookISBN;
private System.Windows.Forms.Label label3;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form_Customer_LookOverOrders()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form_Customer_LookOverOrders));
this.butExit = new System.Windows.Forms.Button();
this.customerID = new System.Windows.Forms.TextBox();
this.orderID = new System.Windows.Forms.TextBox();
this.butUpdate = new System.Windows.Forms.Button();
this.butCommit = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.butLast = new System.Windows.Forms.Button();
this.butFirst = new System.Windows.Forms.Button();
this.butNext = new System.Windows.Forms.Button();
this.butPrev = new System.Windows.Forms.Button();
this.orderquantity = new System.Windows.Forms.TextBox();
this.orderprice = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.bookISBN = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// butExit
//
this.butExit.BackColor = System.Drawing.Color.Transparent;
this.butExit.Location = new System.Drawing.Point(212, 304);
this.butExit.Name = "butExit";
this.butExit.Size = new System.Drawing.Size(64, 24);
this.butExit.TabIndex = 25;
this.butExit.Text = "退出";
this.butExit.Click += new System.EventHandler(this.butExit_Click);
//
// customerID
//
this.customerID.Location = new System.Drawing.Point(120, 27);
this.customerID.Name = "customerID";
this.customerID.ReadOnly = true;
this.customerID.Size = new System.Drawing.Size(208, 21);
this.customerID.TabIndex = 21;
this.customerID.Text = "customerID";
//
// orderID
//
this.orderID.Location = new System.Drawing.Point(120, 67);
this.orderID.Name = "orderID";
this.orderID.ReadOnly = true;
this.orderID.Size = new System.Drawing.Size(208, 21);
this.orderID.TabIndex = 20;
this.orderID.Text = "orderID";
//
// butUpdate
//
this.butUpdate.BackColor = System.Drawing.Color.Transparent;
this.butUpdate.Location = new System.Drawing.Point(44, 232);
this.butUpdate.Name = "butUpdate";
this.butUpdate.Size = new System.Drawing.Size(56, 24);
this.butUpdate.TabIndex = 17;
this.butUpdate.Text = "修改";
this.butUpdate.Click += new System.EventHandler(this.butUpdate_Click);
//
// butCommit
//
this.butCommit.BackColor = System.Drawing.Color.Transparent;
this.butCommit.Location = new System.Drawing.Point(92, 304);
this.butCommit.Name = "butCommit";
this.butCommit.Size = new System.Drawing.Size(64, 24);
this.butCommit.TabIndex = 16;
this.butCommit.Text = "满足订单";
this.butCommit.Click += new System.EventHandler(this.butCommit_Click);
//
// label2
//
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Location = new System.Drawing.Point(40, 27);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 14;
this.label2.Text = "客户ID";
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(40, 67);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 13;
this.label1.Text = "订单号";
//
// butLast
//
this.butLast.BackColor = System.Drawing.Color.Transparent;
this.butLast.Location = new System.Drawing.Point(268, 232);
this.butLast.Name = "butLast";
this.butLast.Size = new System.Drawing.Size(56, 24);
this.butLast.TabIndex = 29;
this.butLast.Text = ">|";
this.butLast.Click += new System.EventHandler(this.butLast_Click);
//
// butFirst
//
this.butFirst.BackColor = System.Drawing.Color.Transparent;
this.butFirst.Location = new System.Drawing.Point(100, 232);
this.butFirst.Name = "butFirst";
this.butFirst.Size = new System.Drawing.Size(56, 24);
this.butFirst.TabIndex = 28;
this.butFirst.Text = "|<";
this.butFirst.Click += new System.EventHandler(this.butFirst_Click);
//
// butNext
//
this.butNext.BackColor = System.Drawing.Color.Transparent;
this.butNext.Location = new System.Drawing.Point(212, 232);
this.butNext.Name = "butNext";
this.butNext.Size = new System.Drawing.Size(56, 24);
this.butNext.TabIndex = 27;
this.butNext.Text = ">";
this.butNext.Click += new System.EventHandler(this.butNext_Click);
//
// butPrev
//
this.butPrev.BackColor = System.Drawing.Color.Transparent;
this.butPrev.Location = new System.Drawing.Point(156, 232);
this.butPrev.Name = "butPrev";
this.butPrev.Size = new System.Drawing.Size(56, 24);
this.butPrev.TabIndex = 26;
this.butPrev.Text = "<";
this.butPrev.Click += new System.EventHandler(this.butPrev_Click);
//
// orderquantity
//
this.orderquantity.Location = new System.Drawing.Point(120, 184);
this.orderquantity.Name = "orderquantity";
this.orderquantity.ReadOnly = true;
this.orderquantity.Size = new System.Drawing.Size(208, 21);
this.orderquantity.TabIndex = 33;
this.orderquantity.Text = "orderquantity";
//
// orderprice
//
this.orderprice.Location = new System.Drawing.Point(120, 144);
this.orderprice.Name = "orderprice";
this.orderprice.ReadOnly = true;
this.orderprice.Size = new System.Drawing.Size(208, 21);
this.orderprice.TabIndex = 31;
this.orderprice.Text = "orderprice";
//
// label5
//
this.label5.BackColor = System.Drawing.Color.Transparent;
this.label5.Location = new System.Drawing.Point(40, 184);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 16);
this.label5.TabIndex = 32;
this.label5.Text = "订购数量";
//
// label6
//
this.label6.BackColor = System.Drawing.Color.Transparent;
this.label6.Location = new System.Drawing.Point(40, 144);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(56, 16);
this.label6.TabIndex = 30;
this.label6.Text = "订购价格";
//
// radioButton1
//
this.radioButton1.BackColor = System.Drawing.Color.Transparent;
this.radioButton1.Location = new System.Drawing.Point(184, 272);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(136, 24);
this.radioButton1.TabIndex = 34;
this.radioButton1.Text = "查看已完成的订单";
this.radioButton1.Click += new System.EventHandler(this.radioButton1_Click);
//
// radioButton2
//
this.radioButton2.BackColor = System.Drawing.Color.Transparent;
this.radioButton2.Checked = true;
this.radioButton2.Location = new System.Drawing.Point(48, 272);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(136, 24);
this.radioButton2.TabIndex = 35;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "查看未完成的订单";
this.radioButton2.Click += new System.EventHandler(this.radioButton2_Click);
//
// bookISBN
//
this.bookISBN.Location = new System.Drawing.Point(121, 104);
this.bookISBN.Name = "bookISBN";
this.bookISBN.ReadOnly = true;
this.bookISBN.Size = new System.Drawing.Size(208, 21);
this.bookISBN.TabIndex = 37;
this.bookISBN.Text = "bookSBN";
//
// label3
//
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.Location = new System.Drawing.Point(41, 104);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 36;
this.label3.Text = "图书ISBN";
//
// Form_Customer_LookOverOrders
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(370, 336);
this.Controls.Add(this.bookISBN);
this.Controls.Add(this.label3);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.orderquantity);
this.Controls.Add(this.orderprice);
this.Controls.Add(this.customerID);
this.Controls.Add(this.orderID);
this.Controls.Add(this.label5);
this.Controls.Add(this.label6);
this.Controls.Add(this.butLast);
this.Controls.Add(this.butFirst);
this.Controls.Add(this.butNext);
this.Controls.Add(this.butPrev);
this.Controls.Add(this.butExit);
this.Controls.Add(this.butUpdate);
this.Controls.Add(this.butCommit);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "Form_Customer_LookOverOrders";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "查看订单";
this.Load += new System.EventHandler(this.Form_Customer_LookOverOrders_Load);
this.ResumeLayout(false);
}
#endregion
SQL sql;
string oldorderID="";
public void show()
{
if(sql.rows.GetLength(0)!=0)
{
orderID.Text=sql.rows[sql.getPos(),0].ToString();
bookISBN.Text=sql.rows[sql.getPos(),2].ToString();
orderprice.Text=sql.rows[sql.getPos(),4].ToString();
orderquantity.Text=sql.rows[sql.getPos(),5].ToString();
}
else
{
orderID.Text="";
bookISBN.Text="";
orderprice.Text="";
orderquantity.Text="";
MessageBox.Show("无符合查询条件的结果!","提示");
}
}
private void Form_Customer_LookOverOrders_Load(object sender, System.EventArgs e)
{
customerID.Text=Form_Customer.CUSTOMERID;
sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
sql.ExecuteSQL("select * from 客户订单信息表 where customerID='"+customerID.Text+"' and orderstatus='0' order by orderID");
show();
}
private void butFirst_Click(object sender, System.EventArgs e)
{
sql.pointToFirst();
show();
}
private void butPrev_Click(object sender, System.EventArgs e)
{
sql.pointToPrev();
show();
}
private void butNext_Click(object sender, System.EventArgs e)
{
sql.pointToNext();
show();
}
private void butLast_Click(object sender, System.EventArgs e)
{
sql.pointToLast();
}
private void butUpdate_Click(object sender, System.EventArgs e)
{
if(butUpdate.Text=="修改")
{
butUpdate.Text="更新";
oldorderID=orderID.Text;
orderID.ReadOnly=false;
orderprice.ReadOnly=false;
orderquantity.ReadOnly=false;
butFirst.Enabled=false;
butPrev.Enabled=false;
butNext.Enabled=false;
butLast.Enabled=false;
butCommit.Enabled=false;
butExit.Enabled=false;
}
else
{
if(sql.ExecuteSQL("update 客户订单信息表 set orderID='"+orderID.Text+"',orderprice='"
+orderprice.Text+"',orderquantity='"+orderquantity.Text+"' where customerID='"+customerID.Text
+"'and orderID='"+oldorderID+"'")
==false)
{
show();
}
orderID.ReadOnly=true;
orderprice.ReadOnly=true;
orderquantity.ReadOnly=true;
butUpdate.Text="修改";
butFirst.Enabled=true;
butPrev.Enabled=true;
butNext.Enabled=true;
butLast.Enabled=true;
butCommit.Enabled=true;
butExit.Enabled=true;
}
}
private void butCommit_Click(object sender, System.EventArgs e)
{
if(orderID.Text!="")
{
if(
sql.ExecuteSQL("update 库存信息表 set bookquantity=bookquantity-"+orderquantity.Text+" where bookISBN='"+bookISBN.Text+"'")
==true)
{
if(
sql.ExecuteSQL("update 客户订单信息表 set orderstatus='1' where customerID='"+customerID.Text
+"'and orderID='"+orderID.Text+"'")
==true)
{
MessageBox.Show("订单已满足!","提示");
}
}
show();
}
else
{
MessageBox.Show("还没有选择订单!","提示");
}
}
private void butExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void radioButton2_Click(object sender, System.EventArgs e)
{
butCommit.Enabled=true;
sql.ExecuteSQL("select * from 客户订单信息表 where customerID='"+customerID.Text+"' and orderstatus='0' order by orderID");
show();
}
private void radioButton1_Click(object sender, System.EventArgs e)
{
butCommit.Enabled=false;
sql.ExecuteSQL("select * from 客户订单信息表 where customerID='"+customerID.Text+"' and orderstatus='1' order by orderID");
show();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -