sa010.cs

来自「C#简单练习进销存代码」· CS 代码 · 共 741 行 · 第 1/2 页

CS
741
字号
			// label10
			// 
			this.label10.Dock = System.Windows.Forms.DockStyle.Top;
			this.label10.Location = new System.Drawing.Point(5, 185);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(134, 20);
			this.label10.TabIndex = 48;
			this.label10.Text = "A.O.E:";
			this.label10.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// textBox7
			// 
			this.textBox7.Dock = System.Windows.Forms.DockStyle.Top;
			this.textBox7.Location = new System.Drawing.Point(5, 187);
			this.textBox7.Name = "textBox7";
			this.textBox7.Size = new System.Drawing.Size(274, 20);
			this.textBox7.TabIndex = 49;
			this.textBox7.Text = "textBox7";
			// 
			// label11
			// 
			this.label11.Dock = System.Windows.Forms.DockStyle.Top;
			this.label11.Location = new System.Drawing.Point(5, 205);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(134, 20);
			this.label11.TabIndex = 50;
			this.label11.Text = "Profit:";
			this.label11.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// textBox8
			// 
			this.textBox8.Dock = System.Windows.Forms.DockStyle.Top;
			this.textBox8.Location = new System.Drawing.Point(5, 207);
			this.textBox8.Name = "textBox8";
			this.textBox8.ReadOnly = true;
			this.textBox8.Size = new System.Drawing.Size(274, 20);
			this.textBox8.TabIndex = 51;
			this.textBox8.Text = "textBox8";
			// 
			// textBox12
			// 
			this.textBox12.Dock = System.Windows.Forms.DockStyle.Top;
			this.textBox12.Location = new System.Drawing.Point(5, 303);
			this.textBox12.Name = "textBox12";
			this.textBox12.Size = new System.Drawing.Size(274, 20);
			this.textBox12.TabIndex = 61;
			this.textBox12.Text = "textBox12";
			// 
			// textBox11
			// 
			this.textBox11.Dock = System.Windows.Forms.DockStyle.Top;
			this.textBox11.Location = new System.Drawing.Point(5, 283);
			this.textBox11.Name = "textBox11";
			this.textBox11.Size = new System.Drawing.Size(274, 20);
			this.textBox11.TabIndex = 52;
			this.textBox11.Text = "textBox11";
			// 
			// dateTimePicker2
			// 
			this.dateTimePicker2.CustomFormat = "yyyy-MM-dd";
			this.dateTimePicker2.Dock = System.Windows.Forms.DockStyle.Top;
			this.dateTimePicker2.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
			this.dateTimePicker2.Location = new System.Drawing.Point(5, 323);
			this.dateTimePicker2.Name = "dateTimePicker2";
			this.dateTimePicker2.Size = new System.Drawing.Size(274, 20);
			this.dateTimePicker2.TabIndex = 60;
			// 
			// label19
			// 
			this.label19.Dock = System.Windows.Forms.DockStyle.Top;
			this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label19.Location = new System.Drawing.Point(5, 325);
			this.label19.Name = "label19";
			this.label19.Size = new System.Drawing.Size(134, 20);
			this.label19.TabIndex = 59;
			this.label19.Text = "Due Date";
			this.label19.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// label18
			// 
			this.label18.Dock = System.Windows.Forms.DockStyle.Top;
			this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label18.Location = new System.Drawing.Point(5, 305);
			this.label18.Name = "label18";
			this.label18.Size = new System.Drawing.Size(134, 20);
			this.label18.TabIndex = 58;
			this.label18.Text = "Other Payable";
			this.label18.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// label17
			// 
			this.label17.Dock = System.Windows.Forms.DockStyle.Top;
			this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label17.Location = new System.Drawing.Point(5, 285);
			this.label17.Name = "label17";
			this.label17.Size = new System.Drawing.Size(134, 20);
			this.label17.TabIndex = 57;
			this.label17.Text = "Receivable:";
			this.label17.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// textBox10
			// 
			this.textBox10.Dock = System.Windows.Forms.DockStyle.Top;
			this.textBox10.Location = new System.Drawing.Point(5, 247);
			this.textBox10.Name = "textBox10";
			this.textBox10.Size = new System.Drawing.Size(274, 20);
			this.textBox10.TabIndex = 56;
			this.textBox10.Text = "textBox10";
			// 
			// textBox9
			// 
			this.textBox9.Dock = System.Windows.Forms.DockStyle.Top;
			this.textBox9.Location = new System.Drawing.Point(5, 227);
			this.textBox9.Name = "textBox9";
			this.textBox9.Size = new System.Drawing.Size(274, 20);
			this.textBox9.TabIndex = 54;
			this.textBox9.Text = "textBox9";
			// 
			// label16
			// 
			this.label16.Dock = System.Windows.Forms.DockStyle.Top;
			this.label16.Location = new System.Drawing.Point(5, 245);
			this.label16.Name = "label16";
			this.label16.Size = new System.Drawing.Size(134, 20);
			this.label16.TabIndex = 55;
			this.label16.Text = "Certified:";
			this.label16.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// label15
			// 
			this.label15.Dock = System.Windows.Forms.DockStyle.Top;
			this.label15.Location = new System.Drawing.Point(5, 225);
			this.label15.Name = "label15";
			this.label15.Size = new System.Drawing.Size(134, 20);
			this.label15.TabIndex = 53;
			this.label15.Text = "Remarks:";
			this.label15.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// button1
			// 
			this.button1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button1.Location = new System.Drawing.Point(5, 374);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(274, 24);
			this.button1.TabIndex = 62;
			this.button1.Text = "Payment";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// label12
			// 
			this.label12.Dock = System.Windows.Forms.DockStyle.Top;
			this.label12.Location = new System.Drawing.Point(5, 265);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(134, 20);
			this.label12.TabIndex = 60;
			this.label12.Text = "Credit Sales?";
			this.label12.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			// 
			// checkBox1
			// 
			this.checkBox1.Dock = System.Windows.Forms.DockStyle.Top;
			this.checkBox1.Location = new System.Drawing.Point(5, 267);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(274, 16);
			this.checkBox1.TabIndex = 63;
			// 
			// SA010
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(616, 453);
			this.Name = "SA010";
			this.Text = "single";
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.panel3.ResumeLayout(false);
			this.panel4.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.DsMast)).EndInit();

		}		#endregion		protected override void ReFill()
		{
			int p=0;
			
			if(BindMast!=null&&BindMast.Position>0)p=BindMast.Position;
			this.DaMast.SelectCommand =new System.Data.OleDb.OleDbCommand(BasSql+SelSql,((wmMain)this.MdiParent).db);
			System.Data.OleDb.OleDbCommandBuilder  OleDbCommandBuilder1 =new System.Data.OleDb.OleDbCommandBuilder (this.DaMast);
			this.DsMast.Clear();
			
			this.DaMast.Fill(this.DsMast,"Mast");
			
			DsMast.Tables ["Mast"].Columns["PUR_PRICE"].DefaultValue=0;
			DsMast.Tables ["Mast"].Columns["QTY"].DefaultValue=0;
			DsMast.Tables ["Mast"].Columns["TOTALC"].DefaultValue=0;
			DsMast.Tables ["Mast"].Columns["AOE"].DefaultValue=0;
			DsMast.Tables ["Mast"].Columns["SA_PRICE"].DefaultValue=0;
			DsMast.Tables ["Mast"].Columns["RF_CUS"].DefaultValue=0;
			DsMast.Tables ["Mast"].Columns["PT_OT"].DefaultValue=0;
			DsMast.Tables ["Mast"].Columns["CR"].DefaultValue=false;
			
			//
			//Initial CurrencyManager;
			//
			
			this.BindMast =(CurrencyManager)this.BindingContext[DsMast,"Mast"];
			this.BindMast.Position =p;
			//this.BindMast.PositionChanged-=new EventHandler(BindMast_PositionChanged);
			//this.BindMast.PositionChanged+=new EventHandler(BindMast_PositionChanged);
			
			//
			//Initial DataGrid;
			//
			this.dataGrid1.TableStyles.Clear();
			this.dataGrid1.SetDataBinding (this.DsMast,"Mast");
			this.dataGrid1.TableStyles.Add (new DataGridTableStyle());
			dataGrid1.TableStyles[0].MappingName="Mast";
			dataGrid1.TableStyles[0].GridColumnStyles.RemoveAt (0);
			dataGrid1.TableStyles[0].GridColumnStyles.RemoveAt (0);
			dataGrid1.TableStyles[0].GridColumnStyles.RemoveAt (0);
			dataGrid1.TableStyles[0].GridColumnStyles.RemoveAt (0);
			//SwiColSty(dataGrid1.TableStyles[0].GridColumnStyles,6,14);
			//dataGrid1.TableStyles.
			
			//
			//Initial TextBox;
			//
			if(this.textBox1.DataBindings.Count<=0)this.textBox1.DataBindings.Add("Text",this.DsMast,"Mast.SA_CODE");
			if(this.textBox2.DataBindings.Count<=0)this.textBox2.DataBindings.Add("Text",this.DsMast,"Mast.PUR_PRICE");
			if(this.textBox3.DataBindings.Count<=0)this.textBox3.DataBindings.Add("Text",this.DsMast,"Mast.TOTALC");
			if(this.textBox4.DataBindings.Count<=0)this.textBox4.DataBindings.Add("Text",this.DsMast,"Mast.SA_PRICE");
			if(this.textBox5.DataBindings.Count<=0)this.textBox5.DataBindings.Add("Text",this.DsMast,"Mast.QTY");
			if(this.textBox6.DataBindings.Count<=0)this.textBox6.DataBindings.Add("Text",this.DsMast,"Mast.TOTAL_AMOUNT");
			if(this.textBox7.DataBindings.Count<=0)this.textBox7.DataBindings.Add("Text",this.DsMast,"Mast.AOE");
			if(this.textBox8.DataBindings.Count<=0)this.textBox8.DataBindings.Add("Text",this.DsMast,"Mast.PROFIT");
			if(this.textBox9.DataBindings.Count<=0)this.textBox9.DataBindings.Add("Text",this.DsMast,"Mast.REMARKS");
			if(this.textBox10.DataBindings.Count<=0)this.textBox10.DataBindings.Add("Text",this.DsMast,"Mast.CERTIFIED");
			if(this.textBox11.DataBindings.Count<=0)this.textBox11.DataBindings.Add("Text",this.DsMast,"Mast.RF_CUS");
			if(this.textBox12.DataBindings.Count<=0)this.textBox12.DataBindings.Add("Text",this.DsMast,"Mast.PT_OT");
			if(this.checkBox1.DataBindings.Count <=0)this.checkBox1.DataBindings.Add ("Checked",this.DsMast,"Mast.CR"); 

			
			this.dateTimePicker1.Value=System.DateTime.Now;
			if(this.dateTimePicker1.DataBindings.Count<=0)this.dateTimePicker1.DataBindings.Add("Text",this.DsMast,"Mast.SA_DATE");
			this.dateTimePicker2.Value=System.DateTime.Now;
			if(this.dateTimePicker2.DataBindings.Count<=0)this.dateTimePicker2.DataBindings.Add("Text",this.DsMast,"Mast.DUE_DATE");
			
			//if(this.checkBox1.DataBindings.Count<=0)this.checkBox1.DataBindings.Add("Checked", this.DsMast, "Mast.CR");
			
			//
			//Initial the ComboBoxs
			//
			
			System.Data.OleDb.OleDbDataAdapter DaTm=new System.Data.OleDb.OleDbDataAdapter ();
			DaTm.SelectCommand =new System.Data.OleDb.OleDbCommand ("select * from Customer ",((wmMain)this.MdiParent).db);
			DaTm.Fill(this.DsMast,"Cus");
			this.comboBox1.DataSource=this.DsMast.Tables["Cus"];
			this.comboBox1.DisplayMember ="Cus_Name";
			this.comboBox1.ValueMember="Auto_No";
			//	this.comboBox1.DataBindings.Clear(); this.comboBox1.DataBindings.Add("SelectedValue",DsMast,"Mast.PR_ITEM");
			if(comboBox1.DataBindings.Count<=0) this.comboBox1.DataBindings.Add("SelectedValue",DsMast,"Mast.CUS_ID");
			
			DaTm.SelectCommand =new System.Data.OleDb.OleDbCommand ("select * from PR011",((wmMain)this.MdiParent).db);
			DaTm.Fill(this.DsMast,"PR");
			this.comboBox2.DataSource=this.DsMast.Tables["PR"].DefaultView;
			this.DsMast.Tables["PR"].DefaultView.Sort="FNAME";
			this.comboBox2.DisplayMember ="FNAME";
			this.comboBox2.ValueMember="AUTO_NO";
			//	this.comboBox1.DataBindings.Clear(); this.comboBox1.DataBindings.Add("SelectedValue",DsMast,"Mast.PR_ITEM");
			if(comboBox2.DataBindings.Count<=0) this.comboBox2.DataBindings.Add("SelectedValue",DsMast,"Mast.PR_ID");
			
			DaTm.SelectCommand =new System.Data.OleDb.OleDbCommand ("select * from PR_Item",((wmMain)this.MdiParent).db);
			DaTm.Fill(this.DsMast,"PR_Item");

			DaTm.Dispose();
			DaTm=null;
		}		protected override void Save()
		{
			//this.textBox1.
			//	this.DsMast.AcceptChanges ();
			this.BindMast.EndCurrentEdit ();
			System.Data.OleDb.OleDbDataAdapter DaSave=new System.Data.OleDb.OleDbDataAdapter ();
			DaSave.SelectCommand =new System.Data.OleDb.OleDbCommand("select * from SA" ,((wmMain)this.MdiParent).db);
			System.Data.OleDb.OleDbCommandBuilder  OleDbCommandBuilder1 =new System.Data.OleDb.OleDbCommandBuilder (DaSave);
			//MessageBox.Show (OleDbCommandBuilder1.GetUpdateCommand ().CommandText.ToString ());
			DaSave.RowUpdated += new System.Data.OleDb.OleDbRowUpdatedEventHandler(DaSave_RowUpdated);
			try
			{
				
				DaSave.Update (DsMast,"Mast");
				
			}
			catch(Exception e)
			{
				MessageBox.Show("Current records have error. The transaction will be ignore! Error:"+e.Message.ToString ());
				this.DsMast.RejectChanges();
			}
			DaSave.Dispose ();
			DaSave=null;

		}		private void DaSave_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
		{
			int newID = 0;
			System.Data.OleDb.OleDbCommand idCMD = new System.Data.OleDb.OleDbCommand("SELECT @@IDENTITY",((wmMain)this.MdiParent).db);
			
			if (e.StatementType == System.Data.StatementType.Insert)
			{
				// Retrieve the identity value and store it in the CategoryID column.
				newID = (int)idCMD.ExecuteScalar();
				e.Row["AUTO_NO"] = newID;
				//	MessageBox.Show (newID.ToString ());
			}
			if(e.StatementType!= System.Data.StatementType.Delete)//e.StatementType == System.Data.StatementType.Insert ||e.StatementType == System.Data.StatementType.Update )
			{
				
				idCMD.CommandText="select TOTAL_AMOUNT,PROFIT,Cus_Name,PR_NAME,PR_IT_ID,IT_NAME,PR_CODE from SA010 where AUTO_NO="+e.Row["AUTO_NO"].ToString ();
				System.Data.OleDb.OleDbDataReader dr=idCMD.ExecuteReader();
				if(dr.Read ())
				{
					e.Row["TOTAL_AMOUNT"]=dr.GetValue(0);
					e.Row["PROFIT"]=dr.GetValue(1);
					
					e.Row["Cus_Name"]=dr.GetValue (2);
					e.Row["PR_NAME"]=dr.GetValue (3);
					e.Row["PR_IT_ID"]=dr.GetValue (4);
					e.Row["IT_NAME"]=dr.GetValue (5);
					e.Row["PR_CODE"]=dr.GetValue (6);
					
				}
				dr.Close ();
				dr=null;
				
				
				
			}
			idCMD=null;/**/
		}		protected override void Search()
		{
			new star.SA.SA010SE(this).ShowDialog();
		}

		private void label2_Click(object sender, System.EventArgs e)
		{
		
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			this.Save();
			if(this.BindMast.Count>0 && this.BindMast.Position>=0)
			{
				System.Data.DataRowView drv=(System.Data.DataRowView)this.BindMast.Current ;
				new SA.SA011 (((wmMain)this.MdiParent).db,Convert.ToInt32 (drv[0])).ShowDialog (this);
			}
			else
			{
				MessageBox.Show ("Please choose right purchase orders in left data list.");
			}
			
		//	new PR.PR011 (((wmMain)this.MdiParent).db);
		}

		}}

⌨️ 快捷键说明

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