- 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_ArticlesInfoAdd : 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_ArticlesInfoAdd");
- if (!IsPostBack)
- {
- DropLoadSet();
- }
- }
- 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.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.Add(MR);
- MessageBox.Show("新建成功");
- KeyValue_YPMC.Text = "";
- KeyValue_YPBM.Text = "";
- KeyValue_YPMS.Text = "";
- KeyValue_JLDW.Text = "";
- KeyValue_DJ.Text = "";
- KeyValue_GYS.Text = "";
- KeyValue_JJKC.Text = "";
- KeyValue_DQKC.Text = "";
- KeyValue_CJR.Text = "";
- KeyValue_DJQX.Text = "";
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }