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

📄 frmproductsales.cs

📁 本论文叙述了联机考试系统的现状以及C#语言的概况。重点介绍了联机考试系统的实现过程:包括系统分析、 系统调查、 数据流程分析、功能设计、 数据库设计、 系统物理配置方案、 系统实现、 系统测试和调试。
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
using System.Drawing.Printing;
using System.Text;

namespace SupermarketProject
{
	/// <summary>
	
	/// </summary>
	public class frmProductSales : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.ColumnHeader A;
		private System.Windows.Forms.ColumnHeader B;
		private System.Windows.Forms.ColumnHeader C;
		private System.Windows.Forms.TextBox txtBillDate;
		private System.Windows.Forms.TextBox txtBillNo;
		private System.Windows.Forms.TextBox txtUsrId;
		private System.Windows.Forms.Panel pnlPanel;
		private System.Windows.Forms.Button btnAddItem;
		private System.Windows.Forms.TextBox txtTotalPrice;
		private System.Windows.Forms.TextBox txtSalePrice;
		private System.Windows.Forms.TextBox txtDiscount;
		private System.Windows.Forms.TextBox txtStockPrice;
		private System.Windows.Forms.TextBox txtQty;
		private System.Windows.Forms.TextBox txtProductName;
		private System.Windows.Forms.Panel pnlTotal;
		private System.Windows.Forms.ComboBox cboPaymentMode;
		private System.Windows.Forms.Button btnPrint;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Button btnSave;
		private System.Windows.Forms.ListView lvwBillDetails;
		private System.Windows.Forms.ComboBox cboProductId;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.Label lblBillNo;
		private System.Windows.Forms.Label lblUserId;
		private System.Windows.Forms.Label lblQty;
		private System.Windows.Forms.Label lblProdNo;
		private System.Windows.Forms.Label lblTotalPrice;
		private System.Windows.Forms.Label lblSalePrice;
		private System.Windows.Forms.Label lblDiscount;
		private System.Windows.Forms.Label lblStockPrice;
		private System.Windows.Forms.Label lblPaymentMode;
		private System.Windows.Forms.Label lblTotalBillAmt;
		private System.Windows.Forms.TextBox txtTotalBillAmt;
		private System.Windows.Forms.ErrorProvider errProductSales;
		private System.Windows.Forms.HelpProvider hlpProdSales;
		private System.Windows.Forms.ToolTip tipProdSales;
		
		//other variables
		private string errorMsg;
		public static int index;
		public static int prodCount = 0;
		private string userName;
		private DataRow[] drBillDet;
		private decimal salePrice, purPrice, totalPrice,discount;
		private int billNo;
		private System.Windows.Forms.ColumnHeader D;
		private OleDbDataReader reader;
		private string[] items=new string[4];
		private decimal totalbillamt=0;
		private int stockid;
		private OleDbDataAdapter adapter1,adapter2;
		private DataSet ds;
		private DateTime validFrom,validTo;
		private long qoh;
		private System.Windows.Forms.PrintDialog pdlgBill;
		private System.Drawing.Printing.PrintDocument pDocBill;
		private System.Windows.Forms.PrintPreviewDialog ppdlgBill;
		private System.Windows.Forms.GroupBox grpSales;
		private System.Windows.Forms.Label lblDate;
		private System.Windows.Forms.Button btnPreview;
		private Settings settings;

		public frmProductSales(string userName)
		{
			try
			{
				settings=new Settings();
				//initialize certain members
				drBillDet = new DataRow[50];
				index = 0;
				this.userName = userName;
				
				//create dataset that will store two tables, one for Bills master table and one for Bill details child table

				//first adapter 
					
				adapter1 = new OleDbDataAdapter("select * from Bills",DataConnection.oleconn);
				this.ds = new  DataSet();
				adapter1.Fill (ds,"Bills");
            
				//second adapter 
				adapter2 = new OleDbDataAdapter("select * from BillDetails",DataConnection.oleconn);

				adapter2.Fill (ds, "BillDetails");
			
				//add master detail relationship
				ds.Relations.Add("ParentChild",ds.Tables["Bills"].Columns["BillNo"],ds.Tables["BillDetails"].Columns["BillNo"]);
				ds.Tables[1].Clear();			
			
				InitializeComponent();
                this.hlpProdSales.HelpNamespace=settings.uiDirectory+ @"\HELP\SupermarketHelp.chm"; 
			}
			catch(Exception e)
			{ MessageBox.Show("发生错误  " + e.Message.ToString()) ; } 
		}

		/// <summary>
		
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmProductSales));
			this.grpSales = new System.Windows.Forms.GroupBox();
			this.txtBillDate = new System.Windows.Forms.TextBox();
			this.lblDate = new System.Windows.Forms.Label();
			this.txtBillNo = new System.Windows.Forms.TextBox();
			this.lblBillNo = new System.Windows.Forms.Label();
			this.txtUsrId = new System.Windows.Forms.TextBox();
			this.lblUserId = new System.Windows.Forms.Label();
			this.pnlPanel = new System.Windows.Forms.Panel();
			this.cboProductId = new System.Windows.Forms.ComboBox();
			this.btnAddItem = new System.Windows.Forms.Button();
			this.txtTotalPrice = new System.Windows.Forms.TextBox();
			this.lblTotalPrice = new System.Windows.Forms.Label();
			this.txtSalePrice = new System.Windows.Forms.TextBox();
			this.lblSalePrice = new System.Windows.Forms.Label();
			this.txtDiscount = new System.Windows.Forms.TextBox();
			this.lblDiscount = new System.Windows.Forms.Label();
			this.txtStockPrice = new System.Windows.Forms.TextBox();
			this.lblStockPrice = new System.Windows.Forms.Label();
			this.txtQty = new System.Windows.Forms.TextBox();
			this.lblQty = new System.Windows.Forms.Label();
			this.txtProductName = new System.Windows.Forms.TextBox();
			this.label5 = new System.Windows.Forms.Label();
			this.lblProdNo = new System.Windows.Forms.Label();
			this.pnlTotal = new System.Windows.Forms.Panel();
			this.btnPreview = new System.Windows.Forms.Button();
			this.lblPaymentMode = new System.Windows.Forms.Label();
			this.cboPaymentMode = new System.Windows.Forms.ComboBox();
			this.btnPrint = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.txtTotalBillAmt = new System.Windows.Forms.TextBox();
			this.lblTotalBillAmt = new System.Windows.Forms.Label();
			this.btnSave = new System.Windows.Forms.Button();
			this.lvwBillDetails = new System.Windows.Forms.ListView();
			this.A = new System.Windows.Forms.ColumnHeader();
			this.B = new System.Windows.Forms.ColumnHeader();
			this.C = new System.Windows.Forms.ColumnHeader();
			this.D = new System.Windows.Forms.ColumnHeader();
			this.errProductSales = new System.Windows.Forms.ErrorProvider();
			this.hlpProdSales = new System.Windows.Forms.HelpProvider();
			this.tipProdSales = new System.Windows.Forms.ToolTip(this.components);
			this.pdlgBill = new System.Windows.Forms.PrintDialog();
			this.pDocBill = new System.Drawing.Printing.PrintDocument();
			this.ppdlgBill = new System.Windows.Forms.PrintPreviewDialog();
			this.grpSales.SuspendLayout();
			this.pnlPanel.SuspendLayout();
			this.pnlTotal.SuspendLayout();
			this.SuspendLayout();
			// 
			// grpSales
			// 
			this.grpSales.Controls.Add(this.txtBillDate);
			this.grpSales.Controls.Add(this.lblDate);
			this.grpSales.Controls.Add(this.txtBillNo);
			this.grpSales.Controls.Add(this.lblBillNo);
			this.grpSales.Controls.Add(this.txtUsrId);
			this.grpSales.Controls.Add(this.lblUserId);
			this.grpSales.Dock = System.Windows.Forms.DockStyle.Top;
			this.grpSales.Location = new System.Drawing.Point(0, 0);
			this.grpSales.Name = "grpSales";
			this.grpSales.Size = new System.Drawing.Size(698, 56);
			this.grpSales.TabIndex = 0;
			this.grpSales.TabStop = false;
			this.grpSales.Text = "帐单信息";
			// 
			// txtBillDate
			// 
			this.txtBillDate.BackColor = System.Drawing.Color.Gray;
			this.txtBillDate.ForeColor = System.Drawing.SystemColors.Info;
			this.txtBillDate.Location = new System.Drawing.Point(544, 22);
			this.txtBillDate.Name = "txtBillDate";
			this.txtBillDate.ReadOnly = true;
			this.txtBillDate.Size = new System.Drawing.Size(142, 21);
			this.txtBillDate.TabIndex = 5;
			this.txtBillDate.Text = "";
			// 
			// lblDate
			// 
			this.lblDate.Location = new System.Drawing.Point(464, 26);
			this.lblDate.Name = "lblDate";
			this.lblDate.Size = new System.Drawing.Size(60, 20);
			this.lblDate.TabIndex = 4;
			this.lblDate.Text = "日期";
			this.lblDate.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// txtBillNo
			// 
			this.txtBillNo.BackColor = System.Drawing.Color.Gray;
			this.txtBillNo.Enabled = false;
			this.txtBillNo.ForeColor = System.Drawing.SystemColors.Info;
			this.txtBillNo.Location = new System.Drawing.Point(328, 22);
			this.txtBillNo.Name = "txtBillNo";
			this.txtBillNo.Size = new System.Drawing.Size(120, 21);
			this.txtBillNo.TabIndex = 3;
			this.txtBillNo.Text = "";
			// 
			// lblBillNo
			// 
			this.lblBillNo.Location = new System.Drawing.Point(246, 24);
			this.lblBillNo.Name = "lblBillNo";
			this.lblBillNo.Size = new System.Drawing.Size(70, 20);
			this.lblBillNo.TabIndex = 2;
			this.lblBillNo.Text = "帐单编号";
			this.lblBillNo.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// txtUsrId
			// 
			this.txtUsrId.BackColor = System.Drawing.Color.Gray;
			this.txtUsrId.Enabled = false;
			this.txtUsrId.ForeColor = System.Drawing.SystemColors.Info;
			this.txtUsrId.Location = new System.Drawing.Point(100, 22);
			this.txtUsrId.Name = "txtUsrId";
			this.txtUsrId.Size = new System.Drawing.Size(140, 21);
			this.txtUsrId.TabIndex = 1;
			this.txtUsrId.Text = "";
			// 
			// lblUserId
			// 
			this.lblUserId.Location = new System.Drawing.Point(12, 24);
			this.lblUserId.Name = "lblUserId";
			this.lblUserId.Size = new System.Drawing.Size(60, 20);
			this.lblUserId.TabIndex = 0;
			this.lblUserId.Text = "操作员";
			this.lblUserId.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// pnlPanel
			// 
			this.pnlPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.pnlPanel.Controls.Add(this.cboProductId);
			this.pnlPanel.Controls.Add(this.btnAddItem);
			this.pnlPanel.Controls.Add(this.txtTotalPrice);
			this.pnlPanel.Controls.Add(this.lblTotalPrice);
			this.pnlPanel.Controls.Add(this.txtSalePrice);
			this.pnlPanel.Controls.Add(this.lblSalePrice);
			this.pnlPanel.Controls.Add(this.txtDiscount);
			this.pnlPanel.Controls.Add(this.lblDiscount);
			this.pnlPanel.Controls.Add(this.txtStockPrice);
			this.pnlPanel.Controls.Add(this.lblStockPrice);
			this.pnlPanel.Controls.Add(this.txtQty);
			this.pnlPanel.Controls.Add(this.lblQty);
			this.pnlPanel.Controls.Add(this.txtProductName);
			this.pnlPanel.Controls.Add(this.label5);
			this.pnlPanel.Controls.Add(this.lblProdNo);
			this.pnlPanel.Dock = System.Windows.Forms.DockStyle.Top;
			this.pnlPanel.Location = new System.Drawing.Point(0, 56);
			this.pnlPanel.Name = "pnlPanel";
			this.pnlPanel.Size = new System.Drawing.Size(698, 130);
			this.pnlPanel.TabIndex = 1;
			// 
			// cboProductId
			// 
			this.cboProductId.Location = new System.Drawing.Point(104, 8);
			this.cboProductId.Name = "cboProductId";
			this.cboProductId.Size = new System.Drawing.Size(121, 23);
			this.cboProductId.TabIndex = 1;
			this.cboProductId.MouseHover += new System.EventHandler(this.cboProductId_MouseHover);
			this.cboProductId.Leave += new System.EventHandler(this.cboProductId_Leave);
			// 
			// btnAddItem
			// 
			this.btnAddItem.Enabled = false;
			this.btnAddItem.Location = new System.Drawing.Point(572, 98);
			this.btnAddItem.Name = "btnAddItem";
			this.btnAddItem.Size = new System.Drawing.Size(110, 22);
			this.btnAddItem.TabIndex = 14;
			this.btnAddItem.Text = "添加产品(&A)";
			this.btnAddItem.Click += new System.EventHandler(this.btnAddItem_Click);
			this.btnAddItem.MouseHover += new System.EventHandler(this.btnAddItem_MouseHover);
			// 
			// txtTotalPrice
			// 
			this.txtTotalPrice.BackColor = System.Drawing.SystemColors.Menu;
			this.txtTotalPrice.Enabled = false;
			this.txtTotalPrice.Location = new System.Drawing.Point(98, 98);
			this.txtTotalPrice.Name = "txtTotalPrice";
			this.txtTotalPrice.Size = new System.Drawing.Size(140, 21);
			this.txtTotalPrice.TabIndex = 13;
			this.txtTotalPrice.Text = "";
			// 
			// lblTotalPrice
			// 
			this.lblTotalPrice.Location = new System.Drawing.Point(6, 98);
			this.lblTotalPrice.Name = "lblTotalPrice";
			this.lblTotalPrice.Size = new System.Drawing.Size(92, 18);
			this.lblTotalPrice.TabIndex = 12;
			this.lblTotalPrice.Text = "产品总价";
			this.lblTotalPrice.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// txtSalePrice
			// 
			this.txtSalePrice.BackColor = System.Drawing.SystemColors.Menu;
			this.txtSalePrice.Enabled = false;
			this.txtSalePrice.Location = new System.Drawing.Point(542, 38);
			this.txtSalePrice.Name = "txtSalePrice";
			this.txtSalePrice.Size = new System.Drawing.Size(142, 21);
			this.txtSalePrice.TabIndex = 11;
			this.txtSalePrice.Text = "";
			// 
			// lblSalePrice
			// 
			this.lblSalePrice.Location = new System.Drawing.Point(452, 40);
			this.lblSalePrice.Name = "lblSalePrice";
			this.lblSalePrice.Size = new System.Drawing.Size(92, 18);
			this.lblSalePrice.TabIndex = 10;
			this.lblSalePrice.Text = "售价";
			this.lblSalePrice.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// txtDiscount
			// 
			this.txtDiscount.BackColor = System.Drawing.SystemColors.Menu;

⌨️ 快捷键说明

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