- 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 Articles_ArticlesInfoEditor : System.Web.UI.Page
- {
- //模板
- Model.UseThings MR = new Model.UseThings();
- //业务
- BLL.UseThings BR = new BLL.UseThings();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "Articles_ArticlesInfoEditor");
- if (!IsPostBack)
- {
- object objid = Request.QueryString["id"];
- if (objid != null)
- {
- DropLoadSet();
- int ri = int.Parse(objid.ToString());
- MR = BR.GetModel(ri);
- KeyValue_YPMC.Text = MR.YPMC;
- KeyValue_YPBM.Text = MR.YPBM;
- KeyValue_YPLB.SelectedValue = MR.YPLB;
- KeyValue_YPMS.Text = MR.YPMS;
- KeyValue_JLDW.Text = MR.JLDW;
- KeyValue_DJ.Text = MR.DJ.ToString();
- KeyValue_GYS.Text = MR.GYS;
- KeyValue_JJKC.Text = MR.JJKC.ToString();
- KeyValue_DQKC.Text = MR.DQKC.ToString();
- KeyValue_CJR.Text = MR.CJR;
- KeyValue_DJQX.Text = MR.DJQX;
- }
- }
- }
- public void DropLoadSet()
- {
- //用品类别
- KeyValue_YPLB.DataTextField = "LBMC";
- KeyValue_YPLB.DataValueField = "ID";
- KeyValue_YPLB.DataSource = EnumGet.UseThingsTypeGetEnum();
- KeyValue_YPLB.DataBind();
- ListItem linone = new ListItem();
- linone.Text = "无";
- linone.Value = "0";
- KeyValue_YPLB.Items.Add(linone);
- KeyValue_YPLB.SelectedIndex = KeyValue_YPLB.Items.Count - 1;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (KeyValue_YPMC.Text == "")
- {
- throw new Exception("用品名称不能为空!");
- }
- if (KeyValue_YPBM.Text == "")
- {
- throw new Exception("用品编码不能为空!");
- }
- decimal DKeyValue_DJ = 0;
- if (!decimal.TryParse(KeyValue_DJ.Text, out DKeyValue_DJ))
- {
- throw new Exception("单价不正确!");
- }
- int IKeyValue_JJKC = 0;
- if (!int.TryParse(KeyValue_JJKC.Text, out IKeyValue_JJKC))
- {
- throw new Exception("警戒库存不正确!");
- }
- int IKeyValue_DQKC = 0;
- if (!int.TryParse(KeyValue_DQKC.Text, out IKeyValue_DQKC))
- {
- throw new Exception("当前库存不正确!");
- }
- MR.ID = int.Parse(Request.QueryString["id"].ToString());
- MR.YPMC = KeyValue_YPMC.Text;
- MR.YPBM = KeyValue_YPBM.Text;
- MR.YPLB = KeyValue_YPLB.SelectedValue;
- MR.YPMS = KeyValue_YPMS.Text;
- MR.JLDW = KeyValue_JLDW.Text;
- MR.DJ = DKeyValue_DJ;
- MR.GYS = KeyValue_GYS.Text;
- MR.JJKC = IKeyValue_JJKC;
- MR.DQKC = IKeyValue_DQKC;
- MR.CJR = KeyValue_CJR.Text;
- MR.DJQX = KeyValue_DJQX.Text;
- BR.Update(MR);
- MessageBox.Show("更新成功");
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }