116 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			116 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using BLL; | |||
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Web; | |||
|  | using System.Web.UI; | |||
|  | using System.Web.UI.WebControls; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.TestRun.DriverSub | |||
|  | { | |||
|  |     public partial class DriverSubContactEdit : PageBase | |||
|  |     { | |||
|  |         #region 加载 | |||
|  |         /// <summary> | |||
|  |         /// 页面加载 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 BLL.UnitService.InitUnitDownList(this.drpSubUnitId, this.CurrUser.LoginProjectId, true); | |||
|  |                 string id = Request.Params["id"]; | |||
|  |                 if (!string.IsNullOrEmpty(id)) | |||
|  |                 { | |||
|  |                     Model.DriverSub_DriverSubContact data = BLL.DriverSubContactService.GetDriverSubContactById(id); | |||
|  |                     if (data != null) | |||
|  |                     { | |||
|  |                         this.hdId.Text = id; | |||
|  |                         this.txtCode.Text = data.Code; | |||
|  |                         if (!string.IsNullOrEmpty(data.SubUnitId)) | |||
|  |                         { | |||
|  |                             this.drpSubUnitId.SelectedValue = data.SubUnitId; | |||
|  |                         } | |||
|  |                         this.txtContactInfo.Text = data.ContactInfo; | |||
|  |                         this.txtChargeManInfo.Text = data.ChargeManInfo; | |||
|  |                         this.txtContactContent.Text = data.ContactContent; | |||
|  |                         this.txtResult.Text = data.Result; | |||
|  |                         this.txtIntTime.Text = data.IntTime.HasValue ? string.Format("{0:yyyy-MM-dd}", data.IntTime) : ""; | |||
|  |                         this.txtOutTime.Text = data.OutTime.HasValue ? string.Format("{0:yyyy-MM-dd}", data.OutTime) : ""; | |||
|  |                         this.txtRemark.Text = data.Remark; | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 附件上传 | |||
|  |         /// <summary> | |||
|  |         /// 附件上传 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnAttach_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (string.IsNullOrEmpty(this.hdId.Text))   //新增记录 | |||
|  |             { | |||
|  |                 this.hdId.Text = SQLHelper.GetNewID(typeof(Model.DriverSub_DriverSubContact)); | |||
|  |             } | |||
|  |             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverSub/DriverSubContact&menuId={1}", this.hdId.Text, BLL.Const.DriverSubContactMenuId))); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 保存 | |||
|  |         /// <summary> | |||
|  |         /// 保存按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnSave_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (this.drpSubUnitId.SelectedValue == BLL.Const._Null) | |||
|  |             { | |||
|  |                 Alert.ShowInTop("请选择开车分包单位!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |             string id = Request.Params["id"]; | |||
|  |             Model.DriverSub_DriverSubContact newData = new Model.DriverSub_DriverSubContact(); | |||
|  |             newData.Code = this.txtCode.Text.Trim(); | |||
|  |             if (this.drpSubUnitId.SelectedValue != BLL.Const._Null) | |||
|  |             { | |||
|  |                 newData.SubUnitId = this.drpSubUnitId.SelectedValue; | |||
|  |             } | |||
|  |             newData.ContactInfo = this.txtContactInfo.Text.Trim(); | |||
|  |             newData.ChargeManInfo = this.txtChargeManInfo.Text.Trim(); | |||
|  |             newData.ContactContent = this.txtContactContent.Text.Trim(); | |||
|  |             newData.Result = this.txtResult.Text.Trim();             | |||
|  |             newData.IntTime = Funs.GetNewDateTime(this.txtIntTime.Text.Trim()); | |||
|  |             newData.OutTime = Funs.GetNewDateTime(this.txtOutTime.Text.Trim()); | |||
|  |             newData.Remark = this.txtRemark.Text.Trim(); | |||
|  |             newData.ProjectId = this.CurrUser.LoginProjectId; | |||
|  |             if (!string.IsNullOrEmpty(id)) | |||
|  |             { | |||
|  |                 newData.DriverSubContactId = id; | |||
|  |                 BLL.DriverSubContactService.UpdateDriverSubContact(newData); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 if (!string.IsNullOrEmpty(this.hdId.Text)) | |||
|  |                 { | |||
|  |                     newData.DriverSubContactId = this.hdId.Text.Trim(); | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     newData.DriverSubContactId = SQLHelper.GetNewID(typeof(Model.DriverSub_DriverSubContact)); | |||
|  |                     this.hdId.Text = newData.DriverSubContactId; | |||
|  |                 } | |||
|  |                 BLL.DriverSubContactService.AddDriverSubContact(newData); | |||
|  |             } | |||
|  |             ShowNotify("保存成功!", MessageBoxIcon.Success); | |||
|  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | |||
|  |         }         | |||
|  |         #endregion | |||
|  |     } | |||
|  | } |