Exemplo n.º 1
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");
            }
        }
Exemplo n.º 2
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)
            {
            }
        }