Exemple #1
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("修改失败,请稍后重试");
                }
            }
        }
Exemple #2
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("修改失败!");
                }
            }
        }
        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("修改失败!请稍后重试!");
                }
            }
        }
        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  = "添加";
        }
        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;
        }
        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;
        }
Exemple #7
0
 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;
 }
Exemple #8
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  = "添加";
        }
        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;
        }
        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  = "添加";
        }