DutyAdd.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:3k
- 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 Dutys_DutyAdd : System.Web.UI.Page
- {
- //模板
- Model.Dutys MD = new Model.Dutys();
- //业务
- BLL.Dutys BD = new BLL.Dutys();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "Dutys_DutyAdd");
- if (!IsPostBack)
- {
- DropLoadSet();
- }
- }
- public void DropLoadSet()
- {
- //值班类别
- KeyValue_ZBLB.DataTextField = "LBMC";
- KeyValue_ZBLB.DataValueField = "ID";
- KeyValue_ZBLB.DataSource = EnumGet.ZhiBanTypeGetEnum();
- KeyValue_ZBLB.DataBind();
- ListItem linone = new ListItem();
- linone.Text = "--请选择--";
- linone.Value = "0";
- KeyValue_ZBLB.Items.Add(linone);
- KeyValue_ZBLB.SelectedIndex = KeyValue_ZBLB.Items.Count - 1;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (KeyValue_ZBLB.SelectedValue == "0")
- {
- throw new Exception("请选择值班类别!");
- }
- if (String.IsNullOrEmpty(KeyValue_ZBRY.Text.Trim()))
- {
- throw new Exception("值班人员不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_ZBKSSJ.Text.Trim()))
- {
- throw new Exception("值班开始时间不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_ZBJSSJ.Text.Trim()))
- {
- throw new Exception("值班结束时间不能为空!");
- }
- MD.ZBLB = KeyValue_ZBLB.SelectedValue;
- MD.ZBRY = KeyValue_ZBRY.Text;
- MD.ZBKSSJ = Convert.ToDateTime(KeyValue_ZBKSSJ.Text);
- MD.ZBJSSJ = Convert.ToDateTime(KeyValue_ZBJSSJ.Text);
- MD.BZ = KeyValue_BZ.Text;
- BD.Add(MD);
- MessageBox.Show("添加成功!");
- KeyValue_ZBLB.SelectedIndex = KeyValue_ZBLB.Items.Count - 1;
- KeyValue_ZBRY.Text = "";
- KeyValue_ZBKSSJ.Text = "";
- KeyValue_ZBJSSJ.Text = "";
- KeyValue_BZ.Text = "";
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }