Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public string DamageInStock(Transaction aTransaction)
        {
            string sr = string.Empty;

            try
            {
                TransactionDAO aDao = new TransactionDAO();
                aDao.InsertTransactionForReport(aTransaction);
                StockBLL aStockBll = new StockBLL();
                aStockBll.UpdateStockForDamage(aTransaction.Stock);
                sr = "Save Successfully";
            }
            catch
            {
                sr = "Please Try Again";
            }
            return(sr);
        }
Пример #4
0
        public string DamageInStock(Transaction aTransaction)
        {
            string sr = string.Empty;
            try
            {
               TransactionDAO aDao=new TransactionDAO();
               aDao.InsertTransactionForReport(aTransaction);
               StockBLL aStockBll = new StockBLL();
                aStockBll.UpdateStockForDamage(aTransaction.Stock);
                sr = "Save Successfully";
            }
            catch
            {
                sr = "Please Try Again";

            }
            return sr;
        }
Пример #5
0
        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);
        }
Пример #6
0
        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;
        }
Пример #7
0
        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 ");

            }
        }
Пример #8
0
        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");
            }
        }
Пример #9
0
        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)
            {
            }
        }
Пример #10
0
        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;
        }
Пример #11
0
        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;
        }