public List <InventoryStockReport> GetTodayReport(DateTime fromdate, DateTime todate) { List <Transaction> aTransactions = new List <Transaction>(); TransactionBLL aTransactionBll = new TransactionBLL(); List <InventoryPurchase> aInventoryPurchases = new List <InventoryPurchase>(); InventoryPurchaseBLL aInventoryPurchaseBll = new InventoryPurchaseBLL(); List <InventoryStockReport> aInventoryStockReports = new List <InventoryStockReport>(); StockBLL aStockBll = new StockBLL(); //DateTime todate = DateTime.Today.AddDays(1); //DateTime fromdate = DateTime.Today; //todate = todate.AddSeconds(-1); aTransactions = aTransactionBll.GetTransactionBetweenDate(fromdate, todate); aInventoryPurchases = aInventoryPurchaseBll.GetInventoryPurchaseBetweenDate(fromdate, todate); aInventoryStockReports = aStockBll.GetAllStockForReport(); foreach (InventoryStockReport report in aInventoryStockReports) { double receive1 = 0, receive2 = 0, damage = 0, send = 0; receive1 = (from purchase in aInventoryPurchases where (purchase.Item.ItemId == report.ItemId) select purchase.Quantity).Sum(); receive2 = (from transaction in aTransactions where (transaction.TransactionType == "Return_from_Kitchen" && transaction.Item.ItemId == report.ItemId) select transaction.Stock.Stocks).Sum(); damage = (from transaction in aTransactions where (transaction.TransactionType == "Damage_in_Stock" && transaction.Item.ItemId == report.ItemId) select transaction.Stock.Stocks).Sum(); send = (from transaction in aTransactions where (transaction.TransactionType == "Send_to_Kitchen" && transaction.Item.ItemId == report.ItemId) select transaction.Stock.Stocks).Sum(); report.ReceivedQty = receive1 + receive2; report.SendQty = send; report.DamageQty = damage; report.Date = DateTime.Today; } return(aInventoryStockReports); }
public List<InventoryStockReport> GetTodayReport(DateTime fromdate,DateTime todate) { List<Transaction> aTransactions = new List<Transaction>(); TransactionBLL aTransactionBll = new TransactionBLL(); List<InventoryPurchase> aInventoryPurchases = new List<InventoryPurchase>(); InventoryPurchaseBLL aInventoryPurchaseBll = new InventoryPurchaseBLL(); List<InventoryStockReport> aInventoryStockReports = new List<InventoryStockReport>(); StockBLL aStockBll = new StockBLL(); //DateTime todate = DateTime.Today.AddDays(1); //DateTime fromdate = DateTime.Today; //todate = todate.AddSeconds(-1); aTransactions = aTransactionBll.GetTransactionBetweenDate(fromdate, todate); aInventoryPurchases = aInventoryPurchaseBll.GetInventoryPurchaseBetweenDate(fromdate, todate); aInventoryStockReports = aStockBll.GetAllStockForReport(); foreach (InventoryStockReport report in aInventoryStockReports) { double receive1 = 0, receive2 = 0, damage = 0, send = 0; receive1 = (from purchase in aInventoryPurchases where (purchase.Item.ItemId == report.ItemId) select purchase.Quantity).Sum(); receive2 = (from transaction in aTransactions where (transaction.TransactionType == "Return_from_Kitchen" && transaction.Item.ItemId == report.ItemId) select transaction.Stock.Stocks).Sum(); damage = (from transaction in aTransactions where (transaction.TransactionType == "Damage_in_Stock" && transaction.Item.ItemId == report.ItemId) select transaction.Stock.Stocks).Sum(); send = (from transaction in aTransactions where (transaction.TransactionType == "Send_to_Kitchen" && transaction.Item.ItemId == report.ItemId) select transaction.Stock.Stocks).Sum(); report.ReceivedQty = receive1 + receive2; report.SendQty = send; report.DamageQty = damage; report.Date = DateTime.Today; } return aInventoryStockReports; }
private void LoadData() { InventoryPurchaseBLL aInventoryPurchaseBll=new InventoryPurchaseBLL(); List<InventoryPurchase> aInventoryPurchases = new List<InventoryPurchase>(); aInventoryPurchases = aInventoryPurchaseBll.GetInventoryPurchaseById(itemId); aInventoryPurchases = aInventoryPurchases.OrderByDescending(a => a.Date).ToList(); DateTime fromdate = DateTime.Now.Date; DateTime todate = DateTime.Now.Date; todate = todate.AddDays(1); fromdate = fromdate.Date; todate = todate.Date; todate = todate.AddSeconds(-1); List<InventoryStockReport> aInventoryStockReports = new List<InventoryStockReport>(); InventoryStockReportBLL aBll = new InventoryStockReportBLL(); aInventoryStockReports = aBll.GetInventoryStockReportBetweenDate(fromdate, todate); InventoryStockReport aInventoryStockReport = aInventoryStockReports.SingleOrDefault(a => a.ItemId == itemId); List<InventoryPurchase> tempInventoryPurchases = new List<InventoryPurchase>(); double sum = 0; foreach (InventoryPurchase inventoryPurchase in aInventoryPurchases) { sum += inventoryPurchase.Quantity; if(sum >= aInventoryStockReport.BalanceQty) { double qty = sum - aInventoryStockReport.BalanceQty; inventoryPurchase.Quantity -= qty; tempInventoryPurchases.Add(inventoryPurchase); break; } else tempInventoryPurchases.Add(inventoryPurchase); } var item = tempInventoryPurchases.Select(a => new { ItemName = a.Item.ItemName, Qty = a.Quantity, ExpireDate = a.ExpireDate, PurchaseDate = a.Date }).ToList(); itemShowDataGridView.DataSource = item; }
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 "); } }
private void showButton_Click(object sender, EventArgs e) { DateTime fromdate = fromdateTimePicker.Value; DateTime todate = todateTimePicker.Value; todate = todate.AddDays(1); fromdate = fromdate.Date; todate = todate.Date; List<InventoryPurchase> aInventoryPurchases=new List<InventoryPurchase>(); InventoryPurchaseBLL aInventoryPurchaseBll=new InventoryPurchaseBLL(); aInventoryPurchases = aInventoryPurchaseBll.GetInventoryPurchaseBetweenDate(fromdate, todate); // inventoryPurchaseDataGridView.DataSource = aInventoryPurchases; ShowReport(aInventoryPurchases); }
private void printPurchaseReportbutton_Click(object sender, EventArgs e) { InventoryPurchaseBLL aInventoryPurchaseBll = new InventoryPurchaseBLL(); List<InventoryReport> aReports = new List<InventoryReport>(); aReports = (List<InventoryReport>)inventoryPurchaseDataGridView.DataSource; if (aReports == null) { MessageBox.Show("No data Available Into GridView"); return; } int printlenght = aReports.Count; PrintDocument doc = new TextDocument(aInventoryPurchaseBll.PrintPurchaseReport(aReports), printlenght); printReportLogoType = 1; doc.PrintPage += this.Doc_PrintPage; doc.DefaultPageSettings.Landscape = true; PrintDialog dlgSettings = new PrintDialog(); dlgSettings.Document = doc; dlgSettings.UseEXDialog = true; if (dlgSettings.ShowDialog() == DialogResult.OK) { doc.Print(); } }