private void button2_Click(object sender, EventArgs e) { CashMemo cm = new CashMemo(); cm.CustomerName = textBoxCname.Text; cm.CustomerPhone = Convert.ToInt32(textBoxcPhone.Text); cm.Date = DateTime.Today.ToShortDateString(); cm.newentry(); cm.CashMemoNO = cm.returnid(); for (int i = 0; i <= Rowcount - 1; i++) { SoldProductcs sp = new SoldProductcs(); sp.BranchID = LoginForm.BRCHID; sp.ProductId = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value); Branch_Product bp1 = new Branch_Product(); bp1.Productid = sp.ProductId; bp1.BranchId = sp.BranchID; bp1.ptype2(); sp.Pname = bp1.ProductName; sp.ProductSalesUnitPrice = bp1.SalesPrice; sp.Ptype = bp1.ProductType; sp.ProdducExpDate = bp1.ProductExpdate; sp.MfgDate = bp1.ProductMfgdate; sp.Quantity = Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value); bp1.Quantity -= sp.Quantity; bp1.proupdate2(bp1.Quantity); sp.TotalPrice = Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value); sp.CashMemoNo = cm.CashMemoNO; sp.SoldDate = DateTime.Today.ToShortDateString(); sp.newentry(); } }
public void LoadAll() { string sql = "SELECT * FROM CashMemo"; this.dt = DataAccess.GetDataTable(sql); this.count = dt.Rows.Count; this.arr = new CashMemo[this.count]; for (int i = 0; i < this.count; i++) { CashMemo p = new CashMemo(); p.CashMemoNO = (int)dt.Rows[i]["Cashmemo_NO"]; p.CustomerPhone = (int)dt.Rows[i]["Customer_phone"]; p.CustomerName = dt.Rows[i]["Customer_name"].ToString(); p.Date = dt.Rows[i]["Date"].ToString(); this.arr[i] = p; } }