discountmgmt.cs

来自「本论文叙述了联机考试系统的现状以及C#语言的概况。重点介绍了联机考试系统的实现过」· CS 代码 · 共 74 行

CS
74
字号
using System;
using System.Data;
using System.Data.OleDb;

namespace SupermarketProject
{
	/// <summary>
	/// Summary description for DiscountMgmt.
	/// </summary>
	
	public struct stDiscount
	{
		public int StockId;
		public int Discount;
		public string ValidFrom;
		public string ValidTo;
	};

	public class DiscountMgmt
	{
		public DiscountMgmt()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public DataTable FetchDiscountDetails(int searchValue)
		{
							
				string str="";
	
				str="Select Discount,ValidFrom ,ValidTo from Discount where StockId ="+searchValue+"";
				
						
				//processing 
				OleDbDataAdapter adapter=new OleDbDataAdapter(str,DataConnection.oleconn);
				DataSet dset = new DataSet();
				
				// Filling the Adapter with values
				adapter.Fill(dset);

				

				// Returning the Data Table
				return dset.Tables[0]; 
			
		}
	
	public void AddDiscount(stDiscount stDisc)
		{
         	
		string str="Insert into Discount(StockId,Discount,ValidFrom,ValidTo)values("+stDisc.StockId+","+stDisc.Discount+",#"+stDisc.ValidFrom+"#,#"+stDisc.ValidTo+"#)";
			Console.WriteLine(str);
			
			DataConnection.commnd.CommandText=str;
			DataConnection.commnd.ExecuteNonQuery ();
			
		}
		
		public void ModifyDiscount(stDiscount stDisc)
		{
			string str="Update Discount set Discount ="+stDisc.Discount+",ValidFrom =#"+stDisc.ValidFrom+"#,validTo = #"+stDisc.ValidTo+"# where StockId = "+stDisc.StockId+"";
			Console.WriteLine(str);
			
			DataConnection.commnd.CommandText=str;
			DataConnection.commnd.ExecuteNonQuery();
			
			Console.WriteLine("已更新");
		}
	
	}
}

⌨️ 快捷键说明

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