
using System;
using System.Data;
using System.Web.UI.WebControls;
using System.Web.SessionState;
using AVC.Business;
using AVC.DataEntity;

	/// <summary>
	/// BusIllegal编辑
	/// </summary>
public partial class BusIllegalEdit : LoginPageBase
	{

		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{
				string strAction = Request.QueryString["action"];
				// 自动编号
				
				ViewState["Action"] = strAction;
				if(strAction == "edit")
				{
					System.Int32 ID = System.Int32.Parse(Request.QueryString["ID"]);BusIllegal objBusIllegal = BusIllegalBiz.GetBusIllegal(ID);
					
					txtID.Text = objBusIllegal.ID.ToString();
					txtIllegalDateTime.Text = objBusIllegal.IllegalDateTime.ToString();
					txtIllegalAddress.Text = objBusIllegal.IllegalAddress;
					txtIllegalContent.Text = objBusIllegal.IllegalContent;
					txtProcessMan.Text = objBusIllegal.ProcessMan;
					txtProcessResult.Text = objBusIllegal.ProcessResult;
					txtBusID.Text = objBusIllegal.BusID.ToString();
					txtBusLicense.Text = objBusIllegal.BusLicense;
					txtID.ReadOnly = true;
					
				}
			}
		}

		public void btnOK_Click(object sender, System.EventArgs e)
		{
			try
			{
				if((string)ViewState["Action"] == "add")
				{
					BusIllegal objBusIllegal = new BusIllegal();
					
					objBusIllegal.ID = System.Int32.Parse(txtID.Text);
					objBusIllegal.IllegalDateTime = System.DateTime.Parse(txtIllegalDateTime.Text);
					objBusIllegal.IllegalAddress = txtIllegalAddress.Text;
					objBusIllegal.IllegalContent = txtIllegalContent.Text;
					objBusIllegal.ProcessMan = txtProcessMan.Text;
					objBusIllegal.ProcessResult = txtProcessResult.Text;
					objBusIllegal.BusID = System.Int32.Parse(txtBusID.Text);
					objBusIllegal.BusLicense = txtBusLicense.Text;
                    objBusIllegal.CreateUser = UserName;
                    objBusIllegal.UpdateUser = UserName;
                    objBusIllegal.UpdateDateTime = System.DateTime.Now;
					objBusIllegal.Flag = 1;
                    objBusIllegal.FlagDateTime = System.DateTime.Now;
                    BusIllegalBiz.AddBusIllegal(objBusIllegal);
					ViewState["Action"] = "edit";		
					txtID.ReadOnly = true;
					
				}
				else if((string)ViewState["Action"] == "edit")
				{
					BusIllegal objBusIllegal = BusIllegalBiz.GetBusIllegal(System.Int32.Parse(txtID.Text));
					
					objBusIllegal.ID = System.Int32.Parse(txtID.Text);
					
					objBusIllegal.IllegalDateTime = System.DateTime.Parse(txtIllegalDateTime.Text);
					
					objBusIllegal.IllegalAddress = txtIllegalAddress.Text;
					
					objBusIllegal.IllegalContent = txtIllegalContent.Text;
					
					objBusIllegal.ProcessMan = txtProcessMan.Text;
					
					objBusIllegal.ProcessResult = txtProcessResult.Text;
					
					objBusIllegal.BusID = System.Int32.Parse(txtBusID.Text);
					
					objBusIllegal.BusLicense = txtBusLicense.Text;
					
					objBusIllegal.UpdateUser =  UserName;

                    objBusIllegal.UpdateDateTime = System.DateTime.Now;
          
					BusIllegalBiz.UpdateBusIllegal(objBusIllegal);
				}
				lblMessage.Text = "保存成功！";
			}
			catch(Exception ex)
			{
				lblMessage.Text = ex.Message;
			}
		}
	}
