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

📄 frmdiscountmgmt.cs

📁 本论文叙述了联机考试系统的现状以及C#语言的概况。重点介绍了联机考试系统的实现过程:包括系统分析、 系统调查、 数据流程分析、功能设计、 数据库设计、 系统物理配置方案、 系统实现、 系统测试和调试。
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.lblModToDate.Size = new System.Drawing.Size(67, 25);
			this.lblModToDate.TabIndex = 4;
			this.lblModToDate.Text = "终止日期";
			this.lblModToDate.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblModFrmDate
			// 
			this.lblModFrmDate.Location = new System.Drawing.Point(182, 34);
			this.lblModFrmDate.Name = "lblModFrmDate";
			this.lblModFrmDate.Size = new System.Drawing.Size(87, 25);
			this.lblModFrmDate.TabIndex = 2;
			this.lblModFrmDate.Text = "起始日期";
			this.lblModFrmDate.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblmodDiscount
			// 
			this.lblmodDiscount.Location = new System.Drawing.Point(10, 34);
			this.lblmodDiscount.Name = "lblmodDiscount";
			this.lblmodDiscount.Size = new System.Drawing.Size(67, 25);
			this.lblmodDiscount.TabIndex = 0;
			this.lblmodDiscount.Text = "折扣";
			this.lblmodDiscount.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// frmDiscountMgmt
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(844, 427);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.grpAddDiscount);
			this.Controls.Add(this.lvwStkId);
			this.Controls.Add(this.lblStockId);
			this.Controls.Add(this.lblProductName);
			this.Controls.Add(this.lvwPrdName);
			this.Controls.Add(this.btnUpdate);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.grpModDiscount);
			this.Name = "frmDiscountMgmt";
			this.Text = "折扣管理";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmDiscountMgmt_Closing);
			this.Load += new System.EventHandler(this.frmDiscountMgmt_Load);
			this.grpAddDiscount.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.updDiscount)).EndInit();
			this.grpModDiscount.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.updModDiscount)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void frmDiscountMgmt_Load(object sender, System.EventArgs e)
		{
			DataConnection.load();
			DataConnection.commnd.CommandText ="Select ProductName from products";

			try
			{
				OleDbDataReader reader = DataConnection.commnd.ExecuteReader();
				while(reader.Read())
				{
					this.lvwPrdName.Items.Add(reader.GetString(0));
				}
				reader.Close();
			}
			catch(OleDbException myException)
			{
				MessageBox.Show(myException.Message);
				//this.Close();
			}

			this.grpModDiscount.Enabled = false;
			this.grpAddDiscount.Enabled = false;
			this.btnAdd.Enabled = false;
			this.btnUpdate.Enabled = false;
		}

	private void lvwPrdName_Click(object sender, System.EventArgs e)
	{
		try{
		this.ClearDetails();
		this.lvwStkId.Clear();
		prodName = this.lvwPrdName.SelectedItems[0].Text; 
		DataConnection.load();
		DataConnection.commnd.CommandText = "Select StockId from Stock where 				ProductId=(select productid from products where ProductName='"+prodName+"')";
		
			OleDbDataReader reader = DataConnection.commnd.ExecuteReader();
			//Console.WriteLine(reader.HasRows);
			while(reader.Read())
			{
				this.lvwStkId.Items.Add(reader.GetInt32(0).ToString());
			}
			reader.Close();
		}
		catch(Exception myException)
		{
			MessageBox.Show(myException.Message);
			//this.Close();
		}
	}

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			frmMainMenu.varDisMgmt =  0;
			this.Close();
		}

		private void ClearDetails()
		{
		  this.updDiscount.Value = 0;
		  this.dtpFrmDate.Value = System.DateTime.Today;
		  this.dtpToDate.Value = System.DateTime.Today;

		  this.updModDiscount.Value =0;
		  this.dtpModFrmDate.Value = System.DateTime.Today;
		  this.dtpModToDate.Value = System.DateTime.Today;

		}
		
		private void lvwStkId_Click(object sender, System.EventArgs e)
		{
			this.ClearDetails();
		    stockId = Convert.ToInt32(this.lvwStkId.SelectedItems[0].Text); 

			DiscountMgmt dismgmt = new DiscountMgmt();

			if(dismgmt.FetchDiscountDetails(stockId).Rows.Count >0)
			{
				MessageBox.Show("找到记录...您可以修改数据");
				DataTable dt = 	dismgmt.FetchDiscountDetails(stockId);
				DataRow dr = dt.Rows[0];
				
				this.updModDiscount.Value = Convert.ToInt32(dr["Discount"]);
				this.dtpModFrmDate.Text = dr["ValidFrom"].ToString();
				this.dtpModToDate.Text = dr["ValidTo"].ToString();
					
				this.btnAdd.Enabled = false;
				this.grpAddDiscount.Enabled = false;
				this.grpModDiscount.Enabled = true;
				this.btnUpdate.Enabled = true;

			}
			else
			{ 			
				MessageBox.Show("未找到记录 ... 您可以添加库存折扣");
				this.btnAdd.Enabled = true;
				this.grpAddDiscount.Enabled = true;
				this.grpModDiscount.Enabled = false;
				this.btnUpdate.Enabled = false;
			}

		}

		private void CollectDiscountNewData()
		{
			this.stDiscnt.StockId = Convert.ToInt32(this.lvwStkId.SelectedItems[0].Text);
			this.stDiscnt.Discount = Convert.ToInt32(this.updDiscount.Value);
			this.stDiscnt.ValidFrom = this.dtpFrmDate.Value.ToShortDateString();
			this.stDiscnt.ValidTo = this.dtpToDate.Value.ToShortDateString();
		 }
		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			if(this.dtpFrmDate.Value > this.dtpToDate.Value)
			{
				MessageBox.Show("终止日期应该晚于起始日期");
				this.dtpToDate.Focus();
			}
			else if(this.updDiscount.Value <=0)
			{
				MessageBox.Show("输入选定库存的折扣");
				this.updDiscount.Focus();
			}
			else
			{
				this.CollectDiscountNewData();   
				DiscountMgmt dismgmt = new DiscountMgmt();
				dismgmt.AddDiscount(this.stDiscnt);
				MessageBox.Show("折扣摘要已添加");
				this.lvwStkId.Clear();
				this.lvwPrdName.Focus();
				this.btnAdd.Enabled = false;
				this.grpAddDiscount.Enabled = false;
			}
	}

		private void CollectDiscountModifyData()
		{
			this.stDiscnt.StockId = Convert.ToInt32(this.lvwStkId.SelectedItems[0].Text);
			this.stDiscnt.Discount = Convert.ToInt32(this.updModDiscount.Value);
			this.stDiscnt.ValidFrom = this.dtpModFrmDate.Value.ToShortDateString();
			this.stDiscnt.ValidTo = this.dtpModToDate.Value.ToShortDateString();
		}

		private void btnUpdate_Click(object sender, System.EventArgs e)
		{
			//Checking if any values has changed
			DiscountMgmt dismgmt = new DiscountMgmt();
			DataTable dt = 	dismgmt.FetchDiscountDetails(stockId);
			DataRow dr = dt.Rows[0];

			if ((this.updModDiscount.Value != Convert.ToInt32(dr["Discount"])) || (this.dtpModFrmDate.Value.ToString() != dr["ValidFrom"].ToString()) || (this.dtpModToDate.Value.ToString() != dr["ValidTo"].ToString()))  
				
			{
				if(this.dtpModFrmDate.Value > this.dtpModToDate.Value)
				{
					MessageBox.Show("终止日期应该晚于起始日期");
					this.dtpModToDate.Focus();
				}
				else if(this.updModDiscount.Value <=0)
				{
					MessageBox.Show("输入选定库存的折扣");
					this.updModDiscount.Focus();
				}
				else
				{
					this.CollectDiscountModifyData();
					dismgmt.ModifyDiscount(this.stDiscnt);
					MessageBox.Show("折扣摘要已更新");
					this.lvwStkId.Clear();
					this.lvwPrdName.Focus();
					this.grpModDiscount.Enabled = false;
					this.btnUpdate.Enabled = false;
				}
			}
			else
			{
				MessageBox.Show("没有改变的记录");
			}
			}

		private void frmDiscountMgmt_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			frmMainMenu.varDisMgmt =  0;
		}

		private void lvwPrdName_Enter(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.lvwPrdName,"点击查看产品树");
		}

		private void lvwStkId_Enter(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.lvwStkId,"点击查看库存树");
		}

		private void lvwStkId_MouseHover(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.lvwStkId,"点击查看库存树");
		}

		private void updDiscount_Enter(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.updDiscount,"点击查看产品树");
		}

		private void updModDiscount_Enter(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.updModDiscount,"点击查看产品树");
		}

		private void btnAdd_MouseHover(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.btnAdd,"点击时记录将被更新");
		}

		private void btnUpdate_MouseHover(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.btnUpdate,"点击时记录将被更新");
		}

		private void btnAdd_Enter(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.btnAdd,"点击时记录将被添加");
		}

		private void btnUpdate_Enter(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.btnUpdate,"点击时记录将被更新");
		}

		private void lvwPrdName_MouseHover(object sender, System.EventArgs e)
		{
			this.tipDiscountMgmt.Active =true;
			this.tipDiscountMgmt.SetToolTip(this.lvwPrdName,"点击查看产品树");		
		}
	}
}

⌨️ 快捷键说明

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