⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form_customer_addorder.cs

📁 中小型书店图书购书系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace 图书管理系统
{
	/// <summary>
	/// Form_Customer_AddOrder 的摘要说明。
	/// </summary>
	public class Form_Customer_AddOrder : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button butExit;
		private System.Windows.Forms.Button butCommit;
		private System.Windows.Forms.TextBox orderquantity;
		private System.Windows.Forms.TextBox bookISBN;
		private System.Windows.Forms.TextBox bookname;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button butSelect;
		private System.Windows.Forms.TextBox customername;
		private System.Windows.Forms.TextBox customerID;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.TextBox orderID;
		private System.Windows.Forms.Label label6;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form_Customer_AddOrder()
		{
			//
			// 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_AddOrder));
			this.butExit = new System.Windows.Forms.Button();
			this.butCommit = new System.Windows.Forms.Button();
			this.orderquantity = new System.Windows.Forms.TextBox();
			this.bookISBN = new System.Windows.Forms.TextBox();
			this.bookname = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.butSelect = new System.Windows.Forms.Button();
			this.customername = new System.Windows.Forms.TextBox();
			this.customerID = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.orderID = new System.Windows.Forms.TextBox();
			this.label6 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// butExit
			// 
			this.butExit.BackColor = System.Drawing.Color.Transparent;
			this.butExit.Location = new System.Drawing.Point(232, 264);
			this.butExit.Name = "butExit";
			this.butExit.Size = new System.Drawing.Size(80, 24);
			this.butExit.TabIndex = 25;
			this.butExit.Text = "退出";
			this.butExit.Click += new System.EventHandler(this.butExit_Click);
			// 
			// butCommit
			// 
			this.butCommit.BackColor = System.Drawing.Color.Transparent;
			this.butCommit.Location = new System.Drawing.Point(96, 264);
			this.butCommit.Name = "butCommit";
			this.butCommit.Size = new System.Drawing.Size(80, 24);
			this.butCommit.TabIndex = 24;
			this.butCommit.Text = "提交订单";
			this.butCommit.Click += new System.EventHandler(this.butCommit_Click);
			// 
			// orderquantity
			// 
			this.orderquantity.Location = new System.Drawing.Point(120, 216);
			this.orderquantity.Name = "orderquantity";
			this.orderquantity.Size = new System.Drawing.Size(208, 21);
			this.orderquantity.TabIndex = 23;
			this.orderquantity.Text = "";
			// 
			// bookISBN
			// 
			this.bookISBN.Location = new System.Drawing.Point(120, 136);
			this.bookISBN.Name = "bookISBN";
			this.bookISBN.ReadOnly = true;
			this.bookISBN.Size = new System.Drawing.Size(208, 21);
			this.bookISBN.TabIndex = 22;
			this.bookISBN.Text = "";
			// 
			// bookname
			// 
			this.bookname.Location = new System.Drawing.Point(120, 176);
			this.bookname.Name = "bookname";
			this.bookname.ReadOnly = true;
			this.bookname.Size = new System.Drawing.Size(208, 21);
			this.bookname.TabIndex = 21;
			this.bookname.Text = "";
			// 
			// label3
			// 
			this.label3.BackColor = System.Drawing.Color.Transparent;
			this.label3.Location = new System.Drawing.Point(32, 216);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(68, 16);
			this.label3.TabIndex = 20;
			this.label3.Text = "订购数量";
			// 
			// label2
			// 
			this.label2.BackColor = System.Drawing.Color.Transparent;
			this.label2.Location = new System.Drawing.Point(32, 136);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(68, 16);
			this.label2.TabIndex = 19;
			this.label2.Text = "ISBN";
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.Color.Transparent;
			this.label1.Location = new System.Drawing.Point(32, 176);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(68, 16);
			this.label1.TabIndex = 18;
			this.label1.Text = "书名";
			// 
			// butSelect
			// 
			this.butSelect.BackColor = System.Drawing.Color.Transparent;
			this.butSelect.Location = new System.Drawing.Point(344, 136);
			this.butSelect.Name = "butSelect";
			this.butSelect.Size = new System.Drawing.Size(32, 20);
			this.butSelect.TabIndex = 26;
			this.butSelect.Text = "...";
			this.butSelect.Click += new System.EventHandler(this.butSelect_Click);
			// 
			// customername
			// 
			this.customername.Location = new System.Drawing.Point(120, 96);
			this.customername.Name = "customername";
			this.customername.ReadOnly = true;
			this.customername.Size = new System.Drawing.Size(208, 21);
			this.customername.TabIndex = 30;
			this.customername.Text = "";
			// 
			// customerID
			// 
			this.customerID.Location = new System.Drawing.Point(120, 56);
			this.customerID.Name = "customerID";
			this.customerID.ReadOnly = true;
			this.customerID.Size = new System.Drawing.Size(208, 21);
			this.customerID.TabIndex = 29;
			this.customerID.Text = "";
			// 
			// label4
			// 
			this.label4.BackColor = System.Drawing.Color.Transparent;
			this.label4.Location = new System.Drawing.Point(32, 96);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(68, 16);
			this.label4.TabIndex = 28;
			this.label4.Text = "客户名称";
			// 
			// label5
			// 
			this.label5.BackColor = System.Drawing.Color.Transparent;
			this.label5.Location = new System.Drawing.Point(32, 56);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(68, 16);
			this.label5.TabIndex = 27;
			this.label5.Text = "客户ID";
			// 
			// orderID
			// 
			this.orderID.Location = new System.Drawing.Point(120, 16);
			this.orderID.Name = "orderID";
			this.orderID.Size = new System.Drawing.Size(208, 21);
			this.orderID.TabIndex = 32;
			this.orderID.Text = "";
			// 
			// label6
			// 
			this.label6.BackColor = System.Drawing.Color.Transparent;
			this.label6.Location = new System.Drawing.Point(32, 16);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(68, 16);
			this.label6.TabIndex = 31;
			this.label6.Text = "订单号";
			// 
			// Form_Customer_AddOrder
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(408, 310);
			this.Controls.Add(this.orderID);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.customername);
			this.Controls.Add(this.customerID);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.butSelect);
			this.Controls.Add(this.butExit);
			this.Controls.Add(this.butCommit);
			this.Controls.Add(this.orderquantity);
			this.Controls.Add(this.bookISBN);
			this.Controls.Add(this.bookname);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Name = "Form_Customer_AddOrder";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "添加订单";
			this.Load += new System.EventHandler(this.Form_Customer_AddOrder_Load);
			this.ResumeLayout(false);

		}
		#endregion

		SQL sql;
		private void butSelect_Click(object sender, System.EventArgs e)
		{
			Form_Customer_AddOrder_SelectBook child=new Form_Customer_AddOrder_SelectBook();
			child.ShowDialog();
			bookISBN.Text=Form_Customer_AddOrder_SelectBook.BOOKISBN;
			bookname.Text=Form_Customer_AddOrder_SelectBook.BOOKNAME;
		}

		private void Form_Customer_AddOrder_Load(object sender, System.EventArgs e)
		{
			sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
			customerID.Text=Form_Customer.CUSTOMERID;
			customername.Text=Form_Customer.CUSTOMERNAME;
		}

		private void butCommit_Click(object sender, System.EventArgs e)
		{
			try
			{
				int.Parse(orderquantity.Text);
			}
			catch
			{
				MessageBox.Show("订购数量必须为整型数,提交失败!","提示");
				return;
			}
			if(Form_Customer_AddOrder_SelectBook.BOOKPRICE=="")
			{
				MessageBox.Show("请先选择一本书!","提示");
				return;
			}
			string orderdate=System.DateTime.Now.Year.ToString()+STR.add0(System.DateTime.Now.Month.ToString())+STR.add0(System.DateTime.Now.Day.ToString());
			double orderprice=Convert.ToDouble(Convert.ToDouble(orderquantity.Text)*Convert.ToDouble(Form_Customer_AddOrder_SelectBook.BOOKPRICE));
			if(sql.ExecuteSQL("insert into 客户订单信息表 values('"
				+orderID.Text+"','"+customerID.Text+"','"+bookISBN.Text+"','"
				+orderdate+"','"+orderprice+"','"+orderquantity.Text+"','0')")
				==false)
			{
				orderID.Text="";
				orderquantity.Text="";
			}
			else MessageBox.Show("提交成功!","提示");
		}

		private void butExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -