93 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			93 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using System;
 | |
| 
 | |
| namespace FineUIPro.Web.TestRun.PersonTrain
 | |
| {
 | |
|     public partial class TrainContractEdit : PageBase
 | |
|     {
 | |
|         #region 加载
 | |
|         /// <summary>
 | |
|         /// 页面加载
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 string id = Request.Params["id"];
 | |
|                 if (!string.IsNullOrEmpty(id))
 | |
|                 {
 | |
|                     Model.TestRun_TrainContract data = BLL.TrainContractService.GetTrainContractById(id);
 | |
|                     if (data != null)
 | |
|                     {
 | |
|                         this.hdId.Text = id;
 | |
|                         this.txtTrainContractDate.Text = data.TrainContractDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.TrainContractDate) : "";
 | |
|                         this.txtTrainContractCode.Text = data.TrainContractCode;
 | |
|                         this.txtTrainContractName.Text = data.TrainContractName;
 | |
|                         this.txtRemark.Text = data.Remark;
 | |
|                     }
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     this.txtTrainContractDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #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.TestRun_TrainContract));
 | |
|             }
 | |
|             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/PersonTrain/TrainContract&menuId={1}", this.hdId.Text, BLL.Const.TrainContractMenuId)));
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 保存
 | |
|         /// <summary>
 | |
|         /// 保存按钮
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnSave_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             string id = Request.Params["id"];
 | |
|             Model.TestRun_TrainContract newData = new Model.TestRun_TrainContract();
 | |
|             newData.TrainContractCode = this.txtTrainContractCode.Text.Trim();
 | |
|             newData.TrainContractName = this.txtTrainContractName.Text.Trim();
 | |
|             newData.TrainContractDate = Funs.GetNewDateTime(this.txtTrainContractDate.Text.Trim());
 | |
|             newData.Remark = this.txtRemark.Text.Trim();
 | |
|             newData.ProjectId = this.CurrUser.LoginProjectId;
 | |
|             if (!string.IsNullOrEmpty(id))
 | |
|             {
 | |
|                 newData.TrainContractId = id;
 | |
|                 BLL.TrainContractService.UpdateTrainContract(newData);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 if (!string.IsNullOrEmpty(this.hdId.Text))
 | |
|                 {
 | |
|                     newData.TrainContractId = this.hdId.Text.Trim();
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     newData.TrainContractId = SQLHelper.GetNewID(typeof(Model.TestRun_TrainContract));
 | |
|                     this.hdId.Text = newData.TrainContractId;
 | |
|                 }
 | |
|                 BLL.TrainContractService.AddTrainContract(newData);
 | |
|             }
 | |
|             ShowNotify("保存成功!", MessageBoxIcon.Success);
 | |
|             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | |
|         }
 | |
|         #endregion
 | |
|     }
 | |
| } |