public string InsertKitchenStock(Stock aStock) { Stock stock = new Stock(); StockDAO aDao = new StockDAO(); string sr = aDao.InsertKitchenStock(aStock); return sr; }
public void InsertStockOrUpdate(Stock aStock) { Stock stock=new Stock(); StockDAO aDao=new StockDAO(); stock = aDao.GetStockByItemid(aStock.Item.ItemId); if(stock.StockId==0) { aDao.InsertStock(aStock); } else if(stock.StockId>0) { double pricePrevious = stock.Stocks*stock.UnitPrice; double priceNow = aStock.Stocks * aStock.UnitPrice; double totalStocks = stock.Stocks + aStock.Stocks; double totalPrice = priceNow + pricePrevious; stock.Stocks = totalStocks; if (totalStocks != 0 && totalPrice != 0) { aStock.UnitPrice = totalPrice / totalStocks; } else aStock.UnitPrice = 0; stock.StockId = stock.StockId; aDao.UpdateStock(stock); } }
public Stock GetStockByItemid(int itemId) { Stock stock = new Stock(); StockDAO aDao = new StockDAO(); stock = aDao.GetStockByItemid(itemId); return stock; }
public Stock GetStockByItemidFrominventory_kitchen_stock(InventoryItem item) { Stock stock = new Stock(); StockDAO aDao = new StockDAO(); stock = aDao.GetStockByItemidFrominventory_kitchen_stock(item.ItemId); return stock; }
public Stock GetStockByCategoryAndItem(Stock aStock) { Stock stock=new Stock(); try { this.OpenConnection(); string sqlComm = String.Format(SqlQueries.GetQuery(Query.GetStockByCategoryAndItem), aStock.Category.CategoryId, aStock.Item.ItemId); IDataReader oReader = this.ExecuteReader(sqlComm); if (oReader != null) { while (oReader.Read()) { stock = ReaderToStock(oReader); } } else stock.StockId = 0; } catch(Exception ex) { MessageBox.Show("Ooops " + ex); } finally { this.CloseConnection(); } return stock; }
public string UpdateKitchenStock(Stock aStock) { StockDAO aDao = new StockDAO(); string sr = aDao.UpdateKitchenStock(aStock); return sr; }
public string SendToKitchen(Transaction aTransaction) { string sr = string.Empty; TransactionDAO aDao=new TransactionDAO(); Stock aStock=new Stock(); StockBLL aBll=new StockBLL(); aStock = aBll.GetStockByItemidFrominventory_kitchen_stock(aTransaction.Item); if(aStock.StockId==0) { aStock = aTransaction.Stock; aStock.Category = aTransaction.Category; aStock.Item = aTransaction.Item; sr = aBll.InsertKitchenStock(aStock); } else if (aStock.StockId > 0) { Stock stock=new Stock(); stock = aTransaction.Stock; double pricePrevious = stock.Stocks * stock.UnitPrice; double priceNow = aStock.Stocks * aStock.UnitPrice; double totalStocks = stock.Stocks + aStock.Stocks; double totalPrice = priceNow + pricePrevious; aStock.Stocks = totalStocks; if (totalStocks != 0 && totalPrice != 0) { aStock.UnitPrice = totalPrice / totalStocks; } else aStock.UnitPrice = 0; // aStock.StockId = stock.StockId; sr=aBll.UpdateKitchenStock(aStock); } if (sr == "Insert Sucessfully") { aDao.InsertTransactionForReport(aTransaction); } if (sr == "Insert Sucessfully") { Stock aaStock=new Stock(); aaStock = aTransaction.Stock; aaStock.Stocks *= -1; aBll.UpdateStockByStockId(aaStock); } return sr; }
private Transaction ReaderToReadInventoryTransaction(IDataReader aReader) { Transaction aTransaction=new Transaction(); InventoryCategory aCategory = new InventoryCategory(); InventoryItem aItem = new InventoryItem(); Unit aUnit = new Unit(); CUserInfo aCUserInfo = new CUserInfo(); Stock aStock = new Stock(); try { aTransaction.TransactionId = Convert.ToInt32(aReader["transaction_id"]); } catch { } try { aTransaction.TransactionType = (aReader["transaction_type"]).ToString(); } catch { } try { aTransaction.TransactionDate = Convert.ToDateTime((aReader["date"])); } catch { } try { aTransaction.TransactionAmount = Convert.ToDouble(aReader["total_price"]); } catch { } try { aTransaction.DamageReport = (aReader["damage_report"]).ToString(); } catch { } try { aCategory.CategoryId = Convert.ToInt32(aReader["category_id"]); } catch { } try { aCategory.CategoryName = aReader["category_name"].ToString(); } catch { } try { aItem.ItemId = Convert.ToInt32(aReader["item_id"]); } catch { } try { aItem.ItemName = (aReader["item_name"]).ToString(); } catch { } try { aUnit.UnitName = (aReader["unit"]).ToString(); } catch { } try { aCUserInfo.UserName = ((aReader["user_name"])).ToString(); } catch { } try { aCUserInfo.UserName = ((aReader["user_name"])).ToString(); } catch { } try { aStock.Stocks = Convert.ToDouble(aReader["quantity"]); } catch { } try { aStock.UnitPrice = Convert.ToDouble(aReader["unit_price"]); } catch { } aTransaction.Category = aCategory; aTransaction.Item = aItem; aTransaction.Unit = aUnit; aTransaction.UserInfo = aCUserInfo; aTransaction.Stock = aStock; return aTransaction; }
private void transactionTypecomboBox_SelectedIndexChanged(object sender, EventArgs e) { try { InventoryItem aItem = new InventoryItem(); string transactiontype = transactionTypecomboBox.SelectedItem.ToString(); if (transactiontype == "Send_to_Kitchen"||transactiontype == "Damage_in_Stock") { if (transactiontype == "Damage_in_Stock") { ShowDamageField(); } else if (transactiontype == "Send_to_Kitchen") { HideDamageField(); } aItem = (InventoryItem)itemNamecomboBox.SelectedItem; Stock aStock = new Stock(); StockBLL aStockBll = new StockBLL(); aStock = aStockBll.GetStockByItemid(aItem.ItemId); stocklabel.Visible = true; stocklabel.Text = "Now Current Stocks are " + aStock.Stocks + " " + unittypelabel.Text; } if (transactiontype == "Return_from_Kitchen" || transactiontype == "Damage_in_kitchen" || transactiontype == "Stock In" || transactiontype == "Stock_Out_In_Kitchen") { if (transactiontype == "Damage_in_kitchen" || transactiontype == "Stock_Out_In_Kitchen") { ShowDamageField(); } else if (transactiontype == "Return_from_Kitchen") { HideDamageField(); } else if (transactiontype == "Stock In") { HideDamageField(); } aItem = (InventoryItem)itemNamecomboBox.SelectedItem; Stock aStock = new Stock(); StockBLL aStockBll = new StockBLL(); aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem); stocklabel.Visible = true; stocklabel.Text = "Now Current Kitchen Stocks are " + aStock.Stocks + " " + unittypelabel.Text; } } catch (Exception) { } }
private Stock ReaderToStock(IDataReader oReader) { Stock aStock=new Stock(); try { aStock.StockId = Convert.ToInt32(oReader["stock_id"]); } catch { } try { aStock.Stocks = Convert.ToDouble(oReader["stock"]); } catch { } try { aStock.UnitPrice = Convert.ToDouble(oReader["unit_price"]); } catch { } return aStock; }
public string UpdateStockByStockId(Stock stock) { string sr = string.Empty; try { this.OpenConnection(); string sqlcomm = String.Format(SqlQueries.GetQuery(Query.UpdateStockByStockId), stock.Stocks,stock.StockId); this.ExecuteNonQuery(sqlcomm); sr = "Update Sucessfully"; } catch (Exception ex) { MessageBox.Show("ohh No " + ex); } finally { this.CloseConnection(); } return sr; }
public void UpdateStock(Stock aStock) { try { this.OpenConnection(); string sqlcomm = String.Format(SqlQueries.GetQuery(Query.UpdateStocks), aStock.Stocks, aStock.UnitPrice,aStock.StockId); this.ExecuteNonQuery(sqlcomm); } catch (Exception ex) { MessageBox.Show("ohh No " + ex); } finally { this.CloseConnection(); } }
public void InsertStock(Stock aStock) { try { this.OpenConnection(); string sqlcomm = String.Format(SqlQueries.GetQuery(Query.InsertStock), aStock.Category.CategoryId, aStock.Category.CategoryName,aStock.Item.ItemId,aStock.Item.ItemName, aStock.Stocks,aStock.Unit.UnitName,aStock.UnitPrice); this.ExecuteNonQuery(sqlcomm); } catch (Exception ex) { MessageBox.Show("ohh No " + ex); } finally { this.CloseConnection(); } }
public string InsertKitchenStock(Stock aStock) { string sr = string.Empty; try { this.OpenConnection(); string sqlcomm = String.Format(SqlQueries.GetQuery(Query.InsertKitchenStock), aStock.Category.CategoryId, aStock.Category.CategoryName, aStock.Item.ItemId, aStock.Item.ItemName, aStock.Stocks, aStock.Item.UnitName, aStock.UnitPrice); this.ExecuteNonQuery(sqlcomm); sr = "Insert Sucessfully"; } catch (Exception ex) { MessageBox.Show("ohh No " + ex); } finally { this.CloseConnection(); } return sr; }
public Stock GetStockByItemidFrominventory_kitchen_stock(int itemId) { Stock stock = new Stock(); try { this.OpenConnection(); string sqlComm = String.Format(SqlQueries.GetQuery(Query.GetStockByItemidFrominventory_kitchen_stock), itemId); IDataReader oReader = this.ExecuteReader(sqlComm); if (oReader != null) { while (oReader.Read()) { stock = ReaderToKitchenStock(oReader); } } else stock.StockId = 0; } catch (Exception ex) { MessageBox.Show("Ooops " + ex); } finally { this.CloseConnection(); } return stock; }
public void UpdateKitchenStockByStockId(Stock cStock) { StockDAO aDao = new StockDAO(); aDao.UpdateKitchenStockByStockId(cStock); }
public void UpdateKitchenStockForDamage(Stock aStock) { Stock stock = new Stock(); StockDAO aDao = new StockDAO(); stock = aDao.GetStockByItemidFrominventory_kitchen_stock(aStock.Item.ItemId); if (stock.StockId == 0) { aDao.InsertStock(aStock); } else if (stock.StockId > 0) { double pricePrevious = stock.Stocks * stock.UnitPrice; //double priceNow = aStock.Stocks * aStock.UnitPrice; double totalStocks = stock.Stocks - aStock.Stocks; // double totalPrice = priceNow + pricePrevious; stock.Stocks = totalStocks; if (pricePrevious != 0 && totalStocks != 0) { stock.UnitPrice = pricePrevious / totalStocks; } else stock.UnitPrice = 0; stock.StockId = stock.StockId; aDao.UpdateKitchenStock(stock); } }
public void UpdateKitchenStockForSendOut(Stock aStock) { Stock stock = new Stock(); StockDAO aDao = new StockDAO(); stock = aDao.GetStockByItemidFrominventory_kitchen_stock(aStock.Item.ItemId); if (stock.StockId == 0) { aDao.InsertStock(aStock); } else if (stock.StockId > 0) { double totalStocks = stock.Stocks - aStock.Stocks; // double totalPrice = priceNow + pricePrevious; stock.Stocks = totalStocks; stock.StockId = stock.StockId; aDao.UpdateKitchenStock(stock); } }
private void TransactionWhenProfessionalPackageIsActive() { InventoryItem aItem = new InventoryItem(); aItem = (InventoryItem)itemNamecomboBox.SelectedItem; InventoryCategory aInventoryCategory = new InventoryCategory(); aInventoryCategory = (InventoryCategory)categoryNamecomboBox.SelectedItem; Stock aStock = new Stock(); StockBLL aStockBll = new StockBLL(); string transactiontype = transactionTypecomboBox.SelectedItem.ToString(); Transaction aTransaction = new Transaction(); aTransaction.TransactionDate = DateTime.Now; aTransaction.Item = aItem; aTransaction.Category = aInventoryCategory; aTransaction.TransactionType = transactiontype; CUserInfo aUserInfo = new CUserInfo(); aUserInfo.UserName = RMSGlobal.LogInUserName; aTransaction.UserInfo = aUserInfo; string sr = string.Empty; if (transactiontype == "Damage_in_Stock") { if (danmagetextBox.Text.Length > 0) { aStock = aStockBll.GetStockByItemid(aItem.ItemId); if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0)) { aStock.Stocks = Convert.ToDouble(quantitytextBox.Text); aStock.Item = aItem; aStock.Category = aInventoryCategory; aTransaction.Stock = aStock; aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''"); TransactionBLL aBll = new TransactionBLL(); sr = aBll.DamageInStock(aTransaction); ShowAndClear(sr); } else MessageBox.Show("Your Quantity Must be Greater than 0 and less than or equal to " + aStock.Stocks + " " + unittypelabel.Text); } else MessageBox.Show("Please Check Your Damage Report Field It's Never Empty"); } if (transactiontype == "Send_to_Kitchen") { aStock = aStockBll.GetStockByItemid(aItem.ItemId); if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0)) { aStock.Stocks = Convert.ToDouble(quantitytextBox.Text); aStock.Item = aItem; aStock.Category = aInventoryCategory; aTransaction.Stock = aStock; TransactionBLL aBll = new TransactionBLL(); sr = aBll.SendToKitchen(aTransaction); ShowAndClear(sr); } else MessageBox.Show("Your Quantity Must be Greater than 0 and less than or equal to " + aStock.Stocks + " " + unittypelabel.Text); } //aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem); if (transactiontype == "Return_from_Kitchen") { aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem); if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0)) { aStock.Stocks = Convert.ToDouble(quantitytextBox.Text); aStock.Item = aItem; aStock.Category = aInventoryCategory; aTransaction.Stock = aStock; TransactionBLL aBll = new TransactionBLL(); sr = aBll.ReturnFromKitchen(aTransaction); ShowAndClear(sr); } else MessageBox.Show("Your Quantity Must be Greater than 0 and less than or equal to " + aStock.Stocks + " " + unittypelabel.Text); } if (transactiontype == "Damage_in_kitchen") { if (danmagetextBox.Text.Length > 0) { aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem); if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0)) { aStock.Stocks = Convert.ToDouble(quantitytextBox.Text); aStock.Item = aItem; aStock.Category = aInventoryCategory; aTransaction.Stock = aStock; aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''"); TransactionBLL aBll = new TransactionBLL(); sr = aBll.DamageInKitchen(aTransaction); ShowAndClear(sr); } else MessageBox.Show("Your Quantity Must be Greater than 0 and less than or equal to " + aStock.Stocks + " " + unittypelabel.Text); } else MessageBox.Show("Please Check Your Damage Report Field It's Never Empty"); } if (transactiontype == "Stock_Out_In_Kitchen") { if (danmagetextBox.Text.Length > 0) { aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem); if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0)) { aStock.Stocks = Convert.ToDouble(quantitytextBox.Text); aStock.Item = aItem; aStock.Category = aInventoryCategory; aTransaction.Stock = aStock; aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''"); TransactionBLL aBll = new TransactionBLL(); sr = aBll.SendOutInKitchen(aTransaction); StockDAO aStockDao=new StockDAO(); aStockDao.InsertOrUpdateSaleRawmaterialsReport(aTransaction.Item.ItemId, Convert.ToDouble(quantitytextBox.Text),aStock.UnitPrice); ShowAndClear(sr); } else MessageBox.Show("Your Quantity Must be Greater than 0 and less than or equal to " + aStock.Stocks + " " + unittypelabel.Text); } else MessageBox.Show("Please Check Your Damage Report Field It's Never Empty"); } }
public string UpdateStockByStockId(Stock stock) { StockDAO aDao = new StockDAO(); string sr = aDao.UpdateStockByStockId(stock); return sr; }
private void savePurchasebutton_Click(object sender, EventArgs e) { try { if (expiredateTimePicker.Value.Date == DateTime.Now.Date) { DialogResult result = MessageBox.Show("Do you want to Empty Expire Date?", "Confirmation", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { } else if (result == DialogResult.No) { return; } } if (pricetextBox.Text.Length != 0 && paidPricetextBox.Text.Length != 0 && quantitytextBox.Text.Length != 0) { InventoryPurchase aInventoryPurchase = new InventoryPurchase(); InventoryCategory aCategory = new InventoryCategory(); InventoryItem aItem = new InventoryItem(); Supplier aSupplier = new Supplier(); Supplier aaSupplier = new Supplier(); Unit aUnit = new Unit(); //Add for purchase record aCategory = (InventoryCategory) categoryNamecomboBox.Items[categoryNamecomboBox.SelectedIndex]; SupplierBLL aSupplierBll = new SupplierBLL(); aSupplier = aSupplierBll.GetSupplierByid(Convert.ToInt32(supplierNamecomboBox.SelectedValue)); // aSupplier = (Supplier) supplierNamecomboBox.Items[supplierNamecomboBox.SelectedIndex]; if (aSupplier.PaidAmount > aSupplier.TotalAmount) { aSupplier.AdvanceAmount = aSupplier.PaidAmount - aSupplier.TotalAmount; } else aSupplier.DueAmount = aSupplier.TotalAmount - aSupplier.PaidAmount; aItem = (InventoryItem) itemNamecomboBox.Items[itemNamecomboBox.SelectedIndex]; aInventoryPurchase.Quantity = Convert.ToDouble(quantitytextBox.Text); aInventoryPurchase.Price = Convert.ToDouble(pricetextBox.Text); aInventoryPurchase.Date = DateTime.Now; aInventoryPurchase.Category = aCategory; aInventoryPurchase.Item = aItem; aaSupplier.PaidAmount = Convert.ToDouble(paidPricetextBox.Text); aInventoryPurchase.Supplier = aaSupplier; if (((aSupplier.DueAmount + Convert.ToDouble(pricetextBox.Text) - (Convert.ToDouble(paidPricetextBox.Text) + aSupplier.AdvanceAmount))) >= 0) aInventoryPurchase.Supplier.DueAmount = aSupplier.DueAmount + Convert.ToDouble(pricetextBox.Text) - (Convert.ToDouble(paidPricetextBox.Text) + aSupplier.AdvanceAmount); else aInventoryPurchase.Supplier.DueAmount = 0.0; if (((Convert.ToDouble(paidPricetextBox.Text) + aSupplier.AdvanceAmount) - (aSupplier.DueAmount + Convert.ToDouble(pricetextBox.Text))) >= 0) { aInventoryPurchase.Supplier.AdvanceAmount = (Convert.ToDouble(paidPricetextBox.Text) + aSupplier.AdvanceAmount) - (aSupplier.DueAmount + Convert.ToDouble(pricetextBox.Text)); } else aInventoryPurchase.Supplier.AdvanceAmount = 0.0; aInventoryPurchase.Supplier.Name = aSupplier.Name; aInventoryPurchase.Supplier.SupplierId = aSupplier.SupplierId; aUnit.UnitName = unittypelabel.Text; aInventoryPurchase.Unit = aUnit; CUserInfo aUserInfo= new CUserInfo(); aUserInfo.UserName= RMSGlobal.LogInUserName; aInventoryPurchase.PaymentType= paymentTypecomboBox.SelectedItem.ToString(); aInventoryPurchase.CUserInfo= aUserInfo; if (expiredateTimePicker.Value.Date == DateTime.Now.Date) { } else { aInventoryPurchase.ExpireDate = expiredateTimePicker.Value.Date; } string res = string.Empty; InventoryPurchaseBLL aInventoryPurchaseBll = new InventoryPurchaseBLL(); res = aInventoryPurchaseBll.InsertPurchase(aInventoryPurchase); if(res=="Purchase Insert Sucessfully") { //Add for Supplier Update aSupplier.TotalAmount += Convert.ToDouble(pricetextBox.Text); aSupplier.PaidAmount += Convert.ToDouble(paidPricetextBox.Text); aSupplierBll.UpdateSupplierForPurchase(aSupplier); //Add for Supplier payment report Supplier paymentSupplier=new Supplier(); paymentSupplier.PaidAmount = Convert.ToDouble(paidPricetextBox.Text); paymentSupplier.TotalAmount = Convert.ToDouble(pricetextBox.Text); paymentSupplier.SupplierId = aSupplier.SupplierId; paymentSupplier.PaymentType = paymentTypecomboBox.SelectedItem.ToString(); aSupplierBll.InsertIntosupplier_payment_reportForSupplierPaymentTrack(paymentSupplier); //Add for stock update Stock aStock=new Stock(); aStock.Category = aCategory; aStock.Item = aItem; aStock.Unit = aUnit; aStock.Stocks = Convert.ToDouble(quantitytextBox.Text); aStock.UnitPrice = Convert.ToDouble(pricetextBox.Text)/aStock.Stocks; StockBLL aStockBll=new StockBLL(); aStockBll.InsertStockOrUpdate(aStock); purchaseActionlabel.Visible = true; purchaseActionlabel.Text = res; Clear(); }else { purchaseActionlabel.Visible = true; purchaseActionlabel.Text = res; } }else { purchaseActionlabel.Visible = true; purchaseActionlabel.Text = "Please Check Your Input"; } } catch { MessageBox.Show("Try Again May Be Your Given Input Format Not Correct Please Given Again "); } }
public string ReturnFromKitchen(Transaction aTransaction) { string sr=""; try { TransactionDAO aDao = new TransactionDAO(); aDao.InsertTransactionForReport(aTransaction); StockBLL aBll = new StockBLL(); Stock dStock=new Stock(); dStock = aTransaction.Stock; aBll.InsertStockOrUpdate(dStock); Stock cStock = new Stock(); cStock = aTransaction.Stock; cStock.Stocks *= -1; aBll.UpdateKitchenStockByStockId(cStock); sr = "Insert Successfully"; } catch { sr = "Plz Try again"; } return sr; }