Пример #1
0
        private bool CheckRawProduct(List<COrderDetails> tempOrderDetailsList)
        {
            CCategory3DAO cCategory3Dao = new CCategory3DAO();
            FinishedRawProductListDAO finishedRawProductListDao = new FinishedRawProductListDAO();

            string stockMessage = "Stock is unavailable ";
            bool isStockAvailable = true;
            KitchenStockDAO aKitchenStockDao = new KitchenStockDAO();

            foreach (COrderDetails orderDetail in tempOrderDetailsList)
            {
                List<CFinishedRawProductList> finishedRawProductList = finishedRawProductListDao.GetFinishedRawProductListByProductID(Convert.ToInt32(orderDetail.ProductID));

                foreach (CFinishedRawProductList finishedRawProduct in finishedRawProductList)
                {

                    // CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(finishedRawProduct.RawProductID));
                    KitchenStock aKitchenStock = new KitchenStock();
                    //  KitchenStockDAO aKitchenStockDao=new KitchenStockDAO();
                    aKitchenStock = aKitchenStockDao.GetStockByItemidFrominventory_kitchen_stock((int)finishedRawProduct.RawProductID);

                    //List<CCategory3> aList = cCategory3Dao.GetAllCategory3();
                    //var temp = from acategory in aList where acategory.Category2ID == cCategory3.Category2ID select acategory;

                    if (finishedRawProduct.Qnty * (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) > aKitchenStock.Stocks)
                    {
                        stockMessage += "\n   " + finishedRawProduct.RawProductName + ": Needed: " + finishedRawProduct.Qnty *
                            (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) + "\n " + " But Have: " + (aKitchenStock.Stocks);
                        isStockAvailable = false;
                    }
                }

            }

            if(!isStockAvailable)
            {
                CUserInfoDAO aUserInfoDao=new CUserInfoDAO();
                CUserInfo aUserInfo=new CUserInfo();
                aUserInfo = aUserInfoDao.GetUserInfoByUsername(RMSGlobal.LoginUserName);
                if (aUserInfo.Type == 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Do You Proceed", "Stock Alert", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        isStockAvailable = true;
                    }
                    else if (dialogResult == DialogResult.No)
                    {

                    }
                }

            }

            if (!isStockAvailable)
            {
                CMessageBox cMessageBox = new CMessageBox("Raw Product", stockMessage);
                cMessageBox.ShowDialog();
                return false;
            }
            else
            {
                foreach (COrderDetails orderDetails in tempOrderDetailsList)
                {
                    List<CFinishedRawProductList> finishedRawProductList =
                        finishedRawProductListDao.GetFinishedRawProductListByProductID(
                            Convert.ToInt32(orderDetails.ProductID));

                    foreach (CFinishedRawProductList finishedRawProduct in finishedRawProductList)
                    {
                        aKitchenStockDao.UpdateStock(Convert.ToInt32(finishedRawProduct.RawProductID),
                                                  finishedRawProduct.Qnty * (orderDetails.OrderQuantity - orderDetails.KitchenQuantity));

                    }
                    COrderDetailsDAO cOrderDetailsDao = new COrderDetailsDAO();
                    cOrderDetailsDao.UpdateKitchenQuantity(orderDetails);
                }
            }

            return true;
        }
Пример #2
0
        private bool CheckStockControl()
        {
            CCategory3DAO cCategory3Dao = new CCategory3DAO();

            COrderManager tempOrderManager = new COrderManager();
            List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>();

            CResult oResult = tempOrderManager.OrderDetailsByOrderID(orderID);

            if (oResult.IsSuccess && oResult.Data != null)
                tempOrderDetailsList = (List<COrderDetails>)oResult.Data;

            string stockMessage = "Stock is unavailable ";
            bool isStockAvailable = true;

            foreach (COrderDetails orderDetail in tempOrderDetailsList)
            {
                CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(orderDetail.ProductID));

                if ((orderDetail.OrderQuantity - orderDetail.KitchenQuantity) > cCategory3.MUnitsInStock && cCategory3.MNonStockable)
                {
                    //stockMessage += "\n   " + orderDetail.Product_Name + "  " + (orderDetail.OrderQuantity - cCategory3.MUnitsInStock);
                    stockMessage += "\n   " + cCategory3.Category3Name + ": Needed: " + (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) + " But Have " + (cCategory3.MUnitsInStock);
                    isStockAvailable = false;
                }

            }

            if (!isStockAvailable)
            {
                CUserInfoDAO aUserInfoDao = new CUserInfoDAO();
                CUserInfo aUserInfo = new CUserInfo();
                aUserInfo = aUserInfoDao.GetUserInfoByUsername(RMSGlobal.LoginUserName);
                if (aUserInfo.Type == 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Do You Proceed", "Stock Alert", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        isStockAvailable = true;
                    }
                    else if (dialogResult == DialogResult.No)
                    {

                    }
                }

            }

            if (!isStockAvailable || !CheckRawProduct(tempOrderDetailsList))
            {
                CMessageBox cMessageBox = new CMessageBox("Finished Product", stockMessage);
                cMessageBox.ShowDialog();
                //MessageBox.Show(stockMessage);
                return false;
            }
            else
            {
                foreach (COrderDetails orderDetails in tempOrderDetailsList)
                {
                    CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(orderDetails.ProductID));
                    if (!cCategory3.MNonStockable)
                    {
                        cCategory3Dao.UpdateStock(Convert.ToInt32(orderDetails.ProductID), orderDetails.OrderQuantity - orderDetails.KitchenQuantity);
                        COrderDetailsDAO cOrderDetailsDao = new COrderDetailsDAO();
                        cOrderDetailsDao.UpdateKitchenQuantity(orderDetails);
                    }
                }
            }

            //   parrentForm.scre

            return true;
        }
Пример #3
0
        public CResult VoidPrintedItems(System.Collections.SortedList slPrintedList, long orderID)
        {
            DataSet tempStockDataSet = new DataSet();
            tempStockDataSet.ReadXml("Config/StockSetting.xml");

            bool isAllowedToOrder = Convert.ToBoolean(tempStockDataSet.Tables[0].Rows[0]["AllowedtoOrder"].ToString());

            CResult oResult = new CResult();
            string sqlCommand = "";

            try
            {
                this.OpenConnection();

                foreach (COrderDetails objDetails in slPrintedList.Values)
                {
                    COrderDetails aDetails = new COrderDetails();
                    aDetails = GetAll(objDetails); // Add for Vat and Cost find out
                    if (objDetails.OrderQuantity > 0) //If item is rest.
                    {

                        sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateLocalVoidItems),
                                                   aDetails.OrderQuantity, aDetails.PrintedQuantity,
                                                   aDetails.OrderDetailsID, aDetails.OrderAmount,
                                                   aDetails.Amount_with_vat, aDetails.VatTotal);

                    }
                    else
                    {
                        sqlCommand = string.Format(SqlQueries.GetQuery(Query.OrderDetailsDelete),
                                                   objDetails.OrderDetailsID);
                    }
                    this.ExecuteNonQuery(sqlCommand);

                    //Add for raw materials update
                    if (!isAllowedToOrder)
                    {
                        if (objDetails.KitchenQuantity - objDetails.OrderQuantity >= 0)
                        {
                            double quantity = objDetails.KitchenQuantity - objDetails.OrderQuantity;
                            //if (objDetails.OrderQuantity == 0)
                            //{
                            //    quantity = 1;
                            //}
                            COrderDetailsDAO cOrderDetailsDao = new COrderDetailsDAO();
                            cOrderDetailsDao.UpdateKitchenQuantity(aDetails);
                            FinishedRawProductListDAO aDao = new FinishedRawProductListDAO();
                            List<CFinishedRawProductList> aList =
                                aDao.GetFinishedRawProductListByProductID(objDetails.ProductID);
                            foreach (CFinishedRawProductList list in aList)
                            {
                                string command = string.Format(SqlQueries.GetQuery(Query.UpdateRawMaterialsByRawProductID),
                                                               list.RawProductID, (list.Qnty * quantity));
                                this.ExecuteNonQuery(command);
                            }
                        }
                    }

                }
                oResult.IsSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in VoidPrintedItems()", LogLevel.Error, "Database");
                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }