Esempio n. 1
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. 2
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. 3
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. 4
0
        private void NewOrder()
        {
            try
            {
                if (m_bOrderState)
                {
                    return;
                }
                CCommonConstants tempCommonConstants = ConfigManager.GetConfig<CCommonConstants>();
                COrderManager tempOrderManager = new COrderManager();
                COrderInfo tempOrderInfo = new COrderInfo();

                tempOrderInfo.TableNumber = GetValidTableNumber("Tabs");
                tempOrderInfo.GuestCount = 1;
                tempOrderInfo.TableName = "Tabs" + tempOrderInfo.TableNumber;
                tempOrderInfo.UserID = tempCommonConstants.UserInfo.UserID;
                tempOrderInfo.OrderTime = DateTime.Now;
                tempOrderInfo.OrderType = "Tabs";
                //Status not used

                CResult oResult = tempOrderManager.InsertOrderInfo(tempOrderInfo);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderInfo = (COrderInfo)oResult.Data;
                }

                //insert new tab info
                CTableInfo tempTableInfo = new CTableInfo();
                tempTableInfo.TableType = "Tabs";
                tempTableInfo.TableNumber = tempOrderInfo.TableNumber;
                tempTableInfo.Status = 1;
                tempOrderManager.InsertTableInfo(tempTableInfo);
                m_iTableNumber = tempTableInfo.TableNumber;

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

                orderID = tempOrderInfo.OrderID;
                m_iType = tempCommonConstants.TabsType;

                m_bOrderState = true;
                LoadStatusBar();
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Esempio n. 5
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)
            {
            }
        }