DutyEditor.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_DutyEditor : 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_DutyEditor");
- if (!IsPostBack)
- {
- object objid = Request.QueryString["id"];
- if (objid != null)
- {
- DropLoadSet();
- int ri = int.Parse(objid.ToString());
- MD = BD.GetModel(ri);
- KeyValue_ZBLB.SelectedValue = MD.ZBLB;
- KeyValue_ZBRY.Text = MD.ZBRY;
- KeyValue_ZBKSSJ.Text = MD.ZBKSSJ.ToString();
- KeyValue_ZBJSSJ.Text = MD.ZBJSSJ.ToString();
- KeyValue_BZ.Text = MD.BZ;
- }
- }
- }
- 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.Update(MD);
- MessageBox.Show("更新成功!");
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }