コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishTypeInfo dti = new DishTypeInfo();

            dti.DTitle = txtDtitle.Text.ToString();

            if (btnSave.Text.Equals("添加"))
            {
                if (_dtiBll.Add(dti))
                {
                    UpdateTypeEvent?.Invoke();
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败!");
                }
            }
            else if (btnSave.Text.Equals("修改"))
            {
                dti.DId = int.Parse(txtDId.Text);
                if (_dtiBll.Edit(dti))
                {
                    UpdateTypeEvent?.Invoke();
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }
            }
        }
コード例 #2
0
        //添加\修改
        private void button1_Click(object sender, EventArgs e)
        {
            DishTypeInfo dti = new DishTypeInfo();

            dti.DTitle = textBox1.Text;
            if (button1.Text.Equals("添加"))
            {
                //添加
                if (dtiBll.Add(dti))
                {
                    button2_Click(null, null);
                    LoadList();
                    UpdateTypeEvent();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试");
                }
            }
            else
            {
                //修改
                dti.DId = Convert.ToInt32(textBox3.Text);
                if (dtiBll.Edit(dti))
                {
                    button2_Click(null, null);
                    LoadList();
                    UpdateTypeEvent();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍后重试");
                }
            }
        }
コード例 #3
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;
        }
コード例 #4
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 = "";
        }
コード例 #5
0
ファイル: DishTypeInfoList.cs プロジェクト: AlexHung123/Cater
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishTypeInfo dti = new DishTypeInfo();

            dti.DTitle = txtTitle.Text;

            if (btnSave.Text == "添加")
            {
                if (dtiBll.Add(dti))
                {
                    LoadDishTypeList();
                    UpdateTypeEvent();
                }
                else
                {
                    MessageBox.Show("添加失败!请稍后重试!");
                }
            }
            else
            {
                dti.DId = Convert.ToInt32(txtDId.Text);
                if (dtiBll.Edit(dti))
                {
                    LoadDishTypeList();
                    UpdateTypeEvent();
                }
                else
                {
                    MessageBox.Show("修改失败!请稍后重试!");
                }
            }
        }
コード例 #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //获取用户输入,构造对象
            if (string.IsNullOrWhiteSpace(txtTitle.Text))
            {
                MessageBox.Show("请输入标题");
                txtTitle.Focus();
                return;
            }
            DishTypeInfo dti = new DishTypeInfo()
            {
                DTitle = txtTitle.Text
            };

            if (txtId.Text == "添加时无编号")
            {
                //调用方法,添加数据
                if (dtiBll.Add(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍候重试");
                }
            }
            else
            {
                dti.DId = Convert.ToInt32(txtId.Text);
                //调用方法,修改数据
                if (dtiBll.Edit(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍候重试");
                }
            }
            //           result = DialogResult.OK;
            RefreshTypeList();
            //恢复控件
            txtId.Text    = "添加时无编号";
            txtTitle.Text = "";
            btnSave.Text  = "添加";
        }
コード例 #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //添加
            //根据用户输入构造对象
            DishTypeInfo dti = new DishTypeInfo()
            {
                DTitle = txtTitle.Text
            };

            if (btnSave.Text == "添加")
            {
                //添加
                if (dtiBll.Add(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试");
                }
            }
            else
            {
                //修改
                dti.DId = Convert.ToInt32(txtId.Text);
                if (dtiBll.Edit(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍后重试");
                }
            }

            //清除文本值
            txtId.Text    = "添加时无编号";
            txtTitle.Text = "";
            btnSave.Text  = "添加";

            this.result = DialogResult.OK;
        }
コード例 #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //判断是添加还是修改!但是无论是添加还是修改,都要进行对象封装
            DishTypeInfo dti = new DishTypeInfo();

            dti.DTitle = txtTitle.Text;

            if (txtId.Text == "添加时无编号")
            {
                //添加
                if (bll.Add(dti))
                {
                    MessageBox.Show("添加成功!");
                }
                else
                {
                    MessageBox.Show("添加失败!请稍后重试");
                }
            }
            else
            {
                //修改
                dti.DId = Convert.ToInt32(txtId.Text);
                if (bll.Exit(dti))
                {
                    MessageBox.Show("修改成功!");
                }
                else
                {
                    MessageBox.Show("修改失败!请稍后重试");
                }
            }

            LoadList();
            btnSave.Text  = "添加";
            txtId.Text    = "添加时无编号";
            txtTitle.Text = "";
        }
コード例 #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishTypeInfo dti = new DishTypeInfo()
            {
                DTitle = txtTitle.Text
            };

            if (txtId.Text == "添加时无编号")
            {
                //添加
                if (dtiBll.Add(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                //修改
                index   = dgvList.SelectedRows[0].Index;
                dti.DId = Convert.ToInt32(txtId.Text);
                if (dtiBll.Edit(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            txtId.Text    = "添加时无编号";
            txtTitle.Text = "";
            btnSave.Text  = "添加";
            result        = DialogResult.OK;
        }
コード例 #10
0
ファイル: FormDishTypeInfo.cs プロジェクト: supeng4587/Cater
 private void btnSave_Click(object sender, EventArgs e)
 {
     //根据用户输入的构造对象
     dti.DTitle = txtTitle.Text;
     //判断添加修改
     if (txtId.Text.Equals("添加时无编号"))
     {
         #region 添加
         if (dtiBll.Add(dti))
         {
             LoadList();
             MessageBox.Show("添加成功.");
         }
         else
         {
             MessageBox.Show("添加失败,请稍后重试......");
         }
         #endregion
     }
     else
     {
         #region 修改 单独采集did
         dti.DId = Convert.ToInt32(txtId.Text);
         if (dtiBll.Edit(dti))
         {
             LoadList();
             MessageBox.Show("修改成功.");
         }
         else
         {
             MessageBox.Show("修改失败,请稍后重试......");
         }
         #endregion
     }
     Clean();
     this.result = DialogResult.OK;
 }
コード例 #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishTypeInfo dti = new DishTypeInfo()
            {
                DTitle = txtTitle.Text.Trim(),
            };

            if (btnSave.Text == "保存")
            {
                if (dtiBll.Add(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                dti.DId = Convert.ToInt32(txtId.Text.ToString());
                if (dtiBll.Edit(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }


            txtTitle.Text = "";
            txtId.Text    = "添加时无编号";
            btnSave.Text  = "添加";
        }
コード例 #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishTypeInfo dti = new DishTypeInfo()
            {
                DTitle = txtTitle.Text
            };

            if (txtId.Text == "No number")
            {
                //Add
                if (dtiBll.Add(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("Failed to add a dish type");
                }
            }
            else
            {
                //Update
                dti.DId = int.Parse(txtId.Text);
                if (dtiBll.Edit(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("Failed to add a dish type");
                }
            }
            ReinitiateCombo();

            this.result = DialogResult.OK;
        }
コード例 #13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishTypeInfo dti = new DishTypeInfo()
            {
                DTitle = txtTitle.Text
            };

            if (txtId.Text == "添加时无编号")
            {
                if (dtiBll.Add(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("失败");
                }
            }
            else
            {
                dti.DId = int.Parse(txtId.Text);
                if (dtiBll.Edit(dti))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }


            txtId.Text    = "添加时无编号";
            txtTitle.Text = "";
            btnSave.Text  = "添加";
        }