MaintenanceAdd.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:3k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. public partial class Vehicles_MaintenanceAdd : System.Web.UI.Page
  12. {
  13.     //模板
  14.     Model.CarsKeep MC = new Model.CarsKeep();
  15.     //业务
  16.     BLL.CarsKeep BC = new BLL.CarsKeep();
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.         LoginLogic.MatchLoad("../", "Vehicles_MaintenanceAdd");
  20.         if (!IsPostBack)
  21.         {
  22.             DropLoadSet();
  23.         }
  24.     }
  25.     public void DropLoadSet()
  26.     {
  27.         //车牌号
  28.         KeyValue_CPH.DataTextField = "CPH";
  29.         KeyValue_CPH.DataValueField = "Id";
  30.         KeyValue_CPH.DataSource = EnumGet.CarNumberGetEnum();
  31.         KeyValue_CPH.DataBind();
  32.         ListItem linone = new ListItem();
  33.         linone.Text = "--请选择--";
  34.         linone.Value = "0";
  35.         KeyValue_CPH.Items.Add(linone);
  36.         KeyValue_CPH.SelectedIndex = KeyValue_CPH.Items.Count - 1;
  37.         //维护类型
  38.         KeyValue_WHLX.DataTextField = "Text";
  39.         KeyValue_WHLX.DataValueField = "Value";
  40.         KeyValue_WHLX.DataSource = EnumGet.WeiHuGetEnum();
  41.         KeyValue_WHLX.DataBind();
  42.         ListItem linone2 = new ListItem();
  43.         linone2.Text = "--请选择--";
  44.         linone2.Value = "0";
  45.         KeyValue_WHLX.Items.Add(linone2);
  46.         KeyValue_WHLX.SelectedIndex = KeyValue_WHLX.Items.Count - 1;
  47.     }
  48.     protected void Button1_Click(object sender, EventArgs e)
  49.     {
  50.         try
  51.         {
  52.             if (KeyValue_CPH.SelectedValue == "0")
  53.             {
  54.                 throw new Exception("请选择车牌号!");
  55.             }    
  56.             if (String.IsNullOrEmpty(KeyValue_WHRQ.Text))
  57.             {
  58.                 throw new Exception("维护日期不能为空!");
  59.             }
  60.             if (KeyValue_WHLX.SelectedValue == "0")
  61.             {
  62.                 throw new Exception("请选择维护类型!");
  63.             }
  64.             if (String.IsNullOrEmpty(KeyValue_WHYY.Text))
  65.             {
  66.                 throw new Exception("请选择维护原因!");
  67.             }
  68.             if (String.IsNullOrEmpty(KeyValue_JBR.Text))
  69.             {
  70.                 throw new Exception("请选择经办人!");
  71.             }
  72.             decimal DKeyValue_WHFY = 0;
  73.             if (!decimal.TryParse(KeyValue_WHFY.Text, out DKeyValue_WHFY))
  74.             {
  75.                 throw new Exception("维护费用不正确!");
  76.             }
  77.             MC.CPH = KeyValue_CPH.SelectedValue;
  78.             MC.WHRQ = Convert.ToDateTime(KeyValue_WHRQ.Text);
  79.             MC.WHLX = KeyValue_WHLX.SelectedValue;
  80.             MC.WHYY = KeyValue_WHYY.Text;
  81.             MC.JBR = KeyValue_JBR.Text;
  82.             MC.WHFY = DKeyValue_WHFY;
  83.             MC.BZ = KeyValue_BZ.Text;
  84.             BC.Add(MC);
  85.             MessageBox.Show("添加成功!");
  86.             KeyValue_WHRQ.Text = "";
  87.             KeyValue_WHYY.Text = "";
  88.             KeyValue_JBR.Text = "";
  89.             KeyValue_WHFY.Text = "";
  90.             KeyValue_BZ.Text = "";
  91.             DropLoadSet();
  92.         }
  93.         catch (Exception exp)
  94.         {
  95.             MessageBox.Show(exp.Message);
  96.         }
  97.     }
  98. }