220 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			220 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using BLL; | |||
|  | using System; | |||
|  | using System.Collections; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Data; | |||
|  | using System.Globalization; | |||
|  | using System.Linq; | |||
|  | using System.Threading.Tasks; | |||
|  | using System.Web; | |||
|  | using System.Web.UI; | |||
|  | using System.Web.UI.WebControls; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.CQMS.Check | |||
|  | { | |||
|  |     public partial class TrainTestRecordEdit : PageBase | |||
|  |     { | |||
|  |         #region 公共字段 | |||
|  |         /// <summary> | |||
|  |         /// 主键 | |||
|  |         /// </summary> | |||
|  |         public string TrainingTestRecordId | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return (string)ViewState["TrainingTestRecordId"]; | |||
|  |             } | |||
|  |             set | |||
|  |             { | |||
|  |                 ViewState["TrainingTestRecordId"] = value; | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, false); | |||
|  |                 var trainType = Funs.DB.Base_TrainType.OrderBy(u => u.TrainTypeCode).ToList(); | |||
|  |                 drpType.DataValueField = "TrainTypeId"; | |||
|  |                 drpType.DataTextField = "TrainTypeName"; | |||
|  |                 this. drpType.DataSource = trainType; | |||
|  |                 this. drpType.DataBind(); | |||
|  |                 Funs.FineUIPleaseSelect(drpType); | |||
|  |                 TrainingTestRecordId = Request.Params["TrainingTestRecordId"]; | |||
|  | 
 | |||
|  |                 if (!string.IsNullOrEmpty(TrainingTestRecordId)) | |||
|  |                 { | |||
|  |                     this.hdCheckControlCode.Text = TrainingTestRecordId; | |||
|  | 
 | |||
|  |                     var dt = CheckControlApproveService.getListData(TrainingTestRecordId); | |||
|  | 
 | |||
|  |                     Model.Training_TrainTestRecord trainTestRecord = TrainTestRecordService.GetTrainTestRecordById(TrainingTestRecordId); | |||
|  |                     this.txtTrainingName.Text = trainTestRecord.TrainingName; | |||
|  |                     if (!string.IsNullOrEmpty(trainTestRecord.UnitId)) | |||
|  |                     { | |||
|  |                         this.drpUnit.SelectedValue = trainTestRecord.UnitId; | |||
|  |                     } | |||
|  |                     if (trainTestRecord.DateA.HasValue) | |||
|  |                     { | |||
|  |                         this.txtDateA.Text = trainTestRecord.DateA.Value.ToString("yyyy-MM-dd HH:mm:ss"); | |||
|  |                     } | |||
|  |                     if (trainTestRecord.DateZ.HasValue) | |||
|  |                     { | |||
|  |                         this.txtDateZ.Text = trainTestRecord.DateZ.Value.ToString("yyyy-MM-dd HH:mm:ss"); | |||
|  |                     } | |||
|  |                     if (!string.IsNullOrEmpty(trainTestRecord.TrainingType)) | |||
|  |                     { | |||
|  |                         this.drpType.SelectedValue = trainTestRecord.TrainingType; | |||
|  |                     } | |||
|  |                     this.txtPeopleNum.Text = trainTestRecord.PeopleNum; | |||
|  |                 } | |||
|  | 
 | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         #region 附件上传 | |||
|  |         /// <summary> | |||
|  |         /// 上传附件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnAttach_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (string.IsNullOrEmpty(this.hdCheckControlCode.Text))   //新增记录 | |||
|  |             { | |||
|  |                 this.hdCheckControlCode.Text = SQLHelper.GetNewID(typeof(Model.Training_TrainTestRecord)); | |||
|  |             } | |||
|  |             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/CheckControl&menuId={2}", "1", this.hdCheckControlCode.Text + "r", BLL.Const.CheckListMenuId))); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  |         protected void imgBtnFile_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (string.IsNullOrEmpty(this.hdCheckControlCode.Text))   //新增记录 | |||
|  |             { | |||
|  |                 this.hdCheckControlCode.Text = SQLHelper.GetNewID(typeof(Model.Training_TrainTestRecord)); | |||
|  |             } | |||
|  |             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/CheckControl&menuId={2}", "1", this.hdCheckControlCode.Text + "re", BLL.Const.CheckListMenuId))); | |||
|  |         } | |||
|  | 
 | |||
|  |         protected void btnSave_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             //string projectId, string userId, string menuId, string buttonName) | |||
|  |             if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectTrainTestRecordMenuId1, BLL.Const.BtnSave)) | |||
|  |             { | |||
|  |                 if (string.IsNullOrEmpty(txtTrainingName.Text.ToString())) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("培训名称必填!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 if (drpUnit.SelectedValue == null || drpUnit.SelectedValue == BLL.Const._Null) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("培训名称必填!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 if (string.IsNullOrEmpty(txtDateA.Text.ToString())) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("开始时间必填!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 if (string.IsNullOrEmpty(txtDateA.Text.ToString())) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("结束时间必填!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 if (drpType.SelectedValue==null||drpType.SelectedValue == BLL.Const._Null) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("培训类型必填!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 if (string.IsNullOrEmpty(txtPeopleNum.Text.ToString())) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("培训人数必填!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 SavePauseNotice("save"); | |||
|  |                 PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | |||
|  |                 //Response.Redirect("/check/CheckList.aspx"); | |||
|  | 
 | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         #region 保存处理 | |||
|  |         /// <summary> | |||
|  |         /// 保存方法 | |||
|  |         /// </summary> | |||
|  |         private void SavePauseNotice(string saveType) | |||
|  |         { | |||
|  |             Model.Training_TrainTestRecord checkControl = new Model.Training_TrainTestRecord(); | |||
|  |             checkControl.TrainingName = this.txtTrainingName.Text.Trim(); | |||
|  |             checkControl.ProjectId = this.CurrUser.LoginProjectId; | |||
|  |             if (this.drpUnit.SelectedValue != Const._Null) | |||
|  |             { | |||
|  |                 checkControl.UnitId = this.drpUnit.SelectedValue; | |||
|  |             } | |||
|  |             if (this.drpType.SelectedValue != Const._Null) | |||
|  |             { | |||
|  |                 checkControl.TrainingType = this.drpType.SelectedValue; | |||
|  |             } | |||
|  | 
 | |||
|  |             if (!string.IsNullOrEmpty(this.txtDateA.Text.Trim())) | |||
|  |             { | |||
|  |                 DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); | |||
|  | 
 | |||
|  |                 dtFormat.ShortDatePattern = "yyyy-MM-dd HH:mm:ss"; | |||
|  |                 checkControl.DateA = Convert.ToDateTime(this.txtDateA.Text.Trim(), dtFormat); | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(this.txtDateZ.Text.Trim())) | |||
|  |             { | |||
|  |                 DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); | |||
|  | 
 | |||
|  |                 dtFormat.ShortDatePattern = "yyyy-MM-dd HH:mm:ss"; | |||
|  |                 checkControl.DateZ = Convert.ToDateTime(this.txtDateZ.Text.Trim(), dtFormat); | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(this.txtPeopleNum.Text.Trim())) | |||
|  |             { | |||
|  |                 checkControl.PeopleNum =this.txtPeopleNum.Text.Trim(); | |||
|  |             } | |||
|  |             //checkControl.AttachUrl = this.hdFilePath.Value; | |||
|  | 
 | |||
|  |             if (!string.IsNullOrEmpty(TrainingTestRecordId) && BLL.TrainTestRecordService.GetTrainTestRecordById(Request.Params["TrainingTestRecordId"]) != null) | |||
|  |             { | |||
|  | 
 | |||
|  |                 checkControl.TrainingTestRecordId = TrainingTestRecordId; | |||
|  |                 BLL.TrainTestRecordService.UpdateTrainTestRecord(checkControl); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 checkControl.TrainingTestRecordId = Guid.NewGuid().ToString(); | |||
|  |                 BLL.TrainTestRecordService.AddTestRecord(checkControl); | |||
|  | 
 | |||
|  |             } | |||
|  | 
 | |||
|  | 
 | |||
|  |             BLL.LogService.AddSys_Log(this.CurrUser, checkControl.TrainingTestRecordId, TrainingTestRecordId, BLL.Const.CheckListMenuId, "编辑质量巡检记录"); | |||
|  |             //BLL.LogService.AddLog(this.CurrUser.UserId, "编辑质量巡检记录", this.CurrUser.LoginProjectId); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  |         protected void WindowAtt_Close(object sender, WindowCloseEventArgs e) | |||
|  |         { | |||
|  | 
 | |||
|  |         } | |||
|  |     } | |||
|  | } |