/// <summary> /// 根据隐患巡检记录Id删除一个隐患巡检记录信息 /// </summary> /// <param name="RegistrationRecordId">隐患巡检记录Id</param> public static void DeleteRegisterRecordByRegisterRecordId(string registrationRecordId) { Model.SUBHSSEDB db = Funs.DB; Model.Inspection_RegistrationRecord RegistrationRecord = db.Inspection_RegistrationRecord.First(e => e.RegistrationRecordId == registrationRecordId); db.Inspection_RegistrationRecord.DeleteOnSubmit(RegistrationRecord); db.SubmitChanges(); }
/// <summary> /// 修改隐患巡检记录信息 /// </summary> /// <param name="RegistrationRecord">隐患巡检记录实体</param> public static void UpdateRegisterRecord(Model.Inspection_RegistrationRecord RegistrationRecord) { Model.SUBHSSEDB db = Funs.DB; Model.Inspection_RegistrationRecord newRegisterRecord = db.Inspection_RegistrationRecord.First(e => e.RegistrationRecordId == RegistrationRecord.RegistrationRecordId); newRegisterRecord.RegistrationIds = RegistrationRecord.RegistrationIds; newRegisterRecord.CheckDate = RegistrationRecord.CheckDate; newRegisterRecord.CheckPerson = RegistrationRecord.CheckPerson; newRegisterRecord.CompileMan = RegistrationRecord.CompileMan; newRegisterRecord.CompileDate = RegistrationRecord.CompileDate; db.SubmitChanges(); }
private void GetRecords() { Model.SUBHSSEDB db = Funs.DB; var registrationList = (from x in db.View_Inspection_Registration where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList(); var checkManList = (from x in registrationList select x.CheckManId).Distinct().ToList(); //获取巡检人集合 var checkDateList = (from x in registrationList select x.CheckTime.Value.Date).Distinct().ToList(); //获取巡检日期集合 foreach (var checkMan in checkManList) { foreach (var checkDate in checkDateList) { Model.Inspection_RegistrationRecord oldRecord = BLL.RegistrationRecordService.GetRegisterRecordByCheckManAndDate(checkMan, checkDate); if (oldRecord == null) { var list = from x in registrationList where x.CheckManId == checkMan && x.CheckTime.Value.Date == checkDate orderby x.CheckTime select x; if (list.Count() > 0) { Model.Inspection_RegistrationRecord record = new Model.Inspection_RegistrationRecord { RegistrationRecordId = SQLHelper.GetNewID(typeof(Model.Inspection_RegistrationRecord)), ProjectId = this.CurrUser.LoginProjectId }; string registrationIds = string.Empty; foreach (var item in list) { registrationIds += item.RegistrationId + ","; } if (!string.IsNullOrEmpty(registrationIds)) { registrationIds = registrationIds.Substring(0, registrationIds.LastIndexOf(",")); } record.RegistrationIds = registrationIds; record.CheckDate = checkDate; record.CheckPerson = checkMan; record.CompileMan = this.CurrUser.UserId; record.CompileDate = DateTime.Now; db.Inspection_RegistrationRecord.InsertOnSubmit(record); db.SubmitChanges(); } } } } }
/// <summary> /// 增加隐患巡检记录信息 /// </summary> /// <param name="RegistrationRecord">隐患巡检记录实体</param> public static void AddRegisterRecord(Model.Inspection_RegistrationRecord RegistrationRecord) { Model.SUBHSSEDB db = Funs.DB; Model.Inspection_RegistrationRecord newRegisterRecord = new Model.Inspection_RegistrationRecord { RegistrationRecordId = RegistrationRecord.RegistrationRecordId, ProjectId = RegistrationRecord.ProjectId, RegistrationIds = RegistrationRecord.RegistrationIds, CheckDate = RegistrationRecord.CheckDate, CheckPerson = RegistrationRecord.CheckPerson, CompileMan = RegistrationRecord.CompileMan, CompileDate = RegistrationRecord.CompileDate }; db.Inspection_RegistrationRecord.InsertOnSubmit(newRegisterRecord); db.SubmitChanges(); }
/// <summary> /// 页面加载时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //if (!string.IsNullOrEmpty(Request.Params["type"])) //{ // this.btnSave.Hidden = true; //} LoadData(); var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.RegistrationRecordMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnSave)) { this.btnSave.Hidden = false; } } string registrationRecordId = Request.Params["RegistrationRecordId"]; Model.Inspection_RegistrationRecord record = BLL.RegistrationRecordService.GetRegisterRecordByRegisterRecordId(registrationRecordId); if (record != null) { if (record.CheckDate != null) { this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", record.CheckDate); } if (!string.IsNullOrEmpty(record.CheckPerson)) { Model.Sys_User user = BLL.UserService.GetUserByUserId(record.CheckPerson); if (user != null) { this.txtCheckMan.Text = user.UserName; } } BindGrid(record.CheckPerson, record.CheckDate.Value.Date); } else { this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } }
/// <summary> /// 保存按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { Model.Inspection_RegistrationRecord record = BLL.RegistrationRecordService.GetRegisterRecordByRegisterRecordId(Request.Params["RegistrationRecordId"]); if (record != null) { string registrationIds = string.Empty; for (int i = 0; i < this.Grid1.Rows.Count; i++) { registrationIds += this.Grid1.Rows[i].RowID + ","; } if (!string.IsNullOrEmpty(registrationIds)) { registrationIds = registrationIds.Substring(0, registrationIds.LastIndexOf(",")); } record.RegistrationIds = registrationIds; record.CompileMan = this.CurrUser.UserId; record.CompileDate = DateTime.Now; BLL.RegistrationRecordService.UpdateRegisterRecord(record); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }