Esempio n. 1
0
 private void TextBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)27)
     {
         double Foodqty;
         try
         {
             Foodqty = double.Parse(TextBox1.Text);
         }
         catch (Exception)
         {
             MessageBox.Show("菜品数量输入有误,请核对后重新输入。");
             TextBox1.Focus();
             TextBox1.Select(0, TextBox1.Text.Length);
             return;
         }
         if (Foodqty > 0)
         {
             FoodQuantity      = double.Parse(Foodqty.ToString());
             FoodOperandi      = txtOperandi.Text;
             FoodTaste         = txtTaste.Text;
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             MessageBox.Show("菜品数量不能为 0,请输入或调整为大于 0 的数字");
         }
     }
 }
Esempio n. 2
0
            private void Button1_Click(System.Object sender, System.EventArgs e)
            {
                double Foodqty;

                try
                {
                    Foodqty = double.Parse(TextBox1.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("菜品数量输入有误,请核对后重新输入。");
                    TextBox1.Focus();
                    TextBox1.Select(0, TextBox1.Text.Length);
                    return;
                }
                if (numFoodPrice.Visible)
                {
                    try
                    {
                        FoodUnitPrice = double.Parse(numFoodPrice.Text);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("菜品单价输入有误,请核对后重新输入。");
                        numFoodPrice.Focus();
                        numFoodPrice.Select(0, numFoodPrice.Text.Length);
                        return;
                    }
                }
                if (Foodqty > 0)
                {
                    FoodQuantity = double.Parse(Foodqty.ToString());
                    FoodOperandi = txtOperandi.Text;
                    FoodTaste    = txtTaste.Text;
                    if (numFoodPrice.Visible)
                    {
                        FoodUnitPrice = double.Parse(numFoodPrice.Text);
                    }
                    else
                    {
                        FoodUnitPrice = double.Parse(Label7.Text);
                    }
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("菜品数量不能为 0,请输入或调整为大于 0 的数字");
                }
            }