コード例 #1
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("修改失败,请稍后重试");
                }
            }
        }
コード例 #2
0
        private void button_添加_Click(object sender, EventArgs e)
        {
            if (textBox_菜系.Text != "")
            {
                DishTypeInfo dti = new DishTypeInfo()
                {
                    DTitle    = textBox_菜系.Text,
                    DIsDelete = false
                };

                if (dtibll.Insert(dti))
                {
                    GetInfo();
                }
                else
                {
                    MessageBox.Show("添加错误");
                }
            }
            else
            {
                MessageBox.Show("菜系不能为空,请输入后,再添加");
            }
        }