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

📄 form_customer.cs

📁 中小型书店图书购书系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.butDelete.BackColor = System.Drawing.Color.Transparent;
			this.butDelete.Location = new System.Drawing.Point(300, 272);
			this.butDelete.Name = "butDelete";
			this.butDelete.Size = new System.Drawing.Size(64, 24);
			this.butDelete.TabIndex = 48;
			this.butDelete.Text = "删除";
			this.butDelete.Click += new System.EventHandler(this.butDelete_Click);
			// 
			// butAdd
			// 
			this.butAdd.BackColor = System.Drawing.Color.Transparent;
			this.butAdd.Location = new System.Drawing.Point(236, 272);
			this.butAdd.Name = "butAdd";
			this.butAdd.Size = new System.Drawing.Size(64, 24);
			this.butAdd.TabIndex = 47;
			this.butAdd.Text = "添加";
			this.butAdd.Click += new System.EventHandler(this.butAdd_Click);
			// 
			// butAlter
			// 
			this.butAlter.BackColor = System.Drawing.Color.Transparent;
			this.butAlter.Location = new System.Drawing.Point(172, 272);
			this.butAlter.Name = "butAlter";
			this.butAlter.Size = new System.Drawing.Size(64, 24);
			this.butAlter.TabIndex = 46;
			this.butAlter.Text = "修改";
			this.butAlter.Click += new System.EventHandler(this.butAlter_Click);
			// 
			// butShowAll
			// 
			this.butShowAll.BackColor = System.Drawing.Color.Transparent;
			this.butShowAll.Location = new System.Drawing.Point(364, 272);
			this.butShowAll.Name = "butShowAll";
			this.butShowAll.Size = new System.Drawing.Size(64, 24);
			this.butShowAll.TabIndex = 49;
			this.butShowAll.Text = "全部显示";
			this.butShowAll.Click += new System.EventHandler(this.butShowAll_Click);
			// 
			// Form_Customer
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(472, 382);
			this.ControlBox = false;
			this.Controls.Add(this.butShowAll);
			this.Controls.Add(this.butDelete);
			this.Controls.Add(this.butAdd);
			this.Controls.Add(this.butAlter);
			this.Controls.Add(this.butLast);
			this.Controls.Add(this.butFirst);
			this.Controls.Add(this.butNext);
			this.Controls.Add(this.butPrev);
			this.Controls.Add(this.comboBox2);
			this.Controls.Add(this.textForSearch);
			this.Controls.Add(this.customername);
			this.Controls.Add(this.customerID);
			this.Controls.Add(this.customeremail);
			this.Controls.Add(this.customersex);
			this.Controls.Add(this.customertelephone);
			this.Controls.Add(this.customeraddress);
			this.Controls.Add(this.customerinfo);
			this.Controls.Add(this.butSearch);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.AddOrder);
			this.Controls.Add(this.butLookOverOrders);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Name = "Form_Customer";
			this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
			this.Text = "Form_Customer";
			this.Load += new System.EventHandler(this.Form_Customer_Load);
			this.ResumeLayout(false);

		}
		#endregion

		SQL sql;
		string oldcustomerID="";
		public static string CUSTOMERID="";
		public static string CUSTOMERNAME="";

		private void butLookOverOrders_Click(object sender, System.EventArgs e)
		{
			Form_Customer_LookOverOrders child=new Form_Customer_LookOverOrders();
			child.ShowDialog();
		}

		private void AddOrder_Click(object sender, System.EventArgs e)
		{
			if(customerID.Text!="")
			{
				Form_Customer_AddOrder child=new Form_Customer_AddOrder();
				child.ShowDialog();
			}
			else
			{
				MessageBox.Show("请先选择一个客户!","提示");
			}
		}

		public void show()
		{
			if(sql.rows.GetLength(0)!=0)
			{
				customerID.Text=sql.rows[sql.getPos(),0].ToString();
				customername.Text=sql.rows[sql.getPos(),1].ToString();
				customerinfo.Text=sql.rows[sql.getPos(),2].ToString();
				customeraddress.Text=sql.rows[sql.getPos(),3].ToString();
				customertelephone.Text=sql.rows[sql.getPos(),4].ToString();
				customersex.Text=sql.rows[sql.getPos(),5].ToString();
				customeremail.Text=sql.rows[sql.getPos(),6].ToString();
			}
			else
			{
				customerID.Text="";
				customername.Text="";
				customerinfo.Text="";
				customeraddress.Text="";
				customertelephone.Text="";
				customersex.Text="";
				customeremail.Text="";
				MessageBox.Show("无符合查询条件的结果!","提示");
			}
			CUSTOMERID=customerID.Text;
			CUSTOMERNAME=customername.Text;
		}

		private void Form_Customer_Load(object sender, System.EventArgs e)
		{
			sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
			sql.ExecuteSQL("select * from 客户信息表 order by customerID");
			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();
			show();
		}

		private void butAlter_Click(object sender, System.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 客户信息表 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 客户订单信息表 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, System.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(sql.ExecuteSQL("insert into 客户信息表 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, System.EventArgs e)
		{
			sql.ExecuteSQL("delete from 客户信息表 where customerID='"+customerID.Text+"'");
			show();
		}

		private void butSearch_Click(object sender, System.EventArgs e)
		{
			if(comboBox1.Text=="客户名称")
			{
				if(comboBox2.Text=="精确")
				{
					sql.ExecuteSQL("select * from 客户信息表 where customername='"+textForSearch.Text+"' order by customerID");
					show();
				}
				else
				{
					sql.ExecuteSQL("select * from 客户信息表 where customername like '%"+textForSearch.Text+"%' order by customerID");
					show();
				}
			}
			else
			{
				if(comboBox2.Text=="精确")
				{
					sql.ExecuteSQL("select * from 客户信息表 where customeremail='"+textForSearch.Text+"' order by customerID");
					show();
				}
				else
				{
					sql.ExecuteSQL("select * from 客户信息表 where customeremail like '%"+textForSearch.Text+"%' order by customerID");
					show();
				}
			}
		}

		private void butShowAll_Click(object sender, System.EventArgs e)
		{
			sql.ExecuteSQL("select * from 客户信息表 order by customerID");
			show();
		}
	}
}

⌨️ 快捷键说明

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