public void ProductTempSale() { _globalBillNo = GetBillNumber(); for (int i = 0; i < dataGridViewSale.RowCount - 1; i++) { int _prodID = Convert.ToInt32(dataGridViewSale.Rows[i].Cells[0].Value); string _prodDescription = Convert.ToString(dataGridViewSale.Rows[i].Cells["Description"].Value); decimal _saleQty, _unitPrice, _totalPrice; var database = new InventoryEntities(); var txnTypelist = (from c in database.TransactionTypes where c.TransactionTypeName == "Sell" select new { c.TransactionTypeID }).FirstOrDefault(); int _txnType = txnTypelist.TransactionTypeID; _saleQty = Convert.ToDecimal(dataGridViewSale.Rows[i].Cells["Quantity"].Value); _unitPrice = Convert.ToDecimal(dataGridViewSale.Rows[i].Cells["SalesPrice"].Value); _totalPrice = _unitPrice * _saleQty; var tempBill = new TempBill(); tempBill.BillNumber = _globalBillNo; tempBill.ProductID = _prodID; tempBill.ProductDesc = _prodDescription; tempBill.Quantity = _saleQty; tempBill.UnitPrice = _unitPrice; tempBill.TotalPrice = _totalPrice; database.TempBills.Add(tempBill); database.SaveChanges(); } }
public List <TempBill> GetListTempBillByTableID(int tableID) { DataTable table; try { table = TempBillDAO.Instance.GetListTempBillByTableID(tableID); } catch (Exception ex) { throw ex; } List <TempBill> lstTempBill = new List <TempBill>(); foreach (DataRow row in table.Rows) { TempBill tmp = new TempBill(row); lstTempBill.Add(tmp); } return(lstTempBill); }