MealsAdd.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:2k
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class Meals_MealsAdd : System.Web.UI.Page
- {
- //模板
- Model.Foods MF = new Model.Foods();
- //业务
- BLL.Foods BF = new BLL.Foods();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "Meals_MealsAdd");
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (String.IsNullOrEmpty(KeyValue_YCLBMC.Text))
- {
- throw new Exception("用餐类别名不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_CM.Text))
- {
- throw new Exception("用餐菜名不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_YCDWDH.Text))
- {
- throw new Exception("用餐单位不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_YCDWDH.Text))
- {
- throw new Exception("用餐单位电话不能为空!");
- }
- decimal DKeyValue_JG = 0;
- if (!decimal.TryParse(KeyValue_JG.Text, out DKeyValue_JG))
- {
- throw new Exception("价格不正确!");
- }
- MF.YCLBMC = KeyValue_YCLBMC.Text;
- MF.CM = KeyValue_CM.Text;
- MF.YCDW = KeyValue_YCDW.Text;
- MF.YCDWDH = KeyValue_YCDWDH.Text;
- MF.JG = DKeyValue_JG;
- MF.BZ = KeyValue_BZ.Text;
- BF.Add(MF);
- MessageBox.Show("添加成功!");
- KeyValue_YCLBMC.Text = "";
- KeyValue_CM.Text = "";
- KeyValue_YCDW.Text = "";
- KeyValue_YCDWDH.Text = "";
- KeyValue_JG.Text = "";
- KeyValue_BZ.Text = "";
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }