Example #1
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
        }
Example #2
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();
        }