Esempio n. 1
0
        private void TableIcon_MouseClick(object sender, EventArgs e)
        {
            try
            {
                COrderManager tempOrderManager = new COrderManager();
                LobbyItemButton tempTableIcon = (LobbyItemButton)sender;
                CCommonConstants tempCommonConstants = ConfigManager.GetConfig<CCommonConstants>();

                if (tempTableIcon.Type.Equals("Table") || tempTableIcon.Type.Equals("Tabs"))
                {
                    if (m_bTableInfoClicked)
                    {
                        CTableInfoMessageBox tempTableInfoMessageBox = new CTableInfoMessageBox(tempTableIcon.OrderID);
                        tempTableInfoMessageBox.Show();

                        m_bTableInfoClicked = false;
                        return;
                    }
                    else if (m_bNameTableClicked)
                    {
                        CKeyBoardForm tempKeyBoardForm = new CKeyBoardForm("Table Naming", "Please Enter the Name of the Table");
                        tempKeyBoardForm.ShowDialog();

                        if (CKeyBoardForm.Content.Equals("Cancel") || CKeyBoardForm.Content.Equals(""))
                            return;

                        COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(tempTableIcon.OrderID).Data;
                        tempOrderInfo.TableName = CKeyBoardForm.Content;
                        tempOrderManager.UpdateOrderInfo(tempOrderInfo);
                        tempTableIcon.TableName = CKeyBoardForm.Content;
                        m_bNameTableClicked = false;
                        TablePanel.Controls.Clear();
                        this.Init();
                        return;
                    }
                    else if (m_bChangeDetailsClicked)
                    {
                        CKeyBoardForm tempKeyBoardForm = new CKeyBoardForm("Change Details", "Please Enter the Name of the Table");
                        tempKeyBoardForm.ShowDialog();
                        if (CKeyBoardForm.Content.Equals("Cancel")) //If cancelled then exit.
                        {
                            return;
                        }

                        CCalculatorForm tempCalculatorForm = new CCalculatorForm("Change Details", "Guest Quantity");
                        tempCalculatorForm.ShowDialog();

                        COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(tempTableIcon.OrderID).Data;
                        if (!CKeyBoardForm.Content.Equals("") && !CKeyBoardForm.Content.Equals("Cancel"))
                        {
                            tempOrderInfo.TableName = CKeyBoardForm.Content;
                        }

                        if(!CCalculatorForm.inputResult.Equals("") && !CCalculatorForm.inputResult.Equals("Cancel") && !(Int32.Parse(CCalculatorForm.inputResult)==0))
                            tempOrderInfo.GuestCount = Convert.ToInt32(CCalculatorForm.inputResult);
                        tempOrderManager.UpdateOrderInfo(tempOrderInfo);

                        m_bChangeDetailsClicked = false;
                        TablePanel.Controls.Clear();
                        Init();
                        return;
                    }
                }

                CTableInfo tempTableInfo = new CTableInfo();
                tempTableInfo = (CTableInfo)tempOrderManager.GetTableInfoByTableNumber(tempTableIcon.TableNumber, tempTableIcon.Type).Data;

                if (tempTableInfo!=null && tempTableInfo.Status == 1)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Table Information", "Someone else is using this table at this moment.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                tempTableInfo.TableNumber = tempTableIcon.TableNumber;
                tempTableInfo.TableType = tempTableIcon.Type;
                tempTableInfo.Status = 1;
                tempOrderManager.UpdateTableInfo(tempTableInfo);

                if (tempTableIcon.Type.Equals("Table"))
                {
                    CTableOrderForm tempTableOrderForm = new CTableOrderForm(tempTableIcon.OrderID, tempCommonConstants.TableType, tempTableIcon.TableNumber);
                    tempTableOrderForm.m_TerminalName = TerminalIDLabel.Text;
                    tempTableOrderForm.m_orderUserName = tempTableIcon.User;
                    tempTableOrderForm.Show();
                }
                else if (tempTableIcon.Type.Equals("Tabs"))
                {
                    CBarServiceForm tempBarServiceForm = new CBarServiceForm(tempTableIcon.OrderID, tempCommonConstants.TabsType, tempTableIcon.TableNumber);
                    tempBarServiceForm.Show();

                }
                else if (tempTableIcon.Type.Equals("TakeAway"))
                {
                    CTableOrderForm tempTableOrderForm = new CTableOrderForm(tempTableIcon.OrderID, tempCommonConstants.TakeAwayType, tempTableIcon.TableNumber);
                    //tempTableOrderForm.m_TerminalName = TerminalIDLabel.Text;
                    tempTableOrderForm.m_orderUserName = tempTableIcon.User;
                    tempTableOrderForm.Show();
                }

                CFormManager.Forms.Push(this);
                this.Hide();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
            }
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        private void Category3Button_Click(object sender, EventArgs e)
        {
            //get item qty

            CCategoryButton tempCategory3Button = (CCategoryButton)sender;
            RMSGlobal.m_sellinginvalue = tempCategory3Button.SellingQuantityorWeight; //Used to identify the product whether sold in quantity or weight

            int tempCategory3ID = tempCategory3Button.CategoryID;
            if (m_bItemDescriptionClicked)
            {
                string tempItemDescription = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0]["description"].ToString();
                if (!tempItemDescription.Equals(""))
                {
                    CMessageBox tempMessageBox = new CMessageBox("Item Description", tempItemDescription);
                    tempMessageBox.ShowDialog();
                }
                else
                {
                    CMessageBox tempMessageBox = new CMessageBox("Item Description", "No information available.");
                    tempMessageBox.ShowDialog();
                }
                m_bItemDescriptionClicked = false;
                return;
            }

            int tempFoodType = int.Parse(Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0].GetParentRow(Program.initDataSet.Relations["category2_to_category3"])["cat2_type"].ToString());
            DataGridView tempDataGridView = new DataGridView();
            if (tempFoodType == 0)
            {
                tempDataGridView = g_BeverageDataGridView;
            }
            else
            {
                tempDataGridView = g_FoodDataGridView;
            }

            DataRow[] tempDataRowArray = Program.initDataSet.Tables["Category4"].Select("cat3_id = " + tempCategory3ID.ToString());

            category4ButtonList.Clear();

            COrderInfoDAO aOrderInfoDao = new COrderInfoDAO();
            COrderInfo aCOrderInfo = aOrderInfoDao.GetOrderInfoByOrderID(orderID);

            if (tempDataRowArray.Length != 0)
            {

                foreach (DataRow tempDataRow in tempDataRowArray)
                {
                    if (Int32.Parse(tempDataRow["status"].ToString()) == 0)
                    {
                        continue;
                    }
                    CCategoryButton tempCategoryButton = new CCategoryButton();
                    tempCategoryButton.CategoryID = int.Parse(tempDataRow["cat4_id"].ToString());
                    tempCategoryButton.CategoryOrder = int.Parse(tempDataRow["cat4_order"].ToString());
                    tempCategoryButton.CategoryLevel = 4;
                    tempCategoryButton.Text = tempDataRow["cat4_name"].ToString();
                    tempCategoryButton.BackColor = tempCategory3Button.BackColor;
                    category4ButtonList.Add(tempCategoryButton);
                }

                keyboardForm.Hide();
                CCategory4Form tempCategory4Form = new CCategory4Form(tempCategory3ID, category4ButtonList, tempCategory3Button.Text);
                tempCategory4Form.ShowDialog();

                CCategoryButton tempCategory4Button = CCategory4Form.m_cbResult;
                m_iSavedOrderedQty = CCategory4Form.ItemQTY;
                if (tempCategory4Button == null)
                {
                    return;
                }
                else   //insert into table and datagridview
                {
                    DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempCategory4Button.CategoryID.ToString());
                    if (temp2DataRowArray.Length != 0)
                    {
                        //category4 + categpry3
                        string ItemName = temp2DataRowArray[0]["cat4_name"].ToString() + " " + tempCategory3Button.Text;
                        string tableTypePrice = string.Empty;
                        if (m_iType == m_cCommonConstants.TableType)
                        {
                            tableTypePrice = temp2DataRowArray[0]["table_price"].ToString();
                        }
                        else if (m_iType == m_cCommonConstants.TakeAwayType)
                        {
                            tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString();
                        }

                        int tempSearchResult = FindExistingItem(tempDataGridView, ItemName);

                        // vat_included
                        double vatRate = 0;
                        bool vat_included = false;
                        double vatAmountRate = 0;
                        try
                        {
                            vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString());
                            vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString());

                            if (vat_included)
                            {
                                vatAmountRate = (Double.Parse(tableTypePrice) * vatRate) / 100;

                                // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString();
                                tableTypePrice = Convert.ToDouble(tableTypePrice).ToString();
                            }
                            else
                            {
                                vatAmountRate = 0.00;
                            }

                        }
                        catch (Exception ex) { }

                        COrderManager tempOrderManager = new COrderManager();
                        COrderDetails tempOrderDetails = new COrderDetails();

                        if (tempSearchResult != -1)
                        {
                            int tempRowIndex = tempSearchResult;
                            int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty;
                            tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty;
                            tempDataGridView.Rows[tempRowIndex].Cells[3].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02");
                            //update Order_details table
                            tempOrderDetails.OrderID = orderID;
                            tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString());
                            tempOrderDetails.ProductID = tempCategory4Button.CategoryID;
                            tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel;
                            tempOrderDetails.OrderQuantity = qty;
                            tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice);
                            tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice);
                            tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood");
                            tempOrderDetails.OnlineItemSequenceNumber = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString());
                            tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[8].Value.ToString());

                            if (aCOrderInfo.VatComplementory) vatRate =vatAmountRate= 0;
                            if (vat_included)
                            {
                                // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate;
                                tempOrderDetails.VatTotal = qty * vatAmountRate;
                                tempDataGridView.Rows[tempRowIndex].Cells[2].Value = qty * vatAmountRate;
                            }
                            else
                            {
                                tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100);
                            }

                            if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
                            {
                                tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                            }
                            else
                            {
                                tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails);//for online orders
                            }
                        }
                        else
                        {
                            //Insert into Order_details table
                            tempOrderDetails.OrderID = orderID;
                            tempOrderDetails.ProductID = tempCategory4Button.CategoryID;
                            tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel;
                            tempOrderDetails.OrderQuantity = m_iSavedOrderedQty;
                            tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice);
                            tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood");
                            tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks;
                            tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice);
                          //  tempOrderDetails.Product_Name = temp2DataRowArray[0]["cat3_name"].ToString();
                            if (aCOrderInfo.VatComplementory) vatRate = 0;
                            if (vat_included)
                            {
                                tempOrderDetails.VatTotal = 0;
                                tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100);
                                // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate;
                            }
                            else
                            {
                                tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100);
                            }

                            tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal;

                            string category1ID = this.GetCategory1ID(tempOrderDetails.ProductID, tempOrderDetails.CategoryLevel);
                            //Int32 cat1Order = this.GetCategory1OrderNumber(Convert.ToInt32(category1ID)); // Change by Mithu

                            if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
                            {
                                tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data;
                                string[] tempDataGridViewRow = new string[]
                                { ItemName,
                                  m_iSavedOrderedQty.ToString(),
                                  ((double)tempOrderDetails.VatTotal).ToString("F02"),
                                  ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"),
                                  tempCategory4Button.CategoryID.ToString(),
                                  "4",
                                  temp2DataRowArray[0]["cat4_rank"].ToString(),
                                  tempOrderDetails.OrderDetailsID.ToString(),
                                  "0",
                                  tempOrderDetails.UnitPrice.ToString("F2")
                                };

                                tempDataGridView.Rows.Add(tempDataGridViewRow);
                            }
                            else //For online orders
                            {
                                tempOrderDetails.ItemName = ItemName;
                                tempOrderDetails = (COrderDetails)tempOrderManager.InsertOnlineOrderDetails(tempOrderDetails).Data;
                                string[] tempDataGridViewRow = new string[]
                                { ItemName,
                                  m_iSavedOrderedQty.ToString(),
                                  ((double)tempOrderDetails.VatTotal).ToString("F02"),
                                  ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"),
                                  tempCategory4Button.CategoryID.ToString(),
                                  "4",
                                  tempOrderDetails.OnlineItemSequenceNumber.ToString(),
                                  tempOrderDetails.OrderDetailsID.ToString(),"0",
                                  tempOrderDetails.UnitPrice.ToString("F2")
                                };

                                tempDataGridView.Rows.Add(tempDataGridViewRow);
                            }
                        }

                        if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //If local orders are considered
                        {
                            this.ConvertRank();
                        }

                        tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending);

                        tempDataGridView.Update();
                        TotalAmountCalculation();
                    }
                }
            }
            else //There is no category4
            {
                keyboardForm.Hide();
                try
                {
                    CCalculatorForm tempCalculatorForm = new CCalculatorForm("Order Quantity", "Item Quantity");
                    tempCalculatorForm.ShowDialog();

                    if (CCalculatorForm.inputResult.Equals("Cancel"))
                        return;

                    string str = CCalculatorForm.inputResult;
                    str = (str == "") ? "1" : str;

                    if (Int32.Parse(str) == 0)
                    {
                        CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                        tempMessageBox.ShowDialog();
                        return;
                    }

                    int tempOrderedQty = Int32.Parse(str);
                    m_iSavedOrderedQty = tempOrderedQty;

                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                DataGridViewRow tempDataGridViewRow = new DataGridViewRow();
                tempDataGridViewRow.CreateCells(tempDataGridView);

                DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3Button.CategoryID.ToString());
                if (temp2DataRowArray.Length != 0)
                {
                    string tableTypePrice = string.Empty;
                    if (m_iType == m_cCommonConstants.TableType)
                    {
                        tableTypePrice = temp2DataRowArray[0]["table_price"].ToString();
                    }
                    else if (m_iType == m_cCommonConstants.TakeAwayType)
                    {
                        tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString();
                    }

                    // vat_included
                    double vatRate = 0;
                    bool vat_included = false;
                    double vatAmountRate = 0;

                    try
                    {
                        vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString());
                        vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString());

                        if (vat_included)
                        {
                            vatAmountRate = (Double.Parse(tableTypePrice) * vatRate) / 100;

                            // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString();
                            tableTypePrice = Convert.ToDouble(tableTypePrice).ToString();
                        }
                        else
                        {
                            vatAmountRate = 0.00;
                        }

                    }
                    catch (Exception ex) { }

                    COrderManager tempOrderManager = new COrderManager();
                    COrderDetails tempOrderDetails = new COrderDetails();

                    int tempResult = FindExistingItem(tempDataGridView, temp2DataRowArray[0]["cat3_name"].ToString());
                    if (tempResult != -1)
                    {
                        //update Order_details table
                        int tempRowIndex = tempResult;
                        int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty;
                        tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty;
                        tempDataGridView.Rows[tempRowIndex].Cells[3].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02");
                        tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString());
                        tempOrderDetails.OrderID = orderID;
                        tempOrderDetails.ProductID = tempCategory3Button.CategoryID;
                        tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel;
                        tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice);
                        tempOrderDetails.OrderQuantity = qty;
                        tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice);
                        tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood");
                        tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString());
                        tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[8].Value.ToString());
                        if (aCOrderInfo.VatComplementory) vatAmountRate = 0;
                        if (vat_included)
                        {
                            tempOrderDetails.VatTotal = qty * vatAmountRate;
                            tempDataGridView.Rows[tempRowIndex].Cells[2].Value = tempOrderDetails.VatTotal;
                        }
                        else
                        {
                            tempOrderDetails.VatTotal = 0.00;
                        }

                        if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
                        {
                            tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                        }
                        else
                        {
                            tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails);
                        }

                    }
                    else
                    {
                        //Insert into Order_details table
                        tempOrderDetails.OrderID = orderID;
                        tempOrderDetails.ProductID = tempCategory3Button.CategoryID;
                        tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel;
                        tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice);
                        tempOrderDetails.OrderQuantity = m_iSavedOrderedQty;
                        tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice);
                        tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood");
                        tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks;
                        tempOrderDetails.Product_Name = temp2DataRowArray[0]["cat3_name"].ToString();
                        tempOrderDetails.UOM = temp2DataRowArray[0]["uom"].ToString();
                        tempOrderDetails.Product_Type = temp2DataRowArray[0]["productType"].ToString();
                        if (aCOrderInfo.VatComplementory) vatRate = vatAmountRate = 0;
                        try
                        {
                            if (vat_included)
                            {
                                tempOrderDetails.VatTotal = 0;
                                tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100);
                                // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate;
                            }
                            else
                            {
                                tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100);
                            }
                        }
                        catch { }

                        try
                        {
                            tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal;

                        }
                        catch { }

                        string category1ID = this.GetCategory1ID(tempOrderDetails.ProductID, tempOrderDetails.CategoryLevel);
                        Int32 cat1Order = this.GetCategory1OrderNumber(Convert.ToInt32(category1ID));

                        if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
                        {
                            tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data;
                            string[] temp2DataGridViewRow = new string[]
                                { temp2DataRowArray[0]["cat3_name"].ToString(),
                                  m_iSavedOrderedQty.ToString(),
                                  tempOrderDetails.VatTotal.ToString("F2"),
                                  ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"),
                                  tempCategory3Button.CategoryID.ToString(),
                                  "3",
                                  temp2DataRowArray[0]["cat3_rank"].ToString(),
                                  tempOrderDetails.OrderDetailsID.ToString(),"0",
                                    tempOrderDetails.UnitPrice.ToString("F2")
                                };
                            tempDataGridView.Rows.Add(temp2DataGridViewRow);
                        }
                        else
                        {
                            tempOrderDetails.ItemName = temp2DataRowArray[0]["cat3_name"].ToString();
                            tempOrderDetails = (COrderDetails)tempOrderManager.InsertOnlineOrderDetails(tempOrderDetails).Data;
                            string[] temp2DataGridViewRow = new string[]
                                {temp2DataRowArray[0]["cat3_name"].ToString(),
                                  m_iSavedOrderedQty.ToString(),
                                    tempOrderDetails.VatTotal.ToString(),
                                  ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"),
                                  tempCategory3Button.CategoryID.ToString(),
                                  "3",
                                  tempOrderDetails.OnlineItemSequenceNumber.ToString(),//For online order sequence number is category rank.
                                  tempOrderDetails.OrderDetailsID.ToString(),"0", //0 For first time.
                                  tempOrderDetails.UnitPrice.ToString("F2")
                                };
                            tempDataGridView.Rows.Add(temp2DataGridViewRow);
                        }
                    }

                    if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
                    {
                        this.ConvertRank();
                    }
                    tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending);
                    try
                    {
                        tempDataGridView.Update();
                    }
                    catch { }
                        TotalAmountCalculation();

                }
            }
            g_FoodDataGridView.ClearSelection();
            g_BeverageDataGridView.ClearSelection();
            m_iSavedOrderedQty = 1;

            keyboardForm.Hide();

            this.SetPrintedItemBackColor();
        }
Esempio n. 4
0
        private void FinishButton_Click(object sender, EventArgs e)
        {
            CResult objResultant = new CResult();
            try
            {
                if (!CheckEmpty() && m_orderIndex == 1)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Please enter all the mandatory values.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                CCustomerManager tempCustomerManager = new CCustomerManager();
                CCustomerInfo tempCustomerInfo = new CCustomerInfo();

                if (txtPhoneNumber.Text.Trim().Equals(String.Empty))
                {
                    CResult oResult5 = tempCustomerManager.CustomerInfoGetByName(txtCustomerName.Text.Trim());
                    if (oResult5.IsSuccess && oResult5.Data != null)
                    {
                        tempCustomerInfo = (CCustomerInfo)oResult5.Data;
                    }
                }

                else
                {
                    CResult oResult = tempCustomerManager.CustomerInfoGetByPhone(txtPhoneNumber.Text.Trim());
                    if (oResult.IsSuccess && oResult.Data != null)
                    {
                        tempCustomerInfo = (CCustomerInfo)oResult.Data;
                    }
                }

                if (txtCustomerName.Text.Length == 0 && (m_orderIndex == 2 || m_orderIndex == 3))
                {
                    txtCustomerName.Text = m_order_name;
                }

                tempCustomerInfo.CustomerName = txtCustomerName.Text.Trim();
                tempCustomerInfo.CustomerPhone = txtPhoneNumber.Text.Trim();

                if (m_orderIndex == 1) //If only delivery type order is considered
                {
                    tempCustomerInfo.CustomerPostalCode = txtPostalCode.Text.Trim();

                    tempCustomerInfo.FloorAptNumber = txtFloorAptNumber.Text.Trim();
                    tempCustomerInfo.HouseNumber = txtHouseNumber.Text.Trim();
                    tempCustomerInfo.StreetName = txtStreetName.Text.Trim() + "-" + txtStreet2.Text.Trim();
                    tempCustomerInfo.BuildingName = txtBuildingName.Text.Trim();

                    tempCustomerInfo.CustomerTown = txtTown.Text.Trim();
                    tempCustomerInfo.CustomerCountry = cmbCountry.Text;
                    tempCustomerInfo.UserName = RMSGlobal.LoginUserName;
                    tempCustomerInfo.TerminalId = RMSGlobal.Terminal_Id;
                    Int64 currentdateTime = DateTime.Now.Ticks;
                    tempCustomerInfo.InsertDate = currentdateTime;
                }

                if (tempCustomerInfo.CustomerID == 0)
                {
                        CResult oResult6 = tempCustomerManager.InsertCustomerInfo(tempCustomerInfo);
                        if (oResult6.IsSuccess && oResult6.Data != null)
                            tempCustomerInfo = (CCustomerInfo)oResult6.Data;
                }
                else
                {
                        tempCustomerManager.UpdateCustomerInfo(tempCustomerInfo);
                }

                #region "Older"

                if (m_customerEditStatus == false)
                {
                    if (m_iOrderID == 0)
                    {
                        COrderManager tempOrderManager = new COrderManager();
                        COrderInfo tempOrderInfo = new COrderInfo();
                        tempOrderInfo.CustomerID = tempCustomerInfo.CustomerID;
                        tempOrderInfo.OrderType = "TakeAway";
                        tempOrderInfo.OrderTime = System.DateTime.Now;
                        tempOrderInfo.TableNumber = GetValidTableNumber("TakeAway");
                        CTableInfo tempTableInfo = new CTableInfo();
                        tempTableInfo.TableNumber = tempOrderInfo.TableNumber;
                        tempTableInfo.TableType = "TakeAway";
                        tempOrderManager.InsertTableInfo(tempTableInfo);

                        if (m_orderIndex==1)
                        {
                            tempOrderInfo.Status = "Delivery";
                        }
                        else if (m_orderIndex ==2 )
                        {
                            tempOrderInfo.Status = "Collection";
                        }
                        else if (m_orderIndex == 3)
                        {
                            tempOrderInfo.Status = "Waiting";
                        }

                        m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>();
                        tempOrderInfo.UserID = m_oCommonConstants.UserInfo.UserID;

                        objResultant = tempOrderManager.InsertOrderInfo(tempOrderInfo); //New Order
                        COrderInfo tempOrderInfoNew = (COrderInfo)objResultant.Data;//Taking the order ID
                        m_iOrderID = tempOrderInfoNew.OrderID;

                        #region " Inserting Order details info if items are selected from the previous orders"
                        //Developed by baruri
                        List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>();
                        if (m_htOrderInfo.Count > 0) //If item is selected from the previous order
                        {
                            tempOrderDetailsList = (List<COrderDetails>)m_htOrderInfo["orderdetail"];
                        }
                        if (tempOrderDetailsList.Count > 0) //Insert details for the new order
                        {
                            for (int itemDetailIndex = 0; itemDetailIndex < tempOrderDetailsList.Count; itemDetailIndex++)
                            {
                                COrderDetails objOrderDetails = (COrderDetails)tempOrderDetailsList[itemDetailIndex];
                                objOrderDetails.OrderID = tempOrderInfo.OrderID;
                                tempOrderManager.InsertOrderDetails(objOrderDetails);
                            }
                            m_htOrderInfo = new Hashtable();//Clearing the previous items from the order if there is any.
                        }
                        #endregion

                        //insert delivery time
                        if (tempOrderInfo.Status.Equals("Delivery"))
                        {
                            CDelivery tempDelivery = new CDelivery();
                            tempDelivery.DeliveryOrderID = tempOrderInfo.OrderID;
                            string deliveryTime = Convert.ToInt32("0" + cmbHour.Text).ToString("00") + ":" + Convert.ToInt32("0" + cmbMinute.Text).ToString("00") + " " + cmbMeridiem.Text;
                            tempDelivery.DeliveryTime = deliveryTime;// DeliveryTimeTextBox.Text.Trim();
                            tempOrderManager.InsertDeliveryInfo(tempDelivery);
                        }

                        //OLD Code
                        //Form tempForm = CFormManager.Forms.Pop();
                        //tempForm.Show();

                        try
                        {
                            WaiterForm waiterForm = new WaiterForm();
                            waiterForm.UserList = userList;
                            waiterForm.ShowDialog();

                            if (waiterForm.DialogResult == DialogResult.OK)
                            {
                                COrderWaiterDao orderwaiterDao = new COrderWaiterDao();
                                COrderwaiter orderwaiter = new COrderwaiter();

                                orderwaiter = orderwaiterDao.GetOrderwaiterByOrderID(tempOrderInfo.OrderID);
                                if (orderwaiter != null && orderwaiter.ID > 0 && orderwaiter.WaiterID != waiterForm.UserInfoData.UserID)
                                {
                                    orderwaiter.OrderID = tempOrderInfo.OrderID;
                                    orderwaiter.WaiterID = waiterForm.UserInfoData.UserID;
                                    orderwaiter.WaiterName = waiterForm.UserInfoData.UserName;
                                    orderwaiterDao.UpdateOrderwaiter(orderwaiter);
                                }
                                else if (orderwaiter.ID == 0)
                                {
                                    orderwaiter.OrderID = tempOrderInfo.OrderID;
                                    orderwaiter.WaiterID = waiterForm.UserInfoData.UserID;
                                    orderwaiter.WaiterName = waiterForm.UserInfoData.UserName;
                                    orderwaiterDao.InsertOrderwaiter(orderwaiter);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }

                        m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>();
                        CTableOrderForm tempForm = new CTableOrderForm(m_iOrderID, m_oCommonConstants.TakeAwayType, tempOrderInfo.TableNumber);
                        tempForm.m_orderUserName = RMSGlobal.LoginUserName;
                        tempForm.Show();

                        this.Close();
                    }
                    else
                    {
                        COrderManager tempOrderManager = new COrderManager();
                        CResult oResult7 = tempOrderManager.OrderInfoByOrderID(m_iOrderID);
                        COrderInfo tempOrderInfo = new COrderInfo();
                        if (oResult7.IsSuccess && oResult7.Data != null)
                        {
                            tempOrderInfo = (COrderInfo)oResult7.Data;
                        }

                        tempOrderInfo.OrderType = "TakeAway";
                        tempOrderInfo.Status = "TakeAway";
                        tempOrderInfo.GuestCount = 0;
                        tempOrderInfo.TableName = "";
                        tempOrderInfo.CustomerID = tempCustomerInfo.CustomerID;
                        tempOrderInfo.TableNumber = GetValidTableNumber("TakeAway");

                        CTableInfo tempTableInfo = new CTableInfo();
                        tempTableInfo.TableNumber = tempOrderInfo.TableNumber;
                        tempTableInfo.TableType = "TakeAway";
                        tempOrderManager.InsertTableInfo(tempTableInfo);

                        if (m_orderIndex == 1)
                        {
                            tempOrderInfo.Status = "Delivery";
                        }
                        else if (m_orderIndex == 3)
                        {
                            tempOrderInfo.Status = "Waiting";
                        }
                        else if (m_orderIndex == 2)
                        {
                            tempOrderInfo.Status = "Collection";
                        }
                        tempOrderManager.UpdateOrderInfo(tempOrderInfo);

                        //insert delivery time
                        if (tempOrderInfo.Status.Equals("Delivery"))
                        {
                            CDelivery tempDelivery = new CDelivery();
                            tempDelivery.DeliveryOrderID = tempOrderInfo.OrderID;
                            string deliveryTime = Convert.ToInt32("0" + cmbHour.Text).ToString("00") + ":" + Convert.ToInt32("0" + cmbMinute.Text).ToString("00") + " " + cmbMeridiem.Text;
                            tempDelivery.DeliveryTime = deliveryTime;// DeliveryTimeTextBox.Text.Trim();
                            tempOrderManager.InsertDeliveryInfo(tempDelivery);
                        }

                        try
                        {
                            WaiterForm waiterForm = new WaiterForm();
                            waiterForm.UserList = userList;
                            waiterForm.ShowDialog();

                            if (waiterForm.DialogResult == DialogResult.OK)
                            {
                                COrderWaiterDao orderwaiterDao = new COrderWaiterDao();
                                COrderwaiter orderwaiter = new COrderwaiter();

                                orderwaiter = orderwaiterDao.GetOrderwaiterByOrderID(tempOrderInfo.OrderID);
                                if (orderwaiter != null && orderwaiter.ID > 0 && orderwaiter.WaiterID != waiterForm.UserInfoData.UserID)
                                {
                                    orderwaiter.OrderID = tempOrderInfo.OrderID;
                                    orderwaiter.WaiterID = waiterForm.UserInfoData.UserID;
                                    orderwaiter.WaiterName = waiterForm.UserInfoData.UserName;
                                    orderwaiterDao.UpdateOrderwaiter(orderwaiter);
                                }
                                else if (orderwaiter.ID == 0)
                                {
                                    orderwaiter.OrderID = tempOrderInfo.OrderID;
                                    orderwaiter.WaiterID = waiterForm.UserInfoData.UserID;
                                    orderwaiter.WaiterName = waiterForm.UserInfoData.UserName;
                                    orderwaiterDao.InsertOrderwaiter(orderwaiter);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }

                        m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>();
                        CTableOrderForm tempForm = (CTableOrderForm)CFormManager.Forms.Pop();
                        tempForm.m_iType = m_oCommonConstants.TakeAwayType;
                        tempForm.Show();
                        this.Close();
                    }
                }
                #endregion
                else //Edit order information.As here is reached from order details screen.
                {
                    COrderInfo tempOrderInfo = new COrderInfo();
                    COrderManager tempOrderManager = new COrderManager();
                    CDelivery tempDelivery = null;

                    tempOrderInfo.OrderID = m_iOrderID;
                    tempOrderManager.DeleteDeliveryInfo(m_iOrderID);//Delete previous record from delivery information table

                    if (m_orderIndex==2)
                    {
                        tempOrderInfo.Status = "Collection";
                    }
                    else if (m_orderIndex==3)
                    {
                        tempOrderInfo.Status = "Waiting";
                    }
                    else
                    {
                        tempOrderInfo.Status = "Delivery";
                        tempDelivery = new CDelivery();
                        tempDelivery.DeliveryOrderID = tempOrderInfo.OrderID;
                        string deliveryTime = Convert.ToInt32("0" + cmbHour.Text).ToString("00") + ":" + Convert.ToInt32("0" + cmbMinute.Text).ToString("00") + " " + cmbMeridiem.Text;
                        tempDelivery.DeliveryTime = deliveryTime;//
                        tempOrderManager.InsertDeliveryInfo(tempDelivery);//Update delivery information
                    }

                    tempOrderManager.UpdateTakeawayOrderInfo(tempOrderInfo);//Update order information

                    try
                    {
                        WaiterForm waiterForm = new WaiterForm();
                        waiterForm.UserList = userList;
                        waiterForm.ShowDialog();

                        if (waiterForm.DialogResult == DialogResult.OK)
                        {
                            COrderWaiterDao orderwaiterDao = new COrderWaiterDao();
                            COrderwaiter orderwaiter = new COrderwaiter();

                            orderwaiter = orderwaiterDao.GetOrderwaiterByOrderID(tempOrderInfo.OrderID);
                            if (orderwaiter != null && orderwaiter.ID > 0 && orderwaiter.WaiterID != waiterForm.UserInfoData.UserID)
                            {
                                orderwaiter.OrderID = tempOrderInfo.OrderID;
                                orderwaiter.WaiterID = waiterForm.UserInfoData.UserID;
                                orderwaiter.WaiterName = waiterForm.UserInfoData.UserName;
                                orderwaiterDao.UpdateOrderwaiter(orderwaiter);
                            }
                            else if (orderwaiter.ID == 0)
                            {
                                orderwaiter.OrderID = tempOrderInfo.OrderID;
                                orderwaiter.WaiterID = waiterForm.UserInfoData.UserID;
                                orderwaiter.WaiterName = waiterForm.UserInfoData.UserName;
                                orderwaiterDao.InsertOrderwaiter(orderwaiter);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }

                    m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>();
                    CTableOrderForm tempForm = (CTableOrderForm)CFormManager.Forms.Pop();
                    tempForm.m_iType = m_oCommonConstants.TakeAwayType;
                    tempForm.Show();
                    this.Close();
                }
                m_phoneNumber = String.Empty;
            }
            catch (Exception exp)
            {
                Console.Write(exp.Message);
            }
        }
Esempio n. 5
0
        private void g_RemoveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_iDataGridViewCurrentRowIndex == -1)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage.");
                    tempMessageBox.ShowDialog();
                    return;
                }
                if (m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString().Equals(""))
                {
                    return;
                }

                int totalQuantity = Convert.ToInt32(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString());
               // int printedQuantity = Convert.ToInt32(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value.ToString());
                int printedQuantity = Convert.ToInt32(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[8].Value.ToString());

                //If printed items are equal to total quantity or greater
                if (totalQuantity <= printedQuantity)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Printed", "Current item(s) has already been sent to kitchen.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                COrderManager tempOrderManager1 = new COrderManager();
                CResult oResult1 = tempOrderManager1.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value.ToString()));
                COrderDetails aDetails = new COrderDetails();
                if (oResult1.IsSuccess && oResult1.Data != null)
                {
                    aDetails = (COrderDetails)oResult1.Data;
                }
                if (aDetails.GuestPrintQuantity >= totalQuantity)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Printed", " All ready Guest Bill Printed so that impossible of item decrease");
                    tempMessageBox.ShowDialog();
                    return;
                }

                if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".ToUpper().Replace(" ", "")) //If the order is not online order
                {

                    COrderManager tempOrderManager = new COrderManager();
                    //int qty = Int32.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString());
                    ////Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString());

                    ////For Vat and Unit vat
                    //Double itemTotalVat = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString());
                    //Double unitVat = itemTotalVat / qty;
                    //itemTotalVat = itemTotalVat - unitVat;
                    //Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value.ToString());
                    //Double unitPrice = amount / qty;

                    int qty = Int32.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString());
                    //Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString());

                    //For Vat and Unit vat
                    Double itemTotalVat = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString());
                    Double unitVat = itemTotalVat / qty;
                    // itemTotalVat = itemTotalVat - unitVat;
                    Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value.ToString());
                    Double unitPrice = amount / qty;

                    if (qty == 1)
                    {
                        tempOrderManager.DeleteOrderDetails(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value.ToString()));
                        m_dDataGridView.Rows.RemoveAt(m_iDataGridViewCurrentRowIndex);
                    }
                    else
                    {
                        qty = qty - 1;
                        if (qty < 1)
                        {
                            qty = 0;
                        }

                        COrderDetails tempOrderDetails = new COrderDetails();
                    //    CResult oResult = tempOrderManager.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString()));
                        CResult oResult = tempOrderManager.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value.ToString()));

                        if (oResult.IsSuccess && oResult.Data != null)
                        {
                            tempOrderDetails = (COrderDetails)oResult.Data;
                        }
                        //tempOrderDetails.OrderQuantity = qty;
                        //tempOrderDetails.OrderAmount = qty * unitPrice;
                        //tempOrderDetails.PrintedQuantity = tempOrderDetails.PrintedQuantity - 1;

                        //Add by deb
                        tempOrderDetails.OrderQuantity = qty;
                        tempOrderDetails.OrderAmount = qty * unitPrice;
                        tempOrderDetails.VatTotal = unitVat * qty;

                        if (tempOrderDetails.PrintedQuantity <= 0)
                        {
                            tempOrderDetails.PrintedQuantity = 0;
                        }
                        //tempOrderDetails.OrderDetailsID = Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString());
                        tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal;
                        tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = qty;

                        //m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value = tempOrderDetails.PrintedQuantity;
                       // m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = ((double)(qty * unitPrice)).ToString("F02");
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[8].Value = tempOrderDetails.PrintedQuantity;
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value = ((double)(qty * unitPrice)).ToString("F02");
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = ((double)(unitVat * qty)).ToString("F02");

                    }
                }
                else //Proceed for online order
                {
                    if (this.TotalItems() < 2)
                    {
                        MessageBox.Show("You can not remove all the items from online", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    COrderManager tempOrderManager = new COrderManager();
                    int qty = Int32.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString());
                    Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString());
                    Double unitPrice = amount / qty;
                    if (qty == 1)
                    {
                        tempOrderManager.DeleteOnlineOrderDetails(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value.ToString())); //Taking the order sequence number.Here named category ranking
                        m_dDataGridView.Rows.RemoveAt(m_iDataGridViewCurrentRowIndex);
                    }
                    else
                    {
                        qty = qty - 1;
                        if (qty < 1)
                        {
                            qty = 0;
                        }

                        COrderDetails tempOrderDetails = new COrderDetails();

                        tempOrderDetails.OrderQuantity = qty;
                        tempOrderDetails.OrderAmount = qty * unitPrice;
                        tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value);

                        tempOrderDetails.OrderDetailsID = Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString());
                        tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails);
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = qty;

                        ///For printed items
                        int printedItems = Convert.ToInt32(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value) - 1;
                        if (printedItems < 1)
                        {
                            printedItems = 0;
                        }
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value = printedItems;

                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = ((double)(qty * unitPrice)).ToString("F02");
                    }
                }
                m_dDataGridView.Update();
                TotalAmountCalculation();
                m_dDataGridView.ClearSelection();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.SetPrintedItemBackColor(); //set the back color
        }
Esempio n. 6
0
        private void g_SpecialButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_iDataGridViewCurrentRowIndex == -1)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                CSpecialModifyForm tempKeyBoardForm = new CSpecialModifyForm();
                tempKeyBoardForm.ShowDialog();

                string sResult = CSpecialModifyForm.Content;
                if (sResult.Equals("") || sResult.Equals("Cancel"))
                {
                    return;
                }

                if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //For local order
                {
                    COrderManager tempOrderManager = new COrderManager();
                    COrderDetails tempOrderDetails = (COrderDetails)tempOrderManager.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString())).Data;

                    if (tempOrderDetails.OrderRemarks.Equals(""))
                    {
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value
                        = m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString() + " (" + sResult + ")";
                    }
                    else if (tempOrderDetails.CategoryLevel == 0)
                    {
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value
                        = m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString() + sResult;
                    }
                    else
                    {
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value
                        = m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString().Substring(0, m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells["Item"].Value.ToString().LastIndexOf('(')) + " (" + sResult + ")";
                    }

                    tempOrderDetails.OrderRemarks = sResult;
                    tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                }
                else
                {
                    COrderManager tempOrderManager = new COrderManager();
                    COrderDetails tempOrderDetails = new COrderDetails();

                    if (sResult.Length > 0)
                    {
                        m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value
                        = m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString() + " (" + sResult + ")";
                    }
                    tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value);
                    tempOrderDetails.OrderRemarks = sResult;
                    tempOrderManager.UpdateOnlineItemSpecial(tempOrderDetails);
                    this.LoadOrderDetails();
                }

                m_dDataGridView.Update();
                m_iDataGridViewCurrentRowIndex = -1;
                m_dDataGridView.ClearSelection();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 7
0
        private void g_PrintTokenButton_Click(object sender, EventArgs e)
        {
            try
            {
                CPrintMethods tempPrintMethods = new CPrintMethods();

                CKeyBoardForm tempKeyboardForm = new CKeyBoardForm("Bar Token Information", "Enter Customer Name");
                tempKeyboardForm.ShowDialog();

                if (CKeyBoardForm.Content.Equals("Cancel"))
                    return;

                CCalculatorForm tempCalculatorForm = new CCalculatorForm("Bar Token Information", "Enter Number of Guest");
                tempCalculatorForm.ShowDialog();

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                    tempMessageBox.ShowDialog();
                    return;
                }
            }
            catch (Exception eee)
            {
            }
        }
Esempio n. 8
0
        private void g_MiscButton_Click(object sender, EventArgs e)
        {
            try
            {
                CKeyBoardForm tempKeyBoardForm = new CKeyBoardForm("Misc Item", "Enter Item Name or Description", true);
                tempKeyBoardForm.ShowDialog();

                if (CKeyBoardForm.Content.Equals("Cancel"))
                    return;

                if (CKeyBoardForm.Content.Equals(""))
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Item Name cannot be Empty");
                    tempMessageBox.ShowDialog();
                    return;
                }
                CPriceCalculatorForm tempCalculatorForm = new CPriceCalculatorForm("Misc Item", "Enter Price");
                tempCalculatorForm.ShowDialog();

                if (CPriceCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CPriceCalculatorForm.inputResult.Equals("0.000"))
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Price cannot be zero.");
                    tempMessageBox.ShowDialog();
                    return;
                }
                  double price = Double.Parse(CPriceCalculatorForm.inputResult);
                //change by mithu

                        CPriceCalculatorForm tempCalculatorForm1 = new CPriceCalculatorForm("Misc Item", "Enter vat");
                     tempCalculatorForm1.ShowDialog();

                if (CPriceCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CPriceCalculatorForm.inputResult.Equals("0.000"))
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Vat cannot be zero.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                double addmisvat=Double.Parse(CPriceCalculatorForm.inputResult);

                try
                {
                    CCalculatorForm tempQtyCalculatorForm = new CCalculatorForm("Order Quantity", "Item Quantity");
                    tempQtyCalculatorForm.ShowDialog();

                    if (CCalculatorForm.inputResult.Equals("Cancel"))
                        return;

                    string str = CCalculatorForm.inputResult;
                    str = (str == "") ? "1" : str;

                    if (Int32.Parse(str) == 0)
                    {
                        CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                        tempMessageBox.ShowDialog();
                        return;
                    }

                    int tempOrderedQty = Int32.Parse(str);
                    m_iSavedOrderedQty = tempOrderedQty;

                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                COrderManager tempOrderManager = new COrderManager();
                COrderDetails tempOrderDetails = new COrderDetails();
                DataGridView tempDataGridView = null;

                if (CKeyBoardForm.m_foodType == true) //If miscelleneous item is food
                {
                    tempDataGridView = g_FoodDataGridView;
                }
                else
                {
                    tempDataGridView = g_BeverageDataGridView;
                }

                int tempResult = FindExistingItem(tempDataGridView, CKeyBoardForm.Content);
                if (tempResult != -1)
                {
                    //update Order_details table
                    int tempRowIndex = tempResult;
                    tempDataGridView.Rows[tempRowIndex].Cells[1].Value = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty;
                    tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString());
                    tempOrderDetails.OrderID = orderID;
                    tempOrderDetails.ProductID = 0;
                    tempOrderDetails.CategoryLevel = 0;
                    tempOrderDetails.OrderRemarks = CKeyBoardForm.Content;
                    tempOrderDetails.Product_Name = CKeyBoardForm.Content;
                    tempOrderDetails.OrderQuantity = Int32.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString());
                    tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity*price;
                    tempOrderDetails.VatTotal = (addmisvat*tempOrderDetails.OrderAmount)/100.0;
                    tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal;
                    tempOrderDetails.OrderFoodType = "Food";
                    tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks;

                    tempDataGridView.Rows[tempRowIndex].Cells[2].Value = tempOrderDetails.VatTotal.ToString("F02");
                    tempDataGridView.Rows[tempRowIndex].Cells[3].Value = tempOrderDetails.OrderAmount.ToString("F02");

                    tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                }
                else
                {
                    //Insert into Order_details table
                    tempOrderDetails.OrderID = orderID;
                    tempOrderDetails.ProductID = 0;
                    tempOrderDetails.CategoryLevel = 0;
                    tempOrderDetails.OrderRemarks = CKeyBoardForm.Content;
                    tempOrderDetails.Product_Name = CKeyBoardForm.Content;
                    tempOrderDetails.OrderQuantity = m_iSavedOrderedQty;
                    tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks;
                    tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity*price;
                    tempOrderDetails.VatTotal = (addmisvat * tempOrderDetails.OrderAmount) / 100.0;
                    tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal;

                    if (CKeyBoardForm.m_foodType == true)
                    {
                        tempOrderDetails.OrderFoodType = "Food";
                    }
                    else
                    {
                        tempOrderDetails.OrderFoodType = "Nonfood";
                    }

                    if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
                    {
                        tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data;
                        string[] tempDataGridViewRow = new string[]
                                { CKeyBoardForm.Content,
                                  m_iSavedOrderedQty.ToString(),
                                  tempOrderDetails.VatTotal.ToString("F02"),
                                  tempOrderDetails.OrderAmount.ToString("F02"),
                                  "0",
                                  "0",
                                  Int64.MaxValue-1+"",
                                  tempOrderDetails.OrderDetailsID.ToString(),"0" //0 for printed item quantity
                                };
                        tempDataGridView.Rows.Add(tempDataGridViewRow);
                    }
                    else
                    {
                        tempOrderDetails.ItemName = CKeyBoardForm.Content;
                        tempOrderDetails = (COrderDetails)tempOrderManager.InsertOnlineOrderDetails(tempOrderDetails).Data;

                        string[] tempDataGridViewRow = new string[]
                                { CKeyBoardForm.Content,
                                  m_iSavedOrderedQty.ToString(),
                                   tempOrderDetails.VatTotal.ToString("F02"),
                                  tempOrderDetails.OrderAmount.ToString("F02"),
                                  "0",
                                  "0",
                                  tempOrderDetails.OnlineItemSequenceNumber.ToString(),
                                  tempOrderDetails.OrderDetailsID.ToString(),"0" //0 for printed item quantity
                                };
                        tempDataGridView.Rows.Add(tempDataGridViewRow);
                    }
                }

                if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //Rank is applicable only for local order only
                {
                    this.ConvertRank();
                }

                tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending);
                tempDataGridView.Update();
                TotalAmountCalculation();
                m_iSavedOrderedQty = 1;
                g_FoodDataGridView.ClearSelection();
                g_BeverageDataGridView.ClearSelection();
            }
            catch (Exception exp)
            {
                Console.Write(exp.Message);
            }
        }
Esempio n. 9
0
        private void g_MiscButton_Click(object sender, EventArgs e)
        {
            try
            {
                CKeyBoardForm tempKeyBoardForm = new CKeyBoardForm("Misc Item", "Enter Item Name or Description");
                tempKeyBoardForm.ShowDialog();

                if (CKeyBoardForm.Content.Equals("Cancel"))
                    return;

                if (CKeyBoardForm.Content.Equals(""))
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Item Name cannot be Empty");
                    tempMessageBox.ShowDialog();
                    return;
                }
                CPriceCalculatorForm tempCalculatorForm = new CPriceCalculatorForm("Misc Item", "Enter Price");
                tempCalculatorForm.ShowDialog();

                if (CPriceCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CPriceCalculatorForm.inputResult.Equals("0.000"))
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Price cannot be zero.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                NewOrder();

                COrderManager tempOrderManager = new COrderManager();
                COrderDetails tempOrderDetails = new COrderDetails();
                DataGridView tempDataGridView = g_FoodDataGridView;

                int tempResult = DataGridViewSearch(tempDataGridView, CKeyBoardForm.Content);
                if (tempResult != -1)
                {
                    //update Order_details table
                    int tempRowIndex = tempResult;
                    tempDataGridView.Rows[tempRowIndex].Cells[1].Value = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty;
                    tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString());
                    tempOrderDetails.OrderID = orderID;
                    tempOrderDetails.ProductID = 0;
                    tempOrderDetails.CategoryLevel = 0;
                    tempOrderDetails.OrderRemarks = CKeyBoardForm.Content;
                    tempOrderDetails.OrderQuantity = Int32.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString());
                    tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(CPriceCalculatorForm.inputResult);
                    tempOrderDetails.OrderFoodType = "Nonfood";
                    tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                }
                else
                {
                    //Insert into Order_details table
                    tempOrderDetails.OrderID = orderID;
                    tempOrderDetails.ProductID = 0;
                    tempOrderDetails.CategoryLevel = 0;
                    tempOrderDetails.OrderRemarks = CKeyBoardForm.Content;
                    tempOrderDetails.OrderQuantity = m_iSavedOrderedQty;
                    tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(CPriceCalculatorForm.inputResult);
                    tempOrderDetails.OrderFoodType = "Nonfood";
                    tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data;

                    string[] tempDataGridViewRow = new string[]
                                { CKeyBoardForm.Content,
                                  m_iSavedOrderedQty.ToString(),
                                  CPriceCalculatorForm.inputResult,
                                  "0",
                                  "0",
                                  (Int64.MaxValue-1)+"",
                                  tempOrderDetails.OrderDetailsID.ToString()
                                };

                    tempDataGridView.Rows.Add(tempDataGridViewRow);

                }
                ConvertRank();
                tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending);
                tempDataGridView.Update();
                TotalAmountCalculation();
                m_iSavedOrderedQty = 1;
                g_FoodDataGridView.ClearSelection();
            }
            catch (Exception eee)
            {
            }
        }
Esempio n. 10
0
        private void g_OpenTabsButton_Click(object sender, EventArgs e)
        {
            try
            {
                COrderManager tempOrderManager = new COrderManager();
                List<COrderShow> tempOrderShowList = (List<COrderShow>)tempOrderManager.OrderListShowByStatus("Paid").Data;

                CKeyBoardForm tempKeyboardForm = new CKeyBoardForm("Tabs Information", "Enter Customer Name");
                tempKeyboardForm.ShowDialog();

                if (CKeyBoardForm.Content.Equals("Cancel") || CKeyBoardForm.Content.Equals(""))
                    return;

                string tabsName = CKeyBoardForm.Content;

                CCalculatorForm tableGuestForm = new CCalculatorForm("Tabs Information", "Guest Quantity");
                tableGuestForm.ShowDialog();

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                    tempMessageBox.ShowDialog();
                    return;
                }

                string tableGuest = "";
                tableGuest = CCalculatorForm.inputResult;

                NewOrder();
                CResult oResult=tempOrderManager.OrderInfoByOrderID(orderID);
                COrderInfo tempOrderInfo = new COrderInfo();
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderInfo = (COrderInfo)oResult.Data;
                }
                tempOrderInfo.GuestCount = int.Parse(tableGuest);
                tempOrderInfo.TableName = tabsName;
                tempOrderManager.UpdateOrderInfo(tempOrderInfo);
            }
            catch (Exception eee)
            {
            }
        }
Esempio n. 11
0
        private void g_ConvertButton_Click(object sender, EventArgs e)
        {
            try
            {
                COrderManager tempOrderManager = new COrderManager();
                CResult oResult = tempOrderManager.OrderListShowByStatus("Paid");
                List<COrderShow> tempOrderShowList= new List<COrderShow>();
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderShowList = (List<COrderShow>)oResult.Data;
                }

                CCalculatorForm tableNumberForm = new CCalculatorForm("Table Information", "Table Number");
                tableNumberForm.ShowDialog();

                string tableNumber = "";

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                    tempMessageBox.ShowDialog();
                    return;
                }

                tableNumber = CCalculatorForm.inputResult;

                //check whether table already exists
                bool found = false;
                for (int orderCounter = 0; orderCounter < tempOrderShowList.Count; orderCounter++)
                {
                    if (int.Parse(tableNumber) == tempOrderShowList[orderCounter].TableNumber && tempOrderShowList[orderCounter].OrderType.Equals("Table"))
                        found = true;
                }
                if (found)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Table already opened. Please select another table number.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                CCalculatorForm tableGuestForm = new CCalculatorForm("Table Information", "Guest Quantity");
                tableGuestForm.ShowDialog();

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                    tempMessageBox.ShowDialog();
                    return;
                }

                string tableGuest = "";
                tableGuest = CCalculatorForm.inputResult;

                //update order info table

                COrderInfo tempOrderInfo = new COrderInfo();
                oResult = tempOrderManager.OrderInfoByOrderID(orderID);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderInfo = (COrderInfo)oResult.Data;
                }

                //delete previous tab number from table info
                if(tempOrderInfo.TableNumber!=0)
                    tempOrderManager.DeleteTableInfo(tempOrderInfo.TableNumber, "Tabs");

                //update order info
                tempOrderInfo.GuestCount = int.Parse(tableGuest);
                tempOrderInfo.Status = "Seated";
                tempOrderInfo.OrderType = "Table";
                tempOrderInfo.TableNumber = int.Parse(tableNumber);
                tempOrderInfo.TableName = "";
                tempOrderManager.UpdateOrderInfo(tempOrderInfo);

                //insert new table number in table info
                CTableInfo tempTableInfo = new CTableInfo();
                tempTableInfo.TableNumber = tempOrderInfo.TableNumber;
                tempTableInfo.TableType = "Table";
                tempOrderManager.InsertTableInfo(tempTableInfo);

                CMainForm tempMainForm = (CMainForm)CFormManager.Forms.Pop();
                tempMainForm.Show();
                this.Close();
            }
            catch (Exception eee)
            {
                //MessageBox.Show(eee.ToString());
            }
        }
Esempio n. 12
0
        private void tipsfunctionalButton_Click(object sender, EventArgs e)
        {
            CPriceCalculatorForm tempCalculatorForm = new CPriceCalculatorForm("Misc Item", "Enter Price");
            tempCalculatorForm.ShowDialog();

            if (CPriceCalculatorForm.inputResult.Equals("Cancel"))
                return;

            if (CPriceCalculatorForm.inputResult.Equals("0.000"))
            {
                CMessageBox tempMessageBox = new CMessageBox("Error!", "Price cannot be zero.");
                tempMessageBox.ShowDialog();
                return;
            }
            Double totalpayable = Double.Parse(g_BillTotalLabel.Text.Substring(Program.currency.Length));
            totalpayable = totalpayable - tipsamount;
            double price = Double.Parse(CPriceCalculatorForm.inputResult);
            tipsamount = price;

            totalpayable = totalpayable + price;
            m_dBalance = totalpayable;
            g_BillTotalLabel.Text = Program.currency + totalpayable.ToString("F02");
            g_BalaceLabel.Text = String.Format("Balace Due {0}" + (totalpayable.ToString("F02")), Program.currency);
        }
Esempio n. 13
0
        private void g_UseDepositButton_Click(object sender, EventArgs e)
        {
            CCalculatorForm tempCalculatorForm = new CCalculatorForm("Use Deposit", "Enter Deposit Serial Number");
            tempCalculatorForm.ShowDialog();

            if (CCalculatorForm.inputResult.Equals("Cancel") || CCalculatorForm.inputResult.Equals(""))
            {
                return;
            }
            Int64 tempDepositSerial = Int64.Parse(CCalculatorForm.inputResult);
            CDepositManager tempDepositManager = new CDepositManager();
            CDeposit tempDeposit = new CDeposit();
            CResult oResult = tempDepositManager.DepositGetByDepositID(tempDepositSerial);
            if (oResult.IsSuccess && oResult.Data != null)
            {
                tempDeposit = (CDeposit)oResult.Data;

                if (tempDeposit.DepositID != 0)
                {

                    CUseDepositForm tempUseDepositForm = new CUseDepositForm(tempDeposit);
                    DialogResult dResult = tempUseDepositForm.ShowDialog();
                    if (dResult.Equals(DialogResult.Cancel))
                        return;
                    else if (dResult.Equals(DialogResult.OK))
                    {
                        if (CUseDepositForm.usedAmount > m_dBalance)
                        {
                            tempDeposit.DepositBalance = tempDeposit.DepositBalance - m_dBalance;
                        }
                        else
                        {
                            tempDeposit.DepositBalance = tempDeposit.DepositBalance - CUseDepositForm.usedAmount;
                        }
                        m_oDeposit = tempDeposit;

                        if (CUseDepositForm.usedAmount > m_dBalance)
                        {
                            m_dTotalAmount = m_dTotalAmount - m_dBalance;
                        }
                        else
                        {
                            m_dTotalAmount = m_dTotalAmount - CUseDepositForm.usedAmount;
                        }
                        g_BillTotalLabel.Text = "£" + m_dTotalAmount.ToString("F02");

                        g_DepositUsedLabel.Text = "£" + CUseDepositForm.usedAmount.ToString("F02");
                        CurrentPaymentMethod = "Deposit";
                        UpdateCalculation(0);
                        g_UseDepositButton.Enabled = false;
                    }
                }
                else
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Deposit Information not found!");
                    tempMessageBox.ShowDialog();
                }
            }
        }
Esempio n. 14
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;
        }
Esempio n. 15
0
        private void g_QuantityButton_Click(object sender, EventArgs e)
        {
            CCalculatorForm tempCalculatorForm = new CCalculatorForm("Order Quantity", "Item Quantity");
            tempCalculatorForm.ShowDialog();

            if (CCalculatorForm.inputResult.Equals("Cancel"))
                return;

            if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
            {
                CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                tempMessageBox.ShowDialog();
                return;
            }

            int tempOrderedQty = Int32.Parse(CCalculatorForm.inputResult);
            m_iSavedOrderedQty = tempOrderedQty;
        }
Esempio n. 16
0
        private void functionalButton1_Click(object sender, EventArgs e)
        {
            try
            {
                COrderManager tempOrderManager = new COrderManager();
                CResult oResult = tempOrderManager.OrderInfoByOrderID(orderID);
                COrderInfo tempOrderInfo = new COrderInfo();
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderInfo = (COrderInfo)oResult.Data;
                }
                List<COrderShow> tempOrderShowList = new List<COrderShow>();
                oResult = tempOrderManager.OrderListShowByStatus("Paid");
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderShowList = (List<COrderShow>)oResult.Data;
                }

                if (tempOrderInfo.OrderType.Equals("Table"))
                {
                    tempOrderManager.DeleteTableInfo(tempOrderInfo.TableNumber, "Table");

                    CTakeAwayForm tempTakeAway = new CTakeAwayForm(orderID);
                    tempTakeAway.Show();
                    CFormManager.Forms.Push(this);
                    this.Hide();
                }
                else if (tempOrderInfo.OrderType.Equals("TakeAway"))
                {
                    CCalculatorForm tableNumberForm = new CCalculatorForm("Table Information", "Table Number");
                    tableNumberForm.ShowDialog();

                    if (CCalculatorForm.inputResult.Equals("Cancel"))
                        return;
                    if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                    {
                        CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                        tempMessageBox.ShowDialog();
                        return;
                    }
                    string tableNumber = "";
                    tableNumber = CCalculatorForm.inputResult;

                    bool found = false;
                    for (int counter = 0; counter < tempOrderShowList.Count; counter++)
                    {
                        if (int.Parse(tableNumber) == tempOrderShowList[counter].TableNumber && tempOrderShowList[counter].OrderType.Equals("Table"))
                            found = true;
                    }
                    if (found)
                    {
                        CMessageBox tempMessageBox = new CMessageBox("Error", "Table already opened. Please select another table number.");
                        tempMessageBox.ShowDialog();
                        return;
                    }

                    CCalculatorForm tableGuestForm = new CCalculatorForm("Table Information", "Guest Quantity");
                    tableGuestForm.ShowDialog();

                    if (CCalculatorForm.inputResult.Equals("Cancel"))
                        return;
                    if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                    {
                        CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                        tempMessageBox.ShowDialog();
                        return;
                    }

                    string tableGuest = "";
                    tableGuest = CCalculatorForm.inputResult;

                    tempOrderManager.DeleteTableInfo(tempOrderInfo.TableNumber, "TakeAway");

                    tempOrderInfo.OrderType = "Table";
                    tempOrderInfo.Status = "Seated";
                    tempOrderInfo.TableNumber = int.Parse(tableNumber);
                    //tempOrderInfo.TableName = "Table " + tableNumber;
                    tempOrderInfo.GuestCount = int.Parse(tableGuest);

                    CTableInfo tempTableInfo = new CTableInfo();
                    tempTableInfo.TableNumber = tempOrderInfo.TableNumber;
                    tempTableInfo.TableType = "Table";
                    tempOrderManager.InsertTableInfo(tempTableInfo);
                    ////g_ConvertButton.Text = "Convert to Take Away";

                    tempOrderManager.UpdateOrderInfo(tempOrderInfo);
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 17
0
        private void g_RemoveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_iDataGridViewCurrentRowIndex == -1)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                COrderManager tempOrderManager = new COrderManager();
                int qty = Int32.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString());
                Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString());
                Double unitPrice = amount / qty;
                if (qty == 1)
                {
                    tempOrderManager.DeleteOrderDetails(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString()));
                    m_dDataGridView.Rows.RemoveAt(m_iDataGridViewCurrentRowIndex);
                }
                else
                {
                    qty = qty - 1;

                    COrderDetails tempOrderDetails = new COrderDetails();
                    CResult oResult = tempOrderManager.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString()));
                    if (oResult.IsSuccess && oResult.Data != null)
                    {
                        tempOrderDetails = (COrderDetails)oResult.Data;
                    }
                    tempOrderDetails.OrderQuantity = qty;
                    tempOrderDetails.OrderAmount = qty * unitPrice;
                    tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                    m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = qty;
                    m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = ((double)(qty * unitPrice)).ToString("F02");
                }

                m_dDataGridView.Update();
                TotalAmountCalculation();
                m_dDataGridView.ClearSelection();
            }
            catch (Exception eee)
            {
            }
        }
Esempio n. 18
0
        private void g_QuantityButton_Click(object sender, EventArgs e)
        {
            try
            {
                CCalculatorForm tempCalculatorForm = new CCalculatorForm("Order Quantity", "Item Quantity");
                tempCalculatorForm.ShowDialog();

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                    tempMessageBox.ShowDialog();
                    return;
                }

                int tempOrderedQty = Int32.Parse(CCalculatorForm.inputResult);
                m_iSavedOrderedQty = tempOrderedQty;
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 19
0
        private void btnPLU_Click(object sender, EventArgs e)
        {
            COrderManager objOrderManager = new COrderManager();
            this.NewOrder();
            //////Start
            //PLUPopup objPLUPopup = new PLUPopup();
            int priceTakeType;
            Int32 productPLU = 0;
            int returnVal = 0;
            Int32 productQuantity = 0;

            priceTakeType = -99;
            //objPLUPopup.ShowDialog(this);

            //if (PLUPopup.m_productCode == "Cancel")
            //{
            //    return;
            //}

            //productPLU = Convert.ToInt32("0" + PLUPopup.m_productCode);

            CCalculatorForm tableNumberForm = new CCalculatorForm("Product PLU Information", "PLU of the Product");
            tableNumberForm.ShowDialog();

            if (CCalculatorForm.inputResult.Equals("Cancel"))
                return;

            if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
            {
                CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                tempMessageBox.ShowDialog();
                return;
            }

            productPLU = Convert.ToInt32("0" + CCalculatorForm.inputResult);

            CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU);
            if (Convert.ToString(objProductName.Data) == "NO")
            {
                CMessageBox tempMessageBox = new CMessageBox("Error", "Invalid PLU.Please enter valid PLU");
                tempMessageBox.ShowDialog();
                return;
            }

            ProductQuantityForm quantityForm = new ProductQuantityForm(Convert.ToString(objProductName.Data));
            quantityForm.ShowDialog();

            if (ProductQuantityForm.m_productQuantity.Equals("Cancel"))
            {
                return;
            }
            if (ProductQuantityForm.m_productQuantity.Equals("") || Int32.Parse(ProductQuantityForm.m_productQuantity) == 0)
            {
                CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                tempMessageBox.ShowDialog();
                return;
            }

            productQuantity = Convert.ToInt32("0" + ProductQuantityForm.m_productQuantity);

            CResult oResult = objOrderManager.GetPluDataByProductPLU(productPLU, priceTakeType, orderID, productQuantity);

            if (oResult.IsSuccess && oResult.Data != null)
            {
                returnVal = int.Parse(oResult.Data.ToString());
            }

            if (returnVal == 0)
            {
                MessageBox.Show("Please enter valid plu product", RMSGlobal.MessageBoxTitle,
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            ///End new
            this.FillNonFoods();

            btnPLU_Click(sender, e);
        }
Esempio n. 20
0
        private void g_SeatButton_Click(object sender, EventArgs e)
        {
            if (m_iDataGridViewCurrentRowIndex == -1)
            {
                CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage.");
                tempMessageBox.ShowDialog();
                return;
            }

            if (m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value == null || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value == null || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value == "" || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString() == "" || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString().Length < 1 || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString().Length < 1)
            {
                return;
            }
            try
            {
                if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //If local order is considered
                {
                    COrderDetails objOrderDetails = new COrderDetails();
                    Int64 itemSequenceNumber = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value);
                    int quantity = Convert.ToInt32("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value);
                    double vat = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value);
                    double amount = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value);

                    //
                    double vateRate = vat / quantity;
                    double totalVat = (vateRate) * (quantity + 1);
                    objOrderDetails.VatTotal = totalVat;
                    amount = (amount / quantity) * (quantity + 1); //Calculate the total amount
                    quantity++; //Increasing the quantity of items
                    Int64 productID = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[4].Value);

                    objOrderDetails.ProductID = productID;
                    objOrderDetails.OrderAmount = amount;
                    objOrderDetails.OrderQuantity = quantity;
                    objOrderDetails.OrderID = orderID;
                    objOrderDetails.Amount_with_vat = objOrderDetails.OrderAmount + objOrderDetails.VatTotal;
                    objOrderDetails.OrderDetailsID = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value);
                    COrderManager objOrderManager = new COrderManager();
                    objOrderManager.AddNewLocalProducts(objOrderDetails); //Increasing Items's quantity for local orders
                    m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = quantity;
                    m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = totalVat.ToString("F02");
                    m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value = amount.ToString("F02");

                }
                else
                {
                    COrderDetails objOrderDetails = new COrderDetails();
                    Int64 itemSequenceNumber = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value);
                    int quantity = Convert.ToInt32("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value);
                    double vat = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value);
                    double amount = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value);
                    double vateRate = amount / quantity;
                    double totalVat = (vateRate) * (quantity + 1);
                    objOrderDetails.VatTotal = totalVat;
                    amount = (amount / quantity) * (quantity + 1); //Calculate the total amount
                    quantity++; //Increasing the quantity of items

                    objOrderDetails.OnlineItemSequenceNumber = itemSequenceNumber;
                    objOrderDetails.OrderAmount = amount;
                    objOrderDetails.OrderQuantity = quantity;
                    objOrderDetails.OrderDetailsID = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value);
                    COrderManager objOrderManager = new COrderManager();
                    objOrderManager.AddNewOnlineProducts(objOrderDetails);
                    m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = quantity;
                    m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = totalVat.ToString("F02");
                    m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value = amount.ToString("F02");
                }

                m_dDataGridView.Update();
                TotalAmountCalculation();
                m_dDataGridView.ClearSelection();
            }
            catch (Exception exp)
            {
                throw exp;
            }
            this.SetPrintedItemBackColor(); //set the back color
        }
Esempio n. 21
0
        private void btnReorder_Click(object sender, EventArgs e)
        {
            if (m_iDataGridViewCurrentRowIndex == -1)
            {
                CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage.");
                tempMessageBox.ShowDialog();
                return;
            }

            if (m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value == null || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString() == String.Empty)
            {
                return;
            }

            COrderDetails objOrderDetails = new COrderDetails();
            Int64 itemSequenceNumber = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value);
            int quantity = Convert.ToInt32("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value);
            double amount = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value);
            amount = (amount / quantity) * (quantity + 1); //Calculate the total amount
            quantity++; //Increasing the quantity of items
            Int64 productID = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value);

            objOrderDetails.ProductID = productID;
            objOrderDetails.OrderAmount = amount;
            objOrderDetails.OrderQuantity = quantity;
            objOrderDetails.OrderID = orderID;
            COrderManager objOrderManager = new COrderManager();
            objOrderManager.AddNewLocalProducts(objOrderDetails); //Increasing Items's quantity for local orders
            m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = quantity;
            m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = amount.ToString("F02");

            m_dDataGridView.Update();
            TotalAmountCalculation();
            m_dDataGridView.ClearSelection();
        }
Esempio n. 22
0
        //private void btnPLU_Click(object sender, EventArgs e)
        //{
        //    int priceTakeType;
        //    Int32 productPLU = 0;
        //    int returnVal = 0;
        //    Int32 productQuantity = 0;
        //    COrderManager objOrderManager = new COrderManager();
        //    if (m_iType == m_cCommonConstants.TableType)
        //    {
        //        priceTakeType = 1;
        //    }
        //    else if (m_iType == m_cCommonConstants.TakeAwayType)
        //    {
        //        priceTakeType = 2;
        //    }
        //    else
        //    {
        //        priceTakeType = 3;
        //    }
        //    CCalculatorForm tableNumberForm = new CCalculatorForm("Product PLU Information", "PLU of the Product");
        //    tableNumberForm.ShowDialog();
        //    if (CCalculatorForm.inputResult.Equals("Cancel"))
        //        return;
        //    if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
        //    {
        //        CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
        //        tempMessageBox.ShowDialog();
        //        return;
        //    }
        //    productPLU = Convert.ToInt32("0" + CCalculatorForm.inputResult);
        //    CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU);
        //    if (Convert.ToString(objProductName.Data) == "NO")
        //    {
        //        CMessageBox tempMessageBox = new CMessageBox("Error", "Invalid PLU.Please enter valid PLU");
        //        tempMessageBox.ShowDialog();
        //        return;
        //    }
        //    ProductQuantityForm quantityForm = new ProductQuantityForm(Convert.ToString(objProductName.Data));
        //    quantityForm.ShowDialog();
        //    if (ProductQuantityForm.m_productQuantity.Equals("Cancel"))
        //    {
        //        return;
        //    }
        //    if (ProductQuantityForm.m_productQuantity.Equals("") || Int32.Parse(ProductQuantityForm.m_productQuantity) == 0)
        //    {
        //        CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
        //        tempMessageBox.ShowDialog();
        //        return;
        //    }
        //    productQuantity = Convert.ToInt32("0" + ProductQuantityForm.m_productQuantity);
        //    CResult oResult = objOrderManager.GetPluDataByProductPLU(productPLU, priceTakeType, orderID, productQuantity);
        //    if (oResult.IsSuccess && oResult.Data != null)
        //    {
        //        returnVal = int.Parse(oResult.Data.ToString());
        //        //for vat includr option
        //        String queryStr = SqlQueries.GetQuery(Query.LastPLUOrderDetails);
        //        CDalConfig oTempDal = ConfigManager.GetConfig<CDalConfig>();
        //        String tempConnStr = oTempDal.ConnectionString;
        //        // Create a new data adapter based on the specified query.
        //        SqlDataAdapter dataAdapter = new SqlDataAdapter(queryStr, tempConnStr);
        //        // Populate a new data table and bind it to the BindingSource.
        //        DataTable table = new DataTable();
        //        //table.Locale = System.Globalization.CultureInfo.InvariantCulture;
        //        dataAdapter.Fill(table);
        //        int CategoryID = Convert.ToInt32(table.Rows[0]["product_id"].ToString());
        //        Double amount = Convert.ToDouble(table.Rows[0]["amount"].ToString());
        //        int catLavel=Convert.ToInt32(table.Rows[0]["cat_level"].ToString());
        //        //vat in cat Three
        //        double vatRate = 0;
        //        bool vat_included = false;
        //        double vatAmountRate = 0;
        //        if(catLavel==3)
        //        {
        //        DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + CategoryID.ToString());
        //        vatRate = 0;
        //        vat_included = false;
        //        vatAmountRate = 0;
        //        try
        //        {
        //            vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString());
        //            vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString());
        //            if (vat_included)
        //            {
        //                vatAmountRate = (amount * vatRate) / 100;
        //                // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString();
        //                // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString();
        //            }
        //            else
        //            {
        //                vatAmountRate = 0.00;
        //            }
        //        }
        //        catch (Exception ex) { }
        //        }
        //        if(catLavel==4)
        //        {
        //            DataRow[] temp3DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + CategoryID);
        //        vatRate = 0;
        //        vat_included = false;
        //        vatAmountRate = 0;
        //        try
        //        {
        //            vatRate = Convert.ToDouble(temp3DataRowArray[0]["vat_Rate"].ToString());
        //            vat_included = Convert.ToBoolean(temp3DataRowArray[0]["vat_included"].ToString());
        //            if (vat_included)
        //            {
        //                vatAmountRate = (amount * vatRate) / 100;
        //                // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString();
        //                // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString();
        //            }
        //            else
        //            {
        //                vatAmountRate = 0.00;
        //            }
        //        }
        //        catch (Exception ex) { }
        //        }
        //        //string tableTypePrice = string.Empty;
        //        //if (m_iType == m_cCommonConstants.TableType)
        //        //{
        //        //    tableTypePrice = temp2DataRowArray[0]["table_price"].ToString();
        //        //}
        //        //else if (m_iType == m_cCommonConstants.TakeAwayType)
        //        //{
        //        //    tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString();
        //        //}
        //        COrderManager tempOrderManager = new COrderManager();
        //        COrderDetails tempOrderDetails = new COrderDetails();
        //        if (returnVal == 1)
        //        {
        //            //update Order_details table
        //            //int tempRowIndex = tempResult;
        //            //int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty;
        //            //tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty;
        //            //tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02");
        //            tempOrderDetails.OrderDetailsID = Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString());
        //            tempOrderDetails.OrderID =Convert.ToInt32(table.Rows[0]["order_id"].ToString());
        //            tempOrderDetails.ProductID =Convert.ToInt32( table.Rows[0]["product_id"].ToString());
        //            tempOrderDetails.CategoryLevel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString());
        //            tempOrderDetails.UnitPrice = 0.00;
        //            tempOrderDetails.OrderQuantity = Convert.ToInt32(table.Rows[0]["quantity"].ToString());
        //            tempOrderDetails.OrderAmount = Convert.ToDouble(table.Rows[0]["amount"].ToString());
        //            tempOrderDetails.OrderFoodType = table.Rows[0]["food_type"].ToString();
        //           // tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[5].Value.ToString());
        //           // tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString());
        //            if (vat_included)
        //            {
        //                tempOrderDetails.VatTotal = vatAmountRate;
        //            }
        //            else
        //            {
        //                tempOrderDetails.VatTotal = 0.00;
        //            }
        //            //if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
        //            //{
        //            //    tempOrderManager.UpdateOrderDetails(tempOrderDetails);
        //            //}
        //            //else
        //            //{
        //            //    tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails);
        //            //}
        //            try
        //            {
        //                tempOrderManager.UpdateOrderDetails(tempOrderDetails);
        //            }
        //            catch { }
        //        }
        //        //tempOrderDetails.VatTotal = vatAmountRate;
        //        //tempOrderDetails.OrderDetailsID =Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString());
        //        //try
        //        //{
        //        //tempOrderManager.UpdateOrderDetails(tempOrderDetails);
        //        //}
        //        //catch { }
        //    }
        //    if (returnVal == 0)
        //    {
        //        MessageBox.Show("Please enter valid plu product", RMSGlobal.MessageBoxTitle,
        //            MessageBoxButtons.OK, MessageBoxIcon.Information);
        //    }
        //    else
        //    {
        //        COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO();
        //        orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType);
        //    }
        //    this.LoadOrderDetails();
        //    btnPLU_Click(sender, e);
        //}
        private void btnPLU_Click(object sender, EventArgs e)
        {
            int priceTakeType;
            Int32 productPLU = 0;
            int returnVal = 0;
            Int32 productQuantity = 0;
            COrderManager objOrderManager = new COrderManager();

            if (m_iType == m_cCommonConstants.TableType)
            {
                priceTakeType = 1;
            }
            else if (m_iType == m_cCommonConstants.TakeAwayType)
            {
                priceTakeType = 2;
            }
            else
            {
                priceTakeType = 3;
            }

            CCalculatorForm tableNumberForm = new CCalculatorForm("Product PLU Information", "PLU of the Product");
            tableNumberForm.ShowDialog();

            if (CCalculatorForm.inputResult.Equals("Cancel"))
                return;

            if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
            {
                CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                tempMessageBox.ShowDialog();
                return;
            }

            productPLU = Convert.ToInt32("0" + CCalculatorForm.inputResult);

            // Add for find updating order_detail
            int id = productPLU;
            long order = orderID;
            COrderDetailsDAO aDao = new COrderDetailsDAO();
            List<COrderDetails> aList = aDao.OrderDetailsGetAll();

            //  CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU, priceTakeType);
            CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU);

            var check = (from orderdetail in aList
                         where (orderdetail.OrderID == orderID && orderdetail.ProductID == objProductName.Productid)
                         select orderdetail);

            if (Convert.ToString(objProductName.Data) == "NO")
            {
                CMessageBox tempMessageBox = new CMessageBox("Error", "Invalid PLU.Please enter valid PLU");
                tempMessageBox.ShowDialog();
                return;
            }

            ProductQuantityForm quantityForm = new ProductQuantityForm(Convert.ToString(objProductName.Data));
            quantityForm.ShowDialog();

            if (ProductQuantityForm.m_productQuantity.Equals("Cancel"))
            {
                return;
            }
            if (ProductQuantityForm.m_productQuantity.Equals("") || Int32.Parse(ProductQuantityForm.m_productQuantity) == 0)
            {
                CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                tempMessageBox.ShowDialog();
                return;
            }

            productQuantity = Convert.ToInt32("0" + ProductQuantityForm.m_productQuantity);

            // Add for updating order_detail when orderwith same product
            if (check.Count() == 1)
            {

                COrderDetails aOrderDetails = new COrderDetails();
                aOrderDetails = check.Single();
                //double vat = aOrderDetails.Amount_with_vat - aOrderDetails.OrderAmount;
                //vat = (vat * 100) / aOrderDetails.OrderAmount;
                productQuantity += aOrderDetails.OrderQuantity;
                aOrderDetails.OrderQuantity = productQuantity;
                aOrderDetails.OrderAmount = aOrderDetails.UnitPrice * productQuantity;
                aOrderDetails.PrintedQuantity = aOrderDetails.PrintedQuantity;
                aOrderDetails.VatTotal = (objProductName.VateRate * aOrderDetails.OrderAmount) / 100.0;
                aOrderDetails.Amount_with_vat = aOrderDetails.OrderAmount + aOrderDetails.VatTotal;

                COrderDetailsDAO aCOrderDetailsDao = new COrderDetailsDAO();
                aCOrderDetailsDao.OrderDetailsUpdate(aOrderDetails);

                //COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO();
                //orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType);

            }

            if (check.Count() == 0)
            {
                CResult oResult = objOrderManager.GetPluDataByProductPLU(productPLU, priceTakeType, orderID,
                                                                         productQuantity);

                if (oResult.IsSuccess && oResult.Data != null)
                {
                    returnVal = int.Parse(oResult.Data.ToString());

                    //for vat includr option

                    String queryStr = SqlQueries.GetQuery(Query.LastPLUOrderDetails);
                    CDalConfig oTempDal = ConfigManager.GetConfig<CDalConfig>();
                    String tempConnStr = oTempDal.ConnectionString;
                    // Create a new data adapter based on the specified query.
                    SqlDataAdapter dataAdapter = new SqlDataAdapter(queryStr, tempConnStr);
                    // Populate a new data table and bind it to the BindingSource.
                    DataTable table = new DataTable();
                    //table.Locale = System.Globalization.CultureInfo.InvariantCulture;
                    dataAdapter.Fill(table);

                    int CategoryID = Convert.ToInt32(table.Rows[0]["product_id"].ToString());
                    Double amount = Convert.ToDouble(table.Rows[0]["amount"].ToString());

                    int catLavel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString());
                    //vat in cat Three

                    double vatRate = 0;
                    bool vat_included = false;
                    double vatAmountRate = 0;
                    if (catLavel == 3)
                    {
                        DataRow[] temp2DataRowArray =
                            Program.initDataSet.Tables["Category3"].Select("cat3_id = " + CategoryID.ToString());

                        vatRate = 0;
                        vat_included = false;
                        vatAmountRate = 0;
                        try
                        {
                            vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString());
                            vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString());

                            if (vat_included)
                            {
                                vatAmountRate = (amount * vatRate) / 100;

                                // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString();
                                // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString();
                            }
                            else
                            {
                                vatAmountRate = 0.00;
                            }

                        }
                        catch (Exception ex)
                        {
                        }

                    }

                    if (catLavel == 4)
                    {
                        DataRow[] temp3DataRowArray =
                            Program.initDataSet.Tables["Category4"].Select("cat4_id = " + CategoryID);

                        vatRate = 0;
                        vat_included = false;
                        vatAmountRate = 0;
                        try
                        {
                            vatRate = Convert.ToDouble(temp3DataRowArray[0]["vat_Rate"].ToString());
                            vat_included = Convert.ToBoolean(temp3DataRowArray[0]["vat_included"].ToString());

                            if (vat_included)
                            {
                                vatAmountRate = (amount * vatRate) / 100;

                                // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString();
                                // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString();
                            }
                            else
                            {
                                vatAmountRate = 0.00;
                            }

                        }
                        catch (Exception ex)
                        {
                        }

                    }

                    //string tableTypePrice = string.Empty;
                    //if (m_iType == m_cCommonConstants.TableType)
                    //{
                    //    tableTypePrice = temp2DataRowArray[0]["table_price"].ToString();
                    //}
                    //else if (m_iType == m_cCommonConstants.TakeAwayType)
                    //{
                    //    tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString();
                    //}

                    COrderManager tempOrderManager = new COrderManager();
                    COrderDetails tempOrderDetails = new COrderDetails();

                    if (returnVal == 1)
                    {
                        //update Order_details table
                        //int tempRowIndex = tempResult;
                        //int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty;
                        //tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty;
                        //tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02");
                        tempOrderDetails.OrderDetailsID = Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString());
                        tempOrderDetails.OrderID = Convert.ToInt32(table.Rows[0]["order_id"].ToString());
                        tempOrderDetails.ProductID = Convert.ToInt32(table.Rows[0]["product_id"].ToString());
                        tempOrderDetails.CategoryLevel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString());
                        tempOrderDetails.UnitPrice = 0.00;
                        tempOrderDetails.OrderQuantity = Convert.ToInt32(table.Rows[0]["quantity"].ToString());
                        tempOrderDetails.OrderAmount = Convert.ToDouble(table.Rows[0]["amount"].ToString());
                        tempOrderDetails.OrderFoodType = table.Rows[0]["food_type"].ToString();
                        // tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[5].Value.ToString());
                        // tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString());
                        if (vat_included)
                        {
                            tempOrderDetails.VatTotal = vatAmountRate;
                        }
                        else
                        {
                            tempOrderDetails.VatTotal = 0.00;
                        }

                        //if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
                        //{
                        //    tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                        //}
                        //else
                        //{
                        //    tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails);
                        //}

                        try
                        {
                            tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal;
                            tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                        }
                        catch
                        {
                        }
                    }

                    //tempOrderDetails.VatTotal = vatAmountRate;
                    //tempOrderDetails.OrderDetailsID =Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString());
                    //try
                    //{
                    //tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                    //}
                    //catch { }

                }

                if (returnVal == 0)
                {
                    MessageBox.Show("Please enter valid plu product", RMSGlobal.MessageBoxTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO();
                    orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType);

                }
            }

            this.LoadOrderDetails();

            btnPLU_Click(sender, e);
        }
Esempio n. 23
0
        private void Category3Button_Click(object sender, EventArgs e)
        {
            try
            {
                CCategoryButton tempCategory3Button = (CCategoryButton)sender;
                int tempCategory3ID = tempCategory3Button.CategoryID;

                if (m_bItemDescriptionClicked)
                {
                    string tempItemDescription = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0]["description"].ToString();
                    CMessageBox tempMessageBox = new CMessageBox("Item Description", tempItemDescription);
                    tempMessageBox.ShowDialog();
                    m_bItemDescriptionClicked = false;
                    return;
                }

                int tempFoodType = int.Parse(Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0].GetParentRow(Program.initDataSet.Relations["category2_to_category3"])["cat2_type"].ToString());
                DataGridView tempDataGridView = new DataGridView();
                tempDataGridView = g_FoodDataGridView;

                DataRow[] tempDataRowArray = Program.initDataSet.Tables["Category4"].Select("cat3_id = " + tempCategory3ID.ToString());
                category4ButtonList.Clear();
                if (tempDataRowArray.Length != 0)
                {
                    foreach (DataRow tempDataRow in tempDataRowArray)
                    {
                        CCategoryButton tempCategoryButton = new CCategoryButton();
                        tempCategoryButton.CategoryID = int.Parse(tempDataRow["cat4_id"].ToString());
                        tempCategoryButton.CategoryOrder = int.Parse(tempDataRow["cat4_order"].ToString());
                        tempCategoryButton.CategoryLevel = 4;
                        tempCategoryButton.Text = tempDataRow["cat4_name"].ToString();
                        tempCategoryButton.BackColor = tempCategory3Button.BackColor;
                        category4ButtonList.Add(tempCategoryButton);
                    }

                    CCategory4Form tempCategory4Form = new CCategory4Form(tempCategory3ID, category4ButtonList, tempCategory3Button.Text);
                    tempCategory4Form.ShowDialog();
                    CCategoryButton tempCategory4Button = CCategory4Form.m_cbResult;
                    if (tempCategory4Button == null)
                        return;
                    else   //insert into table and datagridview
                    {
                        NewOrder();

                        DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempCategory4Button.CategoryID.ToString());
                        if (temp2DataRowArray.Length != 0)
                        {
                            //category4 + categpry3
                            string ItemName = temp2DataRowArray[0]["cat4_name"].ToString() + " " + tempCategory3Button.Text;
                            string tableTypePrice = string.Empty;
                            tableTypePrice = temp2DataRowArray[0]["bar_price"].ToString();
                            int tempSearchResult = DataGridViewSearch(tempDataGridView, ItemName);

                            COrderManager tempOrderManager = new COrderManager();
                            COrderDetails tempOrderDetails = new COrderDetails();

                            if (tempSearchResult != -1)
                            {
                                int tempRowIndex = tempSearchResult;
                                int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty;
                                tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty;
                                tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02");
                                //update Order_details table
                                tempOrderDetails.OrderID = orderID;
                                tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString());
                                tempOrderDetails.ProductID = tempCategory4Button.CategoryID;
                                tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel;
                                tempOrderDetails.OrderQuantity = qty;
                                tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice);
                                tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood");
                                tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks;
                                tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                            }
                            else
                            {
                                //Insert into Order_details table
                                tempOrderDetails.OrderID = orderID;
                                tempOrderDetails.ProductID = tempCategory4Button.CategoryID;
                                tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel;
                                tempOrderDetails.OrderQuantity = m_iSavedOrderedQty;
                                tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice);
                                tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks;
                                tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood");
                                CResult oResult = tempOrderManager.InsertOrderDetails(tempOrderDetails);
                                if (oResult.IsSuccess && oResult.Data != null)
                                {
                                    tempOrderDetails = (COrderDetails)oResult.Data;
                                }

                                string[] tempDataGridViewRow = new string[]
                                { ItemName,
                                  m_iSavedOrderedQty.ToString(),
                                  ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"),
                                  tempCategory4Button.CategoryID.ToString(),
                                  "4",
                                  temp2DataRowArray[0]["cat4_rank"].ToString(),
                                  tempOrderDetails.OrderDetailsID.ToString()
                                };

                                tempDataGridView.Rows.Add(tempDataGridViewRow);
                            }
                            ConvertRank();
                            tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending);
                            tempDataGridView.Update();
                            TotalAmountCalculation();
                        }
                    }
                }
                else //There is no category4
                {
                    NewOrder();
                    DataGridViewRow tempDataGridViewRow = new DataGridViewRow();
                    tempDataGridViewRow.CreateCells(tempDataGridView);

                    DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3Button.CategoryID.ToString());

                    if (temp2DataRowArray.Length != 0)
                    {
                        string tableTypePrice = string.Empty;
                        tableTypePrice = temp2DataRowArray[0]["bar_price"].ToString();

                        COrderManager tempOrderManager = new COrderManager();
                        COrderDetails tempOrderDetails = new COrderDetails();

                        int tempResult = DataGridViewSearch(tempDataGridView, temp2DataRowArray[0]["cat3_name"].ToString());
                        if (tempResult != -1)
                        {
                            //update Order_details table
                            int tempRowIndex = tempResult;
                            int qty=int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty;
                            tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty;
                            tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02");
                            tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString());
                            tempOrderDetails.OrderID = orderID;
                            tempOrderDetails.ProductID = tempCategory3Button.CategoryID;
                            tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel;
                            tempOrderDetails.OrderQuantity = qty;
                            tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice);
                            tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood");
                            tempOrderManager.UpdateOrderDetails(tempOrderDetails);
                        }
                        else
                        {
                            //Insert into Order_details table
                            tempOrderDetails.OrderID = orderID;
                            tempOrderDetails.ProductID = tempCategory3Button.CategoryID;
                            tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel;
                            tempOrderDetails.OrderQuantity = m_iSavedOrderedQty;
                            tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice);
                            tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood");
                            tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks;
                            CResult oResult = tempOrderManager.InsertOrderDetails(tempOrderDetails);
                            if (oResult.IsSuccess && oResult.Data != null)
                            {
                                tempOrderDetails = (COrderDetails)oResult.Data;
                            }

                            string[] temp2DataGridViewRow = new string[]
                                { temp2DataRowArray[0]["cat3_name"].ToString(),
                                  m_iSavedOrderedQty.ToString(),
                                  ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"),
                                  tempCategory3Button.CategoryID.ToString(),
                                  "3",
                                  temp2DataRowArray[0]["cat3_rank"].ToString(),
                                  tempOrderDetails.OrderDetailsID.ToString()
                                };

                            tempDataGridView.Rows.Add(temp2DataGridViewRow);
                        }
                        ConvertRank();
                        tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending);
                        tempDataGridView.Update();
                        TotalAmountCalculation();
                    }
                }
                m_iSavedOrderedQty = 1;
                g_FoodDataGridView.ClearSelection();
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Esempio n. 24
0
        private void duebillPaymentButton_Click(object sender, EventArgs e)
        {
            if (tempSearchOrderInfo.DueBill > 0)
            {

                DueBillPaymentForm aDueBillPaymentForm = new DueBillPaymentForm();
                aDueBillPaymentForm.ShowDialog();

                double amount = 0.0;

                if (DueBillPaymentForm.inputResult.Equals("Cancel"))
                    return;

                string amt = DueBillPaymentForm.inputResult.Substring(Program.currency.Length);

                if (Convert.ToDouble(amt) == 0.00)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error!", "Price cannot be zero.");
                    tempMessageBox.ShowDialog();
                    return;
                }
                amount = Convert.ToDouble(amt);

                string paymentmethod = "";
                string cardName = "";
                PaymentMethod aPaymentMethod = new PaymentMethod();
                aPaymentMethod.ShowDialog();
                paymentmethod = PaymentMethod.inputResult;

                if (paymentmethod == "Card")
                {
                    EFTOptionForm eFTOptionForm = new EFTOptionForm();

                    DialogResult dr = eFTOptionForm.ShowDialog();

                    if (dr == DialogResult.Cancel)
                        return;

                    saveEFTCardAgainsOrderid(EFTOptionForm.seletedEFTCard);
                }

                PaymentDueBill aPaymentDueBill = new PaymentDueBill();
                CPayment aPayment = new CPayment();
                aPayment.OrderID = orderID;

                double tempamount = 0;
                if (amount - tempSearchOrderInfo.DueBill >= 0)
                {
                    tempamount = tempSearchOrderInfo.DueBill;
                }
                else if (tempSearchOrderInfo.DueBill - amount > 0)
                {
                    tempamount = amount;
                }
                if (paymentmethod == "Cash")
                {
                    aPayment.CashAmount = tempamount;
                    aPayment.EFTAmount = 0;
                    aPaymentDueBill.CashAmount = tempamount;
                }

                else if (paymentmethod == "Card")
                {
                    aPayment.EFTAmount = tempamount;
                    aPayment.CashAmount = 0;
                    aPaymentDueBill.CardAmount = tempamount;

                }
                aPayment.ChequeAmount = tempSearchOrderInfo.DueBill - tempamount;
                aPaymentDueBill.PaymentDate = DateTime.Now;

                CPaymentDAO aPaymentDao = new CPaymentDAO();
                string sr = aPaymentDao.UpdatePaymentForDueBill(aPayment, aPaymentDueBill);
                MessageBox.Show(sr);
                this.Close();
            }
            else
            {
                MessageBox.Show("Due Bill Must be greater than zero");
            }
        }
Esempio n. 25
0
        private void g_CashButton_Click(object sender, EventArgs e)
        {
            try
            {
                Double tempTotal = Double.Parse(g_BalanceLabel.Text);
                Double tempInput = Double.Parse(g_InputTextBox.Text.Substring(1));
                if (tempTotal > tempInput)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Paid Amount less than Balance Amount.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                CPaymentManager tempPaymentManager = new CPaymentManager();

                ///insert into payment table
                CPayment tempPayment = new CPayment();
                tempPayment.OrderID = orderID;

                //get pc id from pc ip
                CPcInfoManager tempPcInfoManager = new CPcInfoManager();
                IPHostEntry ipEntry = System.Net.Dns.GetHostByName(Dns.GetHostName());
                CResult oResult = tempPcInfoManager.PcInfoByPcIP(ipEntry.AddressList[0].ToString());
                CPcInfo tempPcInfo = new CPcInfo();
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempPcInfo = (CPcInfo)oResult.Data;
                }

                tempPayment.PcID = tempPcInfo.PcID;
                tempPayment.TotalAmount = Double.Parse(g_BalanceLabel.Text);
                tempPayment.CashAmount = tempPayment.TotalAmount;
                tempPayment.PaymentTime = System.DateTime.Now;

                oResult = tempPaymentManager.InsertPayment(tempPayment);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempPayment = (CPayment)oResult.Data;
                }

                ////update order info status
                COrderManager tempOrderManager = new COrderManager();
                COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(orderID).Data;
                //tempOrderInfo.Status = "Paid";
                //tempOrderManager.UpdateOrderInfo(tempOrderInfo);

                //opening cash drawer
                try
                {
                    CPrintMethods tempPrintMethods = new CPrintMethods();
                    tempPrintMethods.OpenDrawer();
                }
                catch (Exception eee)
                {
                }

                //archiving
                tempOrderManager.InsertOrderArchive(tempOrderInfo);
                tempOrderManager.InsertOrderDetailsArchive(tempOrderInfo);
                tempOrderManager.DeleteTableInfo(tempOrderInfo.TableNumber, "Tabs");
                Reload();
            }
            catch (Exception eee)
            {
            }
        }
Esempio n. 26
0
        private void vatbutton_Click(object sender, EventArgs e)
        {
            Double MainFoodTotal = PartyReservation.MainGuestAmount + PartyReservation.OtherGuestAmount + PartyReservation.UtilityCostAmount;
            CPriceCalculatorForm tempCalculatorForm1 = new CPriceCalculatorForm("Reservation", "Enter vat");
            tempCalculatorForm1.ShowDialog();

            if (CPriceCalculatorForm.inputResult.Equals("Cancel"))
                return;

            if (CPriceCalculatorForm.inputResult.Equals("0.000"))
            {
                CMessageBox tempMessageBox = new CMessageBox("Error!", "Vat cannot be zero.");
                tempMessageBox.ShowDialog();
                return;
            }

            double reservationvatpercent = Double.Parse(CPriceCalculatorForm.inputResult);
            double vat = 0;
            vat = (reservationvatpercent*MainFoodTotal)/100;
            PartyReservation.Vat= vat;
            vatlabel.Text = vat.ToString("F02");
            LoadTotalPayable();
        }
Esempio n. 27
0
        private void NewTableButton_Click(object sender, EventArgs e)
        {
            try
            {
                COrderManager tempOrderManager = new COrderManager();
                List<COrderShow> tempOrderShowList = (List<COrderShow>)tempOrderManager.OrderListShowByStatus("Paid").Data;

                CCalculatorForm tableNumberForm = new CCalculatorForm("Table Information", "Table Number");
                tableNumberForm.ShowDialog();

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                    tempMessageBox.ShowDialog();
                    return;
                }

                string tableNumber = "";

                tableNumber = CCalculatorForm.inputResult;

                if (tableNumber.Equals(""))
                    return;

                bool found = false;
                for (int recordCounter = 0; recordCounter < tempOrderShowList.Count; recordCounter++)
                {
                    if (int.Parse(tableNumber) == tempOrderShowList[recordCounter].TableNumber && tempOrderShowList[recordCounter].OrderType.Equals("Table"))
                        found = true;
                }

                if (found)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Table already opened. Please select another table number.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                if (tableNumber.Equals("Cancel"))
                {
                    return;
                }

                CCalculatorForm tableGuestForm = new CCalculatorForm("Table Information", "Covers");
                tableGuestForm.ShowDialog();

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                {
                    return;
                }

                if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                    tempMessageBox.ShowDialog();
                    return;
                }

                string tableGuest = "";

                tableGuest = CCalculatorForm.inputResult;

                if (tableGuest.Equals("Cancel")) //If cancelled then exit.
                {
                    return;
                }

                CCalculatorForm floorNumberForm = new CCalculatorForm("Floor Information", "Floor Number");
                floorNumberForm.ShowDialog();

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                string floorNumber = "";

                floorNumber = CCalculatorForm.inputResult;

                COrderInfo tempOrderInfo = new COrderInfo();
                tempOrderInfo.TableNumber = int.Parse(tableNumber);
                //tempOrderInfo.TableName = "Table " + tableNumber;
                tempOrderInfo.UserID = m_oCommonConstants.UserInfo.UserID;
                tempOrderInfo.OrderTime = System.DateTime.Now; //needed now
                tempOrderInfo.OrderType = "Table";
                tempOrderInfo.GuestCount = int.Parse(tableGuest);
                tempOrderInfo.Status = "Seated";
                tempOrderInfo.FloorNo = floorNumber;
                //tempOrderInfo.InitialKitchenText = kitchenText;

                COrderManager tempOrderManager2 = new COrderManager();
                tempOrderInfo = (COrderInfo)tempOrderManager2.InsertOrderInfo(tempOrderInfo).Data;

                COrderSeatTime tempOrderSeatTime = new COrderSeatTime();
                tempOrderSeatTime.OrderID = tempOrderInfo.OrderID;
                tempOrderSeatTime.SeatTime = DateTime.Now;
                tempOrderManager2.InsertOrderSeatTime(tempOrderSeatTime);

                LobbyItemButton tableIcon = new LobbyItemButton();
                tableIcon.OrderID = tempOrderInfo.OrderID;
                tableIcon.TableName = "Table " + tableNumber;
                tableIcon.GuestCount = tableGuest;
                tableIcon.User = m_oCommonConstants.UserInfo.UserName;
                tableIcon.SeatedTime = tempOrderSeatTime.SeatTime;
               // tableIcon.Icon = global::RMS.Properties.Resources.seated;
                tableIcon.ItemType = RMSUIConstants.ItemType.SeatedButNoOrdered;
                tableIcon.TableNumber = int.Parse(tableNumber);
                tableIcon.Click += new EventHandler(TableIcon_MouseClick);

                tableIconList.Add(tableIcon);

                CTableInfo tempTableInfo = new CTableInfo();
                tempTableInfo.TableNumber = int.Parse(tableNumber);
                tempTableInfo.TableType = "Table";
                tempTableInfo.Status = 0;
                tempOrderManager.InsertTableInfo(tempTableInfo);

                try
                {
                    WaiterForm waiterForm = new WaiterForm();
                    waiterForm.UserList = userList;
                    waiterForm.ShowDialog();

                    if (waiterForm.DialogResult == DialogResult.OK)
                    {
                        COrderWaiterDao orderwaiterDao = new COrderWaiterDao();
                        COrderwaiter orderwaiter = new COrderwaiter();

                        orderwaiter = orderwaiterDao.GetOrderwaiterByOrderID(tempOrderInfo.OrderID);
                        if (orderwaiter != null && orderwaiter.ID > 0 && orderwaiter.WaiterID != waiterForm.UserInfoData.UserID)
                        {
                            orderwaiter.OrderID = tempOrderInfo.OrderID;
                            orderwaiter.WaiterID = waiterForm.UserInfoData.UserID;
                            orderwaiter.WaiterName = waiterForm.UserInfoData.UserName;
                            orderwaiterDao.UpdateOrderwaiter(orderwaiter);
                        }
                        else if (orderwaiter.ID == 0)
                        {
                            orderwaiter.OrderID = tempOrderInfo.OrderID;
                            orderwaiter.WaiterID = waiterForm.UserInfoData.UserID;
                            orderwaiter.WaiterName = waiterForm.UserInfoData.UserName;
                            orderwaiterDao.InsertOrderwaiter(orderwaiter);
                        }
                    }
                }
                catch (Exception ex)
                {
                }

                #region "OLD Code"

                //TablePanel.Controls.Clear();
                //Init();

                #endregion

                #region "New code added by Baruri"
                CTableOrderForm objOrderDetailsForm = new CTableOrderForm(tempOrderInfo.OrderID, 0, tempTableInfo.TableNumber);
                objOrderDetailsForm.m_orderUserName = RMSGlobal.LoginUserName;
                objOrderDetailsForm.Show();
                CFormManager.Forms.Push(this);
                this.Hide();
                #endregion

            }
            catch (Exception ee)
            {
            }
        }