Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishTypeInfo model = new DishTypeInfo()
            {
                DTitle = txtTitle.Text
            };

            if (btnSave.Text == "添加")
            {
                if (!bll.Add(model))
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                model.DId = Convert.ToInt32(txtId.Text);
                if (!bll.Update(model))
                {
                    MessageBox.Show("修改失败");
                }
            }
            Reset();
            LoadList();
            resulted = DialogResult.OK;
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishTypeInfo dishTypeInfo = new DishTypeInfo();

            dishTypeInfo.DTitle = txtTitle.Text;
            if (btnSave.Text.Equals("添加"))
            {
                if (dishTypeInfoBll.Insert(dishTypeInfo))
                {
                    LoadList();
                    btnCancel.PerformClick();
                    Type();
                }
                else
                {
                    MessageBox.Show("添加失败请稍后重试");
                }
            }
            else
            {
                dishTypeInfo.DId = Convert.ToInt32(txtId.Text);
                if (dishTypeInfoBll.Update(dishTypeInfo))
                {
                    LoadList();
                    btnCancel.PerformClick();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍后重试");
                }
            }
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //根据用户输入构造对象
            DishTypeInfo dishTypeInfo = new DishTypeInfo()
            {
                DTitle = txtTitle.Text
            };

            if (txtId.Text == "添加时无编号")
            {
                if (bll.Add(dishTypeInfo))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("sb");
                }
            }
            else
            {
                dishTypeInfo.DId = int.Parse(txtId.Text);
                if (bll.Update(dishTypeInfo))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("sb");
                }
            }
            txtId.Text    = "添加时无编号";
            txtTitle.Text = "";
        }