Exemplo n.º 1
0
 //Quantity Text Changed
 private void txtQty_TextChanged(object sender, EventArgs e)
 {
     if (userCancel)
     {
         if (MyValidation.validNumber(txtQty.Text.ToString()))
         {
             if (txtQty.Text.Length > 0 && !txtQty.Text.ToString().Equals("0"))
             {
                 lblItemTotal.Text = Convert.ToString((Convert.ToDouble(txtQty.Text.ToString())) * (Convert.ToDouble(lblItemPrice.Text.ToString())));
             }
             else if (txtQty.Text.ToString().Equals("") || txtQty.Text.ToString().Equals("0"))
             {
                 lblItemTotal.Text = "-";
             }
         }
     }
 }
Exemplo n.º 2
0
        private void picAdd_Click(object sender, EventArgs e)
        {
            bool ok = true;

            errP.Clear();

            int  rows    = dgvCurrentOrder.RowCount;
            bool newItem = false;
            int  qty     = 0;

            if (rows > 1)
            {
                for (int x = 0; x < rows - 1; x++)
                {
                    if (!lblItemNo.Text.ToString().Equals(dgvCurrentOrder.Rows[x].Cells[2].Value.ToString()))
                    {
                        newItem = true;
                    }
                    else
                    {
                        newItem = false;
                        break;
                    }
                }
            }
            else
            {
                newItem = true;
            }

            if (newItem)
            {
                try
                {
                    if (MyValidation.validNumber(txtQty.Text.Trim()) && MyValidation.validLength((txtQty.Text.Trim()), 1, 1) && !txtQty.Text.ToString().Equals("0"))
                    {
                        qty = Convert.ToInt32(txtQty.Text.Trim());
                    }
                    else
                    {
                        throw new MyException("Quantity must be a number between 1 and 9.");
                    }
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtQty, MyEx.toString());
                }

                //Try Adding
                try
                {
                    if (ok)
                    {
                        if (rows > 1)
                        {
                            for (int x = 0; x < rows - 1; x++)
                            {
                                if (dgvCurrentOrder.Rows[x].Cells[2].Value.ToString().Equals(lblItemNo.Text))
                                {
                                    newItem = false;
                                    break;
                                }
                            }
                        }

                        if (newItem)
                        {
                            dgvCurrentOrder.Rows.Add(lblBookingNo.Text, lblRoomNo.Text, lblItemNo.Text, lblItemPrice.Text, txtQty.Text);
                        }
                        else
                        {
                            MessageBox.Show("Item Number " + lblItemNo.Text + " has already been added, choose a new item or remove current Item from the order and add with correct quantity.", "Edit Room Service", MessageBoxButtons.OK);
                        }

                        picAdd.Visible  = false;
                        picSave.Visible = true;

                        //Reset Item Detals
                        lblItemNo.Text             = "-";
                        lblItemNo.Enabled          = false;
                        lblItemDescription.Text    = "-";
                        lblItemDescription.Enabled = false;
                        lblItemPrice.Text          = "-";
                        lblItemPrice.Enabled       = false;
                        txtQty.Text          = "0";
                        txtQty.Enabled       = false;
                        lblItemTotal.Text    = "-";
                        lblItemTotal.Enabled = false;
                        lblItemNum.Enabled   = false;
                        lblItemDesc.Enabled  = false;
                        lblPrice.Enabled     = false;
                        lblQty.Enabled       = false;
                        lblTotal.Enabled     = false;

                        dgvItemList.ClearSelection();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("This Item has already been ordered by this room, you must remove the item from the current order list and add it agin with the correct information.", "Add an Item", MessageBoxButtons.OK);
            }
        }