Пример #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
        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();
            }
        }
Пример #3
0
        private void UpdateRawMaterial(List<COrderDetails> details)
        {
            foreach (COrderDetails objDetails in details)
            {

                //Add for raw materials update
                if (objDetails.KitchenQuantity > 0)
                {
                    double quantity = objDetails.KitchenQuantity;
                    FinishedRawProductListDAO aDao = new FinishedRawProductListDAO();
                    List<CFinishedRawProductList> aList =
                        aDao.GetFinishedRawProductListByProductID(objDetails.ProductID);
                    foreach (CFinishedRawProductList list in aList)
                    {
                        aDao.FinishedRawProductUpdate(list, quantity);

                    }
                }
            }
        }
Пример #4
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;
        }
Пример #5
0
        private void LoadDataGrid()
        {
            try
            {

                // dgvRawProductList.Rows.Clear();
                // dgvRawProductList.Refresh();

                //if (this.dgvRawProductList.DataSource != null)
                //{
                //    this.dgvRawProductList.DataSource = null;
                //}
                //else
                //{
                //    this.dgvRawProductList.Rows.Clear();
                //}

                FinishedRawProductListDAO finishedRawProductListDao = new FinishedRawProductListDAO();

                List<CFinishedRawProductList> finishedRawProductList = new List<CFinishedRawProductList>();

                finishedRawProductList = finishedRawProductListDao.GetFinishedRawProductListByProductID(m_iCat3ID);

                var data = (from c in finishedRawProductList
                            select new { RawProductID = c.RawProductID, RawProductName = c.RawProductName, Qnty = c.Qnty, obj = c }).ToList();
                dgvRawProductList.DataSource = data;

                txtRawProductQnty.Text = finishedRawProductList.Count.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #6
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                if (cFinishedProductList != null)
                {
                    FinishedRawProductListDAO finishedRawProductListDao = new FinishedRawProductListDAO();

                    finishedRawProductListDao.FinishedRawProductListDelete(cFinishedProductList);
                }

                cFinishedProductList = null;

                LoadDataGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #7
0
        private void AddFinishedtoRawProductList()
        {
            try
            {
                //  FinishedRawProductListDAO finishedRawProductDAO = new FinishedRawProductListDAO();

                FinishedRawProductListDAO finishedRawProductDAO = new FinishedRawProductListDAO();
                //     CFinishedRawProductList cfinishedproduct = new CFinishedRawProductList();

                if (isModifyRawProduct && txtRawQnty.Tag != null)
                {
                    cFinishedProductList = txtRawQnty.Tag as CFinishedRawProductList;
                }
                else
                {
                    cFinishedProductList = new CFinishedRawProductList();
                }
                InventoryItem aInventoryItem = new InventoryItem();
                aInventoryItem = (InventoryItem)cmbProductName.SelectedItem;

                // cFinishedProductList.FinishedProductID = m_iCat3ID;
                // cFinishedProductList.RawProductID = cCategory3sList[cmbProductName.SelectedIndex].Category3ID;
                // cFinishedProductList.RawProductName = cCategory3sList[cmbProductName.SelectedIndex].Category3Name;
                cFinishedProductList.FinishedProductID = m_iCat3ID;
                cFinishedProductList.RawProductID = aInventoryItem.ItemId;
                cFinishedProductList.RawProductName = aInventoryItem.ItemName;

                //try { cFinishedProductList.Qnty = Convert.ToInt32(txtRawQnty.Text); }
                //catch (Exception e)
                //{
                //}
                try { cFinishedProductList.Qnty = Convert.ToDouble(txtRawQnty.Text); }
                catch (Exception e)
                {
                }

                cFinishedProductList.Remarks = "";

                if (isModifyRawProduct)
                {
                    finishedRawProductDAO.FinishedRawProductListUpdate(cFinishedProductList);
                }
                else
                {
                    try
                    {
                        finishedRawProductDAO.FinishedRawProductListInsert(cFinishedProductList);
                    }
                    catch { }
                }

                RefreshFinishedRawProduct();

                LoadDataGrid();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }