MealsEditor.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_MealsEditor : 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_MealsEditor");
- if (!IsPostBack)
- {
- object objid = Request.QueryString["id"];
- if (objid != null)
- {
- int ri = int.Parse(objid.ToString());
- MF = BF.GetModel(ri);
- KeyValue_YCLBMC.Text = MF.YCLBMC;
- KeyValue_YCDW.Text = MF.YCDW;
- KeyValue_YCDWDH.Text = MF.YCDWDH;
- KeyValue_JG.Text = MF.JG.ToString();
- KeyValue_BZ.Text = MF.BZ;
- }
- }
- }
- 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.Update(MF);
- MessageBox.Show("更新成功!");
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }