Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishInfo model = new DishInfo()
            {
                DTitle  = txtTitleSave.Text,
                DTypeId = (int)ddlTypeAdd.SelectedValue,
                DPrice  = Convert.ToDecimal(txtPrice.Text),
                DChar   = txtChar.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();
        }
Exemple #2
0
        //添加\修改操作
        private void buttonadd_Click(object sender, EventArgs e)
        {
            DishInfo di = new DishInfo();

            di.DTitle  = textXmt.Text;
            di.DTypeId = Convert.ToInt32(comboBox1.SelectedValue);
            di.DPrice  = Convert.ToDecimal(textjg.Text);
            di.DChar   = textpy.Text;
            if (buttonadd.Text.Equals("添加"))
            {
                //添加
                if (diBll.Add(di))
                {
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试!!!");
                }
            }
            else
            {
                //修改
                di.DId = Convert.ToInt32(textBh.Text);
                if (diBll.Edit(di))
                {
                    buttoncancel_Click(null, null);
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍后重试!!!");
                }
            }
        }
Exemple #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            #region 判断是否有输入数据
            if (string.IsNullOrWhiteSpace(txtTitleSave.Text))
            {
                MessageBox.Show("请输入菜品名称");
                txtTitleSave.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(txtPrice.Text))
            {
                MessageBox.Show("请输入价格");
                txtPrice.Focus();
                return;
            }
            #endregion
            //获取用户输入数据,构建对象
            DishInfo di = new DishInfo()
            {
                DTitle  = txtTitleSave.Text,
                DPrice  = decimal.Parse(txtPrice.Text),
                DChar   = txtChar.Text,
                DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue)
            };
            if (txtId.Text.Equals("添加时无编号"))
            {
                //添加
                if (diBll.Add(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍候重试");
                }
            }
            else
            {
                //修改
                di.DId = int.Parse(txtId.Text);
                if (diBll.Edit(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败,请稍候重试");
                }
            }

            //恢复控件
            txtId.Text               = "添加时无编号";
            txtTitleSave.Text        = "";
            txtPrice.Text            = "";
            txtChar.Text             = "";
            ddlTypeAdd.SelectedIndex = 0;
            btnSave.Text             = "添加";
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if ("-请选择-".Equals(ddlTypeAdd.SelectedValue) || "全部".Equals(ddlTypeAdd.SelectedValue))
            {
                MessageBox.Show("请选择菜品分类");
                return;
            }
            //收集用户输入信息
            DishInfo di = new DishInfo()
            {
                DTitle     = txtTitleSave.Text.Trim(),
                DChar      = txtChar.Text.Trim(),
                DPrice     = Convert.ToDecimal(txtPrice.Text),
                DTypeTitle = ddlTypeAdd.SelectedValue.ToString()
            };

            if (txtId.Text == "添加时无编号")
            {
                #region 添加

                if (diBll.Add(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("逗b,怎么加的");
                }
                #endregion
            }
            else
            {
                #region 修改

                di.Id = int.Parse(txtId.Text);
                if (diBll.Update(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("你是猴子请来的救兵吗?");
                }
                #endregion
            }

            #region 恢复控件

            txtId.Text               = "添加时无编号";
            txtTitleSave.Text        = "";
            txtPrice.Text            = "";
            txtChar.Text             = "";
            ddlTypeAdd.SelectedIndex = 0;

            #endregion
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Createa a new cuision object according to the inputs
            DishInfo di = new DishInfo()
            {
                DTitle  = txtTitleSave.Text,
                DChar   = txtChar.Text,
                DPrice  = Convert.ToDecimal(txtPrice.Text),
                DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue)
            };

            if (txtId.Text == "No number")
            {
                #region Add

                if (diBll.Add(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("Failed to add a cuision");
                }
                #endregion
            }
            else
            {
                #region Update

                di.DId = int.Parse(txtId.Text);
                if (diBll.Update(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("Failed to add a cuision");
                }
                #endregion
            }

            #region Restore

            txtId.Text               = "No number";
            txtTitleSave.Text        = "";
            txtPrice.Text            = "";
            txtChar.Text             = "";
            ddlTypeAdd.SelectedIndex = 0;

            #endregion
        }
Exemple #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //收集用户输入信息
            DishInfo di = new DishInfo()
            {
                DTitle  = txtTitleSave.Text,
                DChar   = txtChar.Text,
                DPrice  = Convert.ToDecimal(txtPrice.Text),
                DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue)
            };

            if (txtId.Text == "添加时无编号")
            {
                #region 添加

                if (diBll.Add(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("逗b,怎么加的");
                }
                #endregion
            }
            else
            {
                #region 修改

                di.DId = int.Parse(txtId.Text);
                if (diBll.Update(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("你是猴子请来的救兵吗?");
                }
                #endregion
            }

            #region 恢复控件

            txtId.Text               = "添加时无编号";
            txtTitleSave.Text        = "";
            txtPrice.Text            = "";
            txtChar.Text             = "";
            ddlTypeAdd.SelectedIndex = 0;

            #endregion
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtTitleSave.Text == "" || txtPrice.Text == "" || ddlTypeAdd.SelectedIndex == 0)
            {
                MessageBox.Show("请完善信息后重试!");
                return;
            }
            DishInfo dish = new DishInfo()
            {
                DTitle  = txtTitleSave.Text,
                DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue),
                DPrice  = Convert.ToInt32(txtPrice.Text),
                DChar   = txtChar.Text
            };


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

            Clear();
            LoadList();
            LoadTypeList();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            //收集用户输入的信息
            DishInfo di = new DishInfo()
            {
                DTitle  = txtNameAdd.Text,
                DChar   = txtPinyin.Text,
                DPrice  = Convert.ToDecimal(txtPrice.Text),
                DTypeId = Convert.ToInt32(cbbType.SelectedValue)
            };

            if (txtIdAdd.Text == "添加时无编号")
            {
                //添加
                if (diBll.Add(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试");
                }
            }
            else
            {
                //修改
                di.DId = int.Parse(txtIdAdd.Text);
                if (diBll.Edit(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试");
                }
            }
            //恢复控件
            txtIdAdd.Text         = "添加时无编号";
            txtNameAdd.Text       = "";
            txtPrice.Text         = "";
            txtPinyin.Text        = "";
            cbbType.SelectedIndex = 0;
        }
Exemple #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishInfo di = new DishInfo()
            {
                DTitle  = txtTitleSave.Text,
                DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue),
                DPrice  = Convert.ToDecimal(txtPrice.Text),
                DChar   = txtChar.Text
            };

            if (txtId.Text == "添加时无编号")
            {
                //添加
                if (diBll.Add(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                //修改
                di.DId = Convert.ToInt32(txtId.Text);
                if (diBll.Edit(di))
                {
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            txtId.Text               = "添加时无编号";
            txtTitleSave.Text        = "";
            ddlTypeAdd.SelectedIndex = 0;
            txtPrice.Text            = "";
            txtChar.Text             = "";
            btnSave.Text             = "添加";
        }
Exemple #10
0
        /// <summary>
        /// btnSave按钮添加和修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishInfo di = new DishInfo()
            {
                DTitle  = txtTitleSave.Text,
                DChar   = txtChar.Text,
                DPrice  = Convert.ToDecimal(txtPrice.Text),
                DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue)
            };

            if (txtId.Text == "添加时无编号")
            {
                #region 添加
                if (diBll.Add(di))
                {
                    LoadList();
                    MessageBox.Show("添加成功.");
                }
                else
                {
                    MessageBox.Show("添加失败,请稍后重试......");
                }
                #endregion
            }
            else
            {
                #region 修改
                di.DId = Convert.ToInt32(txtId.Text);
                if (diBll.Edit(di))
                {
                    LoadList();
                    MessageBox.Show("修改成功.");
                }
                else
                {
                    MessageBox.Show("修改失败,请稍后再试......");
                }
                #endregion
                Clean();
            }
        }
Exemple #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishInfo di = new DishInfo();

            try
            {
                di.DTitle  = txtTitle.Text;
                di.DTypeId = Convert.ToInt32(cbxType.SelectedValue);
                di.DPrice  = Convert.ToDecimal(txtPrice.Text);
                di.DChar   = txtPy.Text;
            }
            catch
            {
                return;
            }
            if (btnSave.Text == "添加")
            {
                if (diBll.Add(di))
                {
                    LoadDishInfoList();
                }
                else
                {
                    MessageBox.Show("添加失败!请稍后重试!");
                }
            }
            else
            {
                //修改
                di.DId = Convert.ToInt32(txtId.Text);
                if (diBll.Edit(di))
                {
                    LoadDishInfoList();
                }
                else
                {
                    MessageBox.Show("修改失败!请稍后重试!");
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishInfo di = new DishInfo()    //构造对象
            {
                DTitle  = txtTitleSave.Text,
                DChar   = txtChar.Text,
                DPrice  = Convert.ToDecimal(txtPrice.Text),
                DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue)
            };

            if (btnSave.Text == "添加")   //添加逻辑
            {
                if (diBll.Add(di))
                {
                    LoadList();
                    LoadTypeList();
                    ResetCom();
                }
                else
                {
                    MessageBox.Show("添加失败,请重试!", "提示");
                }
            }
            else    //修改逻辑
            {
                di.DId = Convert.ToInt32(txtId.Text);
                if (diBll.Edit(di))
                {
                    LoadList();
                    LoadTypeList();
                    ResetCom();
                }
                else
                {
                    MessageBox.Show("添加失败,请重试!", "提示");
                }
            }
        }
Exemple #13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DishInfo di = new DishInfo()
            {
                DTitle  = txtDTitleAdd.Text,
                DChar   = txtDCharAdd.Text,
                DPrice  = Convert.ToDecimal(txtDPriceAdd.Text),
                DTypeId = Convert.ToInt32(cbTypeTitleAdd.SelectedValue)
            };

            if (btnSave.Text.Equals("添加"))
            {
                if (_diBll.Add(di))
                {
                    btnCancel_Click(null, null);
                    LoadList();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else if (btnSave.Text.Equals("修改"))
            {
                di.Did = Convert.ToInt32(txtDId.Text);
                if (_diBll.Edit(di))
                {
                    btnCancel_Click(null, null);
                    LoadList();
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }
            }
        }