Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishInfo dishInfo = new DishInfo();

            dishInfo.DChar   = txtChar.Text;
            dishInfo.DPrice  = Convert.ToDecimal(txtPrice.Text);
            dishInfo.DTitle  = txtTitleSave.Text;
            dishInfo.DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue);
            if (btnSave.Text.Equals("添加"))
            {
                if (dishInfoBll.Insert(dishInfo))
                {
                    LoadList();
                    LoadTypeList();
                    btnCancel.PerformClick();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试");
                }
            }
            else
            {
                dishInfo.DId = Convert.ToInt32(txtId.Text);
                if (dishInfoBll.Update(dishInfo))
                {
                    LoadList();
                    LoadTypeList();
                    btnCancel.PerformClick();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍后重试");
                }
            }
        }
Example #2
0
        private void button_添加_添加_Click(object sender, EventArgs e)
        {
            if (textBox_添加_名称.Text != "" || textBox_添加_价格.Text != "" || textBox_添加_拼音.Text != "")
            {
                #region 添加数据
                try
                {
                    DishInfo di = new DishInfo()
                    {
                        DTitle    = textBox_添加_名称.Text,
                        DChar     = textBox_添加_拼音.Text,
                        DPrice    = decimal.Parse(textBox_添加_价格.Text),
                        DTypeId   = Convert.ToInt32(comboBox_添加_分类.SelectedValue),
                        DIsDelete = false
                    };

                    if (dibll.Insert(di))
                    {
                        GetInfo();
                    }
                    else
                    {
                        MessageBox.Show("添加不成功,未知名错误");
                    }
                }
                catch (FormatException)
                {
                    MessageBox.Show("余额必须是数字");
                }
                #endregion
            }
            else
            {
                MessageBox.Show("不能为空,请填写内容");
            }
        }