Exemple #1
0
        public KitchenStock GetStockByItemidFrominventory_kitchen_stock(int itemId)
        {
            KitchenStock stock = new KitchenStock();
               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)
               {
               throw new Exception("GetStockByItemidFrominventory_kitchen_stock()",ex);
               }
               finally
               {
               this.CloseConnection();
               }
               return stock;
        }
Exemple #2
0
        private KitchenStock ReaderToKitchenStock(IDataReader oReader)
        {
            KitchenStock aStock=new KitchenStock();
               try
               {
               aStock.KitchenStockId = Convert.ToInt32(oReader["kitchen_stock_id"]);
               }
               catch
               {
               }

               try
               {
               aStock.ItemId = Convert.ToInt32(oReader["item_id"]);
               }
               catch
               {
               }

               try
               {
               aStock.Stocks = Convert.ToDouble(oReader["stock"]);
               }
               catch
               {
               }
               try
               {
               aStock.ItemName = (oReader["item_name"]).ToString();
               }
               catch
               {
               }
               //unit_price
               try
               {
               aStock.UnitPrice = Convert.ToDouble(oReader["unit_price"]);
               }
               catch
               {
               }

               return aStock;
        }
Exemple #3
0
        public void InsertOrUpdateSaleRawmaterialsReport(IEnumerable<COrderDetails> check)
        {
            FinishedRawProductListDAO finishedRawProductListDao = new FinishedRawProductListDAO();
             KitchenStockDAO aKitchenStockDao=new KitchenStockDAO();

            try
            {
                this.OpenConnection();
                foreach (COrderDetails cOrderDetailse in check)
                {
                    List<CFinishedRawProductList> finishedRawProductList =
                        finishedRawProductListDao.GetFinishedRawProductListByProductID(
                            Convert.ToInt32(cOrderDetailse.ProductID));
                    //aKitchenStockDao.UpdateStock(Convert.ToInt32(finishedRawProduct.RawProductID),
                    //   finishedRawProduct.Qnty * (orderDetails.OrderQuantity - orderDetails.KitchenQuantity));

                    foreach (CFinishedRawProductList finishedRawProduct in finishedRawProductList)
                    {
                        int flag = 0;
                          KitchenStock aKitchenStock=new KitchenStock();
                          aKitchenStock = aKitchenStockDao.GetStockByItemidFrominventory_kitchen_stock((int)finishedRawProduct.RawProductID);
                        string sqlComm = String.Format(SqlQueries.GetQuery(Query.ExitOrNot), aKitchenStock.ItemId,
                                                       DateTime.Now.Date);
                        IDataReader aReader = this.ExecuteReader(sqlComm);
                        if(aReader!=null)
                        {
                            while(aReader.Read())
                            {
                                flag = Convert.ToInt32(aReader["sale_id"]);
                            }
                            aReader.Close();
                        }
                        if(flag==0)
                        {
                             sqlComm = String.Format(SqlQueries.GetQuery(Query.InsertSalereport), aKitchenStock.ItemId,
                                    cOrderDetailse.OrderQuantity*finishedRawProduct.Qnty,aKitchenStock.UnitPrice*cOrderDetailse.OrderQuantity*finishedRawProduct.Qnty,
                                    DateTime.Now.Date);
                            this.ExecuteNonQuery(sqlComm);
                        }
                        if (flag > 0)
                        {
                            sqlComm = String.Format(SqlQueries.GetQuery(Query.UpdateSalereport),
                                          cOrderDetailse.OrderQuantity * finishedRawProduct.Qnty,
                                          aKitchenStock.UnitPrice * cOrderDetailse.OrderQuantity * finishedRawProduct.Qnty, flag);
                            this.ExecuteNonQuery(sqlComm);
                        }

                    }

                }

            }
            catch (Exception ex)
            {

                throw new Exception("InsertOrUpdateSaleRawmaterialsReport()",ex);
            }
            finally
            {
                this.CloseConnection();
            }
        }
Exemple #4
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;
        }