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(); }
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 }
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) { DishInfo dishInfo = new DishInfo(); dishInfo.DChar = txtChar.Text; dishInfo.DPrice = Convert.ToDecimal(txtPrice.Text); dishInfo.DTitle = txtTitleSave.Text; dishInfo.DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue); if (btnSave.Text.Equals("添加")) { if (dishInfoBll.Insert(dishInfo)) { LoadList(); LoadTypeList(); btnCancel.PerformClick(); } else { MessageBox.Show("添加失败,请稍后重试"); } } else { dishInfo.DId = Convert.ToInt32(txtId.Text); if (dishInfoBll.Update(dishInfo)) { LoadList(); LoadTypeList(); btnCancel.PerformClick(); } else { MessageBox.Show("修改失败,请稍后重试"); } } }