- 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 Vehicles_MaintenanceEditor : System.Web.UI.Page
- {
- //模板
- Model.CarsKeep MC = new Model.CarsKeep();
- //业务
- BLL.CarsKeep BC = new BLL.CarsKeep();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "Vehicles_MaintenanceEditor");
- if (!IsPostBack)
- {
- object objid = Request.QueryString["id"];
- if (objid != null)
- {
- DropLoadSet();
- int ri = int.Parse(objid.ToString());
- MC = BC.GetModel(ri);
- KeyValue_CPH.SelectedValue = MC.CPH;
- KeyValue_WHLX.SelectedValue = MC.WHLX;
- KeyValue_WHYY.Text = MC.WHYY;
- KeyValue_WHRQ.Text = MC.WHRQ.ToString();
- KeyValue_JBR.Text = MC.JBR;
- KeyValue_WHFY.Text = MC.WHFY.ToString("0.00");
- KeyValue_BZ.Text = MC.BZ;
- }
- }
- }
- public void DropLoadSet()
- {
- //车牌号
- KeyValue_CPH.DataTextField = "CPH";
- KeyValue_CPH.DataValueField = "Id";
- KeyValue_CPH.DataSource = EnumGet.CarNumberGetEnum();
- KeyValue_CPH.DataBind();
- ListItem linone = new ListItem();
- linone.Text = "--请选择--";
- linone.Value = "0";
- KeyValue_CPH.Items.Add(linone);
- KeyValue_CPH.SelectedIndex = KeyValue_CPH.Items.Count - 1;
- //维护类型
- KeyValue_WHLX.DataTextField = "Text";
- KeyValue_WHLX.DataValueField = "Value";
- KeyValue_WHLX.DataSource = EnumGet.WeiHuGetEnum();
- KeyValue_WHLX.DataBind();
- ListItem linone2 = new ListItem();
- linone2.Text = "--请选择--";
- linone2.Value = "0";
- KeyValue_WHLX.Items.Add(linone2);
- KeyValue_WHLX.SelectedIndex = KeyValue_WHLX.Items.Count - 1;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- MC = BC.GetModel(int.Parse(Request.QueryString["id"].ToString()));
- try
- {
- if (KeyValue_CPH.SelectedValue == "0")
- {
- throw new Exception("请选择车牌号!");
- }
- if (String.IsNullOrEmpty(KeyValue_WHRQ.Text))
- {
- throw new Exception("维护日期不能为空!");
- }
- if (KeyValue_WHLX.SelectedValue == "0")
- {
- throw new Exception("请选择维护类型!");
- }
- if (String.IsNullOrEmpty(KeyValue_WHYY.Text))
- {
- throw new Exception("请选择维护原因!");
- }
- if (String.IsNullOrEmpty(KeyValue_JBR.Text))
- {
- throw new Exception("请选择经办人!");
- }
- decimal DKeyValue_WHFY = 0;
- if (!decimal.TryParse(KeyValue_WHFY.Text, out DKeyValue_WHFY))
- {
- throw new Exception("维护费用不正确!");
- }
- MC.CPH = KeyValue_CPH.SelectedValue;
- MC.WHRQ = Convert.ToDateTime(KeyValue_WHRQ.Text);
- MC.WHLX = KeyValue_WHLX.SelectedValue;
- MC.WHYY = KeyValue_WHYY.Text;
- MC.JBR = KeyValue_JBR.Text;
- MC.WHFY = DKeyValue_WHFY;
- MC.BZ = KeyValue_BZ.Text;
- BC.Update(MC);
- MessageBox.Show("更新成功!");
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }