/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Params["CheckDayDetailId"])) { Model.Check_CheckDayDetail detail = BLL.Check_CheckDayDetailService.GetCheckDayDetailByCheckDayDetailId(Request.Params["CheckDayDetailId"]); if (detail != null) { detail.CompleteStatus = true; detail.CompletedDate = Funs.GetNewDateTime(this.txtCompletedDate.Text.Trim()); BLL.Check_CheckDayDetailService.UpdateCheckDayDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckSpecialDetailId"])) { Model.Check_CheckSpecialDetail detail = BLL.Check_CheckSpecialDetailService.GetCheckSpecialDetailByCheckSpecialDetailId(Request.Params["CheckSpecialDetailId"]); if (detail != null) { detail.CompleteStatus = true; detail.CompletedDate = Funs.GetNewDateTime(this.txtCompletedDate.Text.Trim()); BLL.Check_CheckSpecialDetailService.UpdateCheckSpecialDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckColligationDetailId"])) { Model.Check_CheckColligationDetail detail = BLL.Check_CheckColligationDetailService.GetCheckColligationDetailByCheckColligationDetailId(Request.Params["CheckColligationDetailId"]); if (detail != null) { detail.CompleteStatus = true; detail.CompletedDate = Funs.GetNewDateTime(this.txtCompletedDate.Text.Trim()); BLL.Check_CheckColligationDetailService.UpdateCheckColligationDetail(detail); } } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }
/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (this.drpHandleStep.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择处理措施!", MessageBoxIcon.Warning); return; } Model.Check_CheckColligationDetail detail = BLL.Check_CheckColligationDetailService.GetCheckColligationDetailByCheckColligationDetailId(this.CheckColligationDetailId); if (detail != null) { detail.Unqualified = this.txtUnqualified.Text.Trim(); detail.Suggestions = this.txtSuggestions.Text.Trim(); detail.WorkArea = this.txtWorkArea.Text.Trim(); if (this.drpUnit.SelectedValue != BLL.Const._Null) { detail.UnitId = this.drpUnit.SelectedValue; } if (this.drpHandleStep.SelectedValue != BLL.Const._Null) { detail.HandleStep = this.drpHandleStep.SelectedValue; } if (this.txtLimitedDate.Enabled == true) { detail.LimitedDate = Funs.GetNewDateTime(this.txtLimitedDate.Text.Trim()); } detail.CompleteStatus = Convert.ToBoolean(this.drpCompleteStatus.SelectedValue); detail.CheckContent = this.txtCheckItem.Text.Trim(); BLL.Check_CheckColligationDetailService.UpdateCheckColligationDetail(detail); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }
/// <summary> /// 增加综合检查明细信息 /// </summary> /// <param name="CheckColligationDetail"></param> public static void AddCheckColligationDetail(Model.Check_CheckColligationDetail CheckColligationDetail) { Model.SUBHSSEDB db = Funs.DB; Model.Check_CheckColligationDetail newCheckColligationDetail = new Model.Check_CheckColligationDetail { CheckColligationDetailId = CheckColligationDetail.CheckColligationDetailId, CheckColligationId = CheckColligationDetail.CheckColligationId, CheckItem = CheckColligationDetail.CheckItem, CheckItemType = CheckColligationDetail.CheckItemType, Unqualified = CheckColligationDetail.Unqualified, CheckArea = CheckColligationDetail.CheckArea, UnitId = CheckColligationDetail.UnitId, HandleStep = CheckColligationDetail.HandleStep, CompleteStatus = CheckColligationDetail.CompleteStatus, RectifyNoticeId = CheckColligationDetail.RectifyNoticeId, LimitedDate = CheckColligationDetail.LimitedDate, CompletedDate = CheckColligationDetail.CompletedDate, Suggestions = CheckColligationDetail.Suggestions, WorkArea = CheckColligationDetail.WorkArea, CheckContent = CheckColligationDetail.CheckContent, HiddenDangerType = CheckColligationDetail.HiddenDangerType, HiddenDangerLevel = CheckColligationDetail.HiddenDangerLevel, PersonId = CheckColligationDetail.PersonId }; db.Check_CheckColligationDetail.InsertOnSubmit(newCheckColligationDetail); db.SubmitChanges(); }
/// <summary> /// 闭环 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCompletedDate_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string CheckColligationId = Grid1.SelectedRowID.Split(',')[0]; var checkColligation = BLL.Check_CheckColligationService.GetCheckColligationByCheckColligationId(CheckColligationId); if (checkColligation.States == BLL.Const.State_2) { string CheckColligationDetailId = Grid1.SelectedRowID.Split(',')[1]; Model.Check_CheckColligationDetail detail = BLL.Check_CheckColligationDetailService.GetCheckColligationDetailByCheckColligationDetailId(CheckColligationDetailId); if (detail != null && !detail.CompletedDate.HasValue) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ShowCompletedDate.aspx?CheckColligationDetailId={0}", CheckColligationDetailId), "编辑闭环时间", 400, 250)); } else { Alert.ShowInTop("该记录已闭环或不存在明细项!", MessageBoxIcon.Warning); return; } } else { Alert.ShowInTop("该记录尚未审批完成,无法进行闭环操作!", MessageBoxIcon.Warning); return; } }
/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (this.drpHandleStep.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择处理措施!", MessageBoxIcon.Warning); return; } if (this.drpHiddenDangerLevel.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择隐患级别!", MessageBoxIcon.Warning); return; } Model.Check_CheckColligationDetail detail = new Model.Check_CheckColligationDetail(); detail.Unqualified = this.txtUnqualified.Text.Trim(); detail.WorkArea = this.txtWorkArea.Text.Trim(); detail.LimitedDate = Funs.GetNewDateTime(this.txtLimitedDate.Text.Trim()); detail.HiddenDangerType = this.txtHiddenDangerType.Text.Trim(); if (this.drpHiddenDangerLevel.SelectedValue != BLL.Const._Null) { detail.HiddenDangerLevel = this.drpHiddenDangerLevel.SelectedValue; } if (this.drpUnit.SelectedValue != BLL.Const._Null) { detail.UnitId = this.drpUnit.SelectedValue; } if (this.drpPerson.SelectedValue != BLL.Const._Null) { detail.PersonId = this.drpPerson.SelectedValue; } detail.Suggestions = this.txtSuggestions.Text.Trim(); if (drpHandleStep.SelectedItem != null) { string hs = string.Empty; foreach (ListItem item in drpHandleStep.SelectedItemArray) { hs += item.Value + "|"; } if (!string.IsNullOrEmpty(hs)) { hs = hs.Substring(0, hs.LastIndexOf('|')); } detail.HandleStep = hs; } if (!string.IsNullOrEmpty(this.CheckColligationDetailId)) { detail.CheckColligationDetailId = this.CheckColligationDetailId; BLL.Check_CheckColligationDetailService.UpdateCheckColligationDetail(detail); } else { detail.CheckColligationId = Request.Params["CheckColligationId"]; this.CheckColligationDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckColligationDetail)); detail.CheckColligationDetailId = this.CheckColligationDetailId; BLL.Check_CheckColligationDetailService.AddCheckColligationDetail(detail); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }
/// <summary> /// 生成隐患整改单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnMenuRectify_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string rectifyNoticeCode = string.Empty; string CheckColligationId = Grid1.SelectedRowID.Split(',')[0]; var checkColligation = BLL.Check_CheckColligationService.GetCheckColligationByCheckColligationId(CheckColligationId); if (checkColligation.States == BLL.Const.State_2) { string CheckColligationDetailId = Grid1.SelectedRowID.Split(',')[1]; Model.Check_CheckColligationDetail detail = BLL.Check_CheckColligationDetailService.GetCheckColligationDetailByCheckColligationDetailId(CheckColligationDetailId); if (string.IsNullOrEmpty(detail.RectifyNoticeId)) { Model.Check_RectifyNotices rectifyNotice = new Model.Check_RectifyNotices { RectifyNoticesId = SQLHelper.GetNewID(typeof(Model.Check_RectifyNotice)), ProjectId = checkColligation.ProjectId, UnitId = detail.UnitId, CheckedDate = checkColligation.CheckTime, RectifyNoticesCode = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectRectifyNoticeMenuId, checkColligation.ProjectId, detail.UnitId), WrongContent = "开展了综合检查,发现问题及隐患:" + detail.Unqualified + "\n" + detail.Suggestions, SignPerson = this.CurrUser.UserId, SignDate = DateTime.Now, }; var workArea = Funs.DB.ProjectData_WorkArea.FirstOrDefault(x => x.ProjectId == checkColligation.ProjectId && x.WorkAreaName == detail.WorkArea); if (workArea != null) { rectifyNotice.WorkAreaId = workArea.WorkAreaId; } BLL.RectifyNoticesService.AddRectifyNotices(rectifyNotice); rectifyNoticeCode = rectifyNotice.RectifyNoticesCode; detail.RectifyNoticeId = rectifyNotice.RectifyNoticesId; BLL.Check_CheckColligationDetailService.UpdateCheckColligationDetail(detail); ///写入工程师日志 BLL.HSSELogService.CollectHSSELog(rectifyNotice.ProjectId, rectifyNotice.SignPerson, rectifyNotice.SignDate, "22", rectifyNotice.WrongContent, Const.BtnAdd, 1); } if (!string.IsNullOrEmpty(rectifyNoticeCode)) { Alert.ShowInTop("已生成隐患整改通知单:" + rectifyNoticeCode + "!", MessageBoxIcon.Success); } else { Alert.ShowInTop("隐患整改通知单已存在,请到对应模块进行处理!", MessageBoxIcon.Warning); } } else { Alert.ShowInTop("该记录尚未审批完成,无法进行操作!", MessageBoxIcon.Warning); return; } }
/// <summary> /// 绑定数据 /// </summary> private void BindGrid() { SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@ProjectId", this.ProjectId), new SqlParameter("@StartTime", !string.IsNullOrEmpty(this.txtStartTime.Text)?this.txtStartTime.Text:null), new SqlParameter("@EndTime", !string.IsNullOrEmpty(this.txtEndTime.Text)?this.txtEndTime.Text:null), new SqlParameter("@States", !string.IsNullOrEmpty(Request.Params["projectId"])?BLL.Const.State_2:null), new SqlParameter("@UnitName", !string.IsNullOrEmpty(this.txtUnitName.Text)?this.txtUnitName.Text:null), new SqlParameter("@WorkAreaName", !string.IsNullOrEmpty(this.txtWorkAreaName.Text)?this.txtWorkAreaName.Text:null), }; DataTable tb = SQLHelper.GetDataTableRunProc("SpCheckColligationStatistic", parameter); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid1.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); for (int i = 0; i < Grid1.Rows.Count; i++) { string[] rowID = Grid1.Rows[i].DataKeys[0].ToString().Split(','); if (rowID.Count() > 0) { var checkColligation = BLL.Check_CheckColligationService.GetCheckColligationByCheckColligationId(rowID[0]); if (checkColligation != null) { if (checkColligation.States == BLL.Const.State_2) { if (rowID.Count() > 1) { Model.Check_CheckColligationDetail detail = BLL.Check_CheckColligationDetailService.GetCheckColligationDetailByCheckColligationDetailId(rowID[1]); if (detail != null) { if (!detail.CompletedDate.HasValue) { Grid1.Rows[i].RowCssClass = "Yellow"; } } //else //{ // Grid1.Rows[i].RowCssClass = "Red"; //} } } else { Grid1.Rows[i].RowCssClass = "Green"; } } } } }
/// <summary> /// 批量删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnMenuDel_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length > 0) { foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); var RectifyNotices = BLL.RectifyNoticesService.GetRectifyNoticesById(rowID); if (RectifyNotices != null) { LogService.AddSys_Log(this.CurrUser, RectifyNotices.RectifyNoticesCode, rowID, BLL.Const.ProjectRectifyNoticeMenuId, BLL.Const.BtnDelete); RectifyNoticesService.DeleteRectifyNoticesById(rowID); Model.Check_CheckDayDetail dayDetail = (from x in Funs.DB.Check_CheckDayDetail where x.RectifyNoticeId == rowID select x).FirstOrDefault(); Model.Check_CheckSpecialDetail specialDetail = (from x in Funs.DB.Check_CheckSpecialDetail where x.RectifyNoticeId == rowID select x).FirstOrDefault(); Model.Check_CheckColligationDetail colligationDetail = (from x in Funs.DB.Check_CheckColligationDetail where x.RectifyNoticeId == rowID select x).FirstOrDefault(); if (dayDetail != null) { dayDetail.RectifyNoticeId = null; Funs.DB.SubmitChanges(); } else if (specialDetail != null) { specialDetail.RectifyNoticeId = null; Funs.DB.SubmitChanges(); } else if (colligationDetail != null) { colligationDetail.RectifyNoticeId = null; Funs.DB.SubmitChanges(); } } } BindGrid(); ShowNotify("删除数据成功!(表格数据已重新绑定)"); } }
/// <summary> /// 根据隐患通知单ID删除所有隐患通知单明细信息 /// </summary> /// <param name="rectifyNoticeId"></param> public static void DeleteRectifyNoticeDetails(string rectifyNoticeId) { Model.SUBHSSEDB db = Funs.DB; var q = (from x in db.Check_RectifyNoticeDetail where x.RectifyNoticeId == rectifyNoticeId select x).ToList(); if (q != null) { foreach (var item in q) { ////删除附件表 BLL.CommonService.DeleteAttachFileById(item.RectifyNoticeDetailId); Model.Check_CheckDayDetail dayDetail = BLL.Check_CheckDayDetailService.GetCheckDayDetailByCheckDayDetailId(item.RectifyNoticeDetailId); if (dayDetail != null) { dayDetail.RectifyNoticeId = null; BLL.Check_CheckDayDetailService.UpdateCheckDayDetail(dayDetail); } else { Model.Check_CheckSpecialDetail specialDetail = BLL.Check_CheckSpecialDetailService.GetCheckSpecialDetailByCheckSpecialDetailId(item.RectifyNoticeDetailId); if (specialDetail != null) { specialDetail.RectifyNoticeId = null; BLL.Check_CheckSpecialDetailService.UpdateCheckSpecialDetail(specialDetail); } else { Model.Check_CheckColligationDetail colligationDetail = BLL.Check_CheckColligationDetailService.GetCheckColligationDetailByCheckColligationDetailId(item.RectifyNoticeDetailId); if (colligationDetail != null) { colligationDetail.RectifyNoticeId = null; BLL.Check_CheckColligationDetailService.UpdateCheckColligationDetail(colligationDetail); } } } } db.Check_RectifyNoticeDetail.DeleteAllOnSubmit(q); db.SubmitChanges(); } }
/// <summary> /// 修改综合检查明细信息 /// </summary> /// <param name="CheckColligationDetail"></param> public static void UpdateCheckColligationDetail(Model.Check_CheckColligationDetail CheckColligationDetail) { Model.SUBHSSEDB db = Funs.DB; var newCheckColligationDetail = db.Check_CheckColligationDetail.FirstOrDefault(x => x.CheckColligationDetailId == CheckColligationDetail.CheckColligationDetailId); if (newCheckColligationDetail != null) { newCheckColligationDetail.Unqualified = CheckColligationDetail.Unqualified; newCheckColligationDetail.CheckArea = CheckColligationDetail.CheckArea; newCheckColligationDetail.UnitId = CheckColligationDetail.UnitId; newCheckColligationDetail.HandleStep = CheckColligationDetail.HandleStep; newCheckColligationDetail.CompleteStatus = CheckColligationDetail.CompleteStatus; newCheckColligationDetail.RectifyNoticeId = CheckColligationDetail.RectifyNoticeId; newCheckColligationDetail.LimitedDate = CheckColligationDetail.LimitedDate; newCheckColligationDetail.CompletedDate = CheckColligationDetail.CompletedDate; newCheckColligationDetail.Suggestions = CheckColligationDetail.Suggestions; newCheckColligationDetail.WorkArea = CheckColligationDetail.WorkArea; newCheckColligationDetail.CheckContent = CheckColligationDetail.CheckContent; newCheckColligationDetail.HiddenDangerType = CheckColligationDetail.HiddenDangerType; newCheckColligationDetail.HiddenDangerLevel = CheckColligationDetail.HiddenDangerLevel; newCheckColligationDetail.PersonId = CheckColligationDetail.PersonId; db.SubmitChanges(); } }
/// <summary> /// Grid1行点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { string checkColligationDetailId = Grid1.DataKeys[e.RowIndex][0].ToString(); Model.Check_CheckColligationDetail detail = BLL.Check_CheckColligationDetailService.GetCheckColligationDetailByCheckColligationDetailId(checkColligationDetailId); if (e.CommandName == "click") { Model.Check_CheckColligationDetail newDetail = new Model.Check_CheckColligationDetail { CheckColligationDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckColligationDetail)), CheckColligationId = detail.CheckColligationId, CheckItem = detail.CheckItem, CheckContent = detail.CheckContent, Unqualified = "隐患", Suggestions = "整改", CompleteStatus = true }; BLL.Check_CheckColligationDetailService.AddCheckColligationDetail(newDetail); checkColligationDetails = (from x in Funs.DB.View_Check_CheckColligationDetail where x.CheckColligationId == this.CheckColligationId orderby x.CheckItem select x).ToList(); Grid1.DataSource = checkColligationDetails; Grid1.DataBind(); SetColor(); } }
/// <summary> /// 生成隐患整改通知单按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCreateRectifyNotice_Click(object sender, EventArgs e) { if (this.Grid1.Rows.Count == 0) { Alert.ShowInTop("请先增加检查记录!", MessageBoxIcon.Warning); return; } int n = 0; for (int i = 0; i < this.Grid1.Rows.Count; i++) { if (this.Grid1.Rows[i].Values[7].ToString() == "隐患整改通知单") { n++; break; } } if (n == 0) { Alert.ShowInTop("没有需要生成隐患整改通知单的检查项!", MessageBoxIcon.Warning); return; } string unitIds = string.Empty; string rectifyNoticeAndUnitIds = string.Empty; string rectifyNoticeCode = string.Empty; for (int i = 0; i < this.Grid1.Rows.Count; i++) { if (this.Grid1.Rows[i].Values[7].ToString() == "隐患整改通知单") { Model.Check_CheckColligationDetail detail = BLL.Check_CheckColligationDetailService.GetCheckColligationDetailByCheckColligationDetailId(this.Grid1.Rows[i].DataKeys[0].ToString()); if (string.IsNullOrEmpty(detail.RectifyNoticeId)) { string unitId = this.Grid1.Rows[i].Values[10].ToString(); if (!unitIds.Contains(unitId)) { Model.Check_RectifyNotice rectifyNotice = new Model.Check_RectifyNotice { RectifyNoticeId = SQLHelper.GetNewID(typeof(Model.Check_RectifyNotice)), ProjectId = this.CurrUser.LoginProjectId, UnitId = unitId, RectifyNoticeCode = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectRectifyNoticeMenuId, this.CurrUser.LoginProjectId, unitId) }; rectifyNotice.CheckArea += this.Grid1.Rows[i].Values[11].ToString(); BLL.Check_RectifyNoticeService.AddRectifyNotice(rectifyNotice); Model.Check_RectifyNoticeDetail d = new Model.Check_RectifyNoticeDetail { RectifyNoticeDetailId = detail.CheckColligationDetailId, RectifyNoticeId = rectifyNotice.RectifyNoticeId, CheckItem = detail.CheckItem, CheckItemType = detail.CheckItemType, Unqualified = detail.Unqualified, CheckArea = detail.CheckArea, UnitId = detail.UnitId, Suggestions = detail.Suggestions, CheckContent = detail.CheckContent }; BLL.Check_RectifyNoticeDetailService.AddRectifyNoticeDetail(d); unitIds += unitId + ","; rectifyNoticeAndUnitIds += rectifyNotice.RectifyNoticeId + "," + unitId + "|"; detail.RectifyNoticeId = rectifyNotice.RectifyNoticeId; BLL.Check_CheckColligationDetailService.UpdateCheckColligationDetail(detail); if (string.IsNullOrEmpty(rectifyNoticeCode)) { rectifyNoticeCode += rectifyNotice.RectifyNoticeCode; } else { rectifyNoticeCode += "," + rectifyNotice.RectifyNoticeCode; } } else { string[] list = rectifyNoticeAndUnitIds.Split('|'); foreach (var item in list) { if (item.Contains(unitId)) { string rectifyNoticeId = item.Split(',')[0]; Model.Check_RectifyNotice rectifyNotice = BLL.Check_RectifyNoticeService.GetRectifyNoticeByRectifyNoticeId(rectifyNoticeId); if (!rectifyNotice.CheckArea.Contains(this.Grid1.Rows[i].Values[11].ToString())) { rectifyNotice.CheckArea += "," + this.Grid1.Rows[i].Values[11].ToString(); } BLL.Check_RectifyNoticeService.UpdateRectifyNotice(rectifyNotice); Model.Check_RectifyNoticeDetail d = new Model.Check_RectifyNoticeDetail { RectifyNoticeDetailId = detail.CheckColligationDetailId, RectifyNoticeId = rectifyNoticeId, CheckItem = detail.CheckItem, CheckItemType = detail.CheckItemType, Unqualified = detail.Unqualified, CheckArea = detail.CheckArea, UnitId = detail.UnitId, Suggestions = detail.Suggestions, CheckContent = detail.CheckContent }; BLL.Check_RectifyNoticeDetailService.AddRectifyNoticeDetail(d); detail.RectifyNoticeId = rectifyNoticeId; BLL.Check_CheckColligationDetailService.UpdateCheckColligationDetail(detail); } } } } } } if (!string.IsNullOrEmpty(rectifyNoticeCode)) { Alert.ShowInTop("已生成隐患整改通知单:" + rectifyNoticeCode + "!", MessageBoxIcon.Success); } else { Alert.ShowInTop("隐患整改通知单已存在,请到对应模块进行处理!", MessageBoxIcon.Warning); } }
/// <summary> /// 将Dataset的数据导入数据库 /// </summary> /// <param name="pds">数据集</param> /// <param name="Cols">数据集行数</param> /// <returns></returns> private bool AddDatasetToSQL(DataTable pds) { string results = string.Empty; int ir = pds.Rows.Count; if (pds != null && ir > 0) { var getCheckColligation = BLL.Check_CheckColligationService.GetCheckColligationByCheckColligationId(this.CheckColligationId); if (getCheckColligation != null) { var units = from x in Funs.DB.Base_Unit select x; var sysConsts = from x in Funs.DB.Sys_Const where x.GroupId == BLL.ConstValue.Group_HandleStep select x; var supCheckSets = from x in Funs.DB.Check_ProjectCheckItemSet where x.ProjectId == this.CurrUser.LoginProjectId && x.SupCheckItem == "0" && x.CheckType == "3" select x; for (int i = 0; i < ir; i++) { string result = string.Empty; string col0 = pds.Rows[i][0].ToString().Trim(); string col1 = pds.Rows[i][1].ToString().Trim(); string col2 = pds.Rows[i][2].ToString().Trim(); string col3 = pds.Rows[i][3].ToString().Trim(); string col4 = pds.Rows[i][4].ToString().Trim(); string col5 = pds.Rows[i][5].ToString().Trim(); string col6 = pds.Rows[i][6].ToString().Trim(); string col7 = pds.Rows[i][7].ToString().Trim(); string col8 = pds.Rows[i][8].ToString().Trim(); if (!string.IsNullOrEmpty(col0) || !string.IsNullOrEmpty(col1)) { if (string.IsNullOrEmpty(col4) || string.IsNullOrEmpty(col5) || string.IsNullOrEmpty(col6)) { result += "第" + (i + 2).ToString() + "行," + "必填项为空!" + "|"; } else { Model.View_Check_CheckColligationDetail newViewDetail = new Model.View_Check_CheckColligationDetail { CheckColligationDetailId = SQLHelper.GetNewID(typeof(Model.View_EduTrain_TrainRecordDetail)), CheckColligationId = getCheckColligation.CheckColligationId, CheckContent = col1, Unqualified = col2, Suggestions = col3, WorkArea = col4, LimitedDate = Funs.GetNewDateTime(col7), }; var checkName = supCheckSets.FirstOrDefault(x => x.CheckItemName == col0); if (checkName != null) { newViewDetail.CheckItem = checkName.CheckItemSetId; newViewDetail.CheckItemStr = checkName.CheckItemName; } else { result += "第" + (i + 2).ToString() + "行," + "项目检查项中不存在!" + "|"; } var unit = units.FirstOrDefault(x => x.UnitName == col5); if (unit != null) { newViewDetail.UnitId = unit.UnitId; newViewDetail.UnitName = unit.UnitName; } else { result += "第" + (i + 2).ToString() + "行," + "单位表中不存在!" + "|"; } var sysConst = sysConsts.FirstOrDefault(x => x.ConstText == col6); if (sysConst != null) { newViewDetail.HandleStepStr = sysConst.ConstText; newViewDetail.HandleStep = sysConst.ConstValue; } else { result += "第" + (i + 2).ToString() + "行," + "常量表中不存在!" + "|"; } newViewDetail.CompleteStatusName = col8; if (col8 == "是") { newViewDetail.CompleteStatus = true; } else { newViewDetail.CompleteStatus = false; } ///判断是否已存在 var addItem = Funs.DB.Check_CheckColligationDetail.FirstOrDefault(x => x.CheckColligationId == newViewDetail.CheckColligationId && x.CheckContent == newViewDetail.CheckContent && x.CheckItem == newViewDetail.CheckItem && x.WorkArea == newViewDetail.WorkArea && x.UnitId == newViewDetail.UnitId); if (addItem == null) { if (string.IsNullOrEmpty(result)) { Model.Check_CheckColligationDetail newDetail = new Model.Check_CheckColligationDetail { CheckColligationDetailId = newViewDetail.CheckColligationDetailId, CheckColligationId = newViewDetail.CheckColligationId, CheckItem = newViewDetail.CheckItem, Unqualified = newViewDetail.Unqualified, UnitId = newViewDetail.UnitId, HandleStep = newViewDetail.HandleStep, CompleteStatus = newViewDetail.CompleteStatus, LimitedDate = newViewDetail.LimitedDate, Suggestions = newViewDetail.Suggestions, CheckContent = newViewDetail.CheckContent, WorkArea = newViewDetail.WorkArea, }; BLL.Check_CheckColligationDetailService.AddCheckColligationDetail(newDetail); ///加入 viewDetails.Add(newViewDetail); } } else { result += "第" + (i + 2).ToString() + "行," + "导入数据重复" + "|"; } if (!string.IsNullOrEmpty(result)) { results += result; } } } } if (viewDetails.Count > 0) { viewDetails = viewDetails.Distinct().ToList(); this.Grid1.Hidden = false; this.Grid1.DataSource = viewDetails; this.Grid1.DataBind(); } if (!string.IsNullOrEmpty(results)) { viewDetails.Clear(); results = "数据导入完成,未成功数据:" + results.Substring(0, results.LastIndexOf("|")); errorInfos = results; Alert alert = new Alert { Message = results, Target = Target.Self }; alert.Show(); } else { errorInfos = string.Empty; ShowNotify("导入成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } else { Alert.ShowInTop("培训数据为空!", MessageBoxIcon.Warning); } } else { Alert.ShowInTop("导入数据为空!", MessageBoxIcon.Warning); } BLL.UploadFileService.DeleteFile(Funs.RootPath, initPath + this.hdFileName.Text); return(true); }
/// <summary> /// 确认按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { List <string> newParentIds = new List <string>(); TreeNode[] nodes = this.tvCheckItemSet.GetCheckedNodes(); foreach (var item in nodes) { if (item.Nodes.Count == 0) { parentIds.Add(item.NodeID); //集合中增加末级节点 if (item.ParentNode != null) { newParentIds.Add(item.ParentNode.NodeID); //记录已增加的末级节点的父级节点集合 } } } foreach (var item in nodes) { if (item.Nodes.Count > 0) { if (!newParentIds.Contains(item.NodeID)) { parentIds.Add(item.NodeID); } } } if (parentIds.Count == 0 && list.Count == 0) { ShowNotify("请至少选择一项!", MessageBoxIcon.Warning); return; } if (!string.IsNullOrEmpty(Request.Params["CheckDayId"])) { foreach (var item in parentIds) { Model.Check_CheckDayDetail detail = new Model.Check_CheckDayDetail { CheckDayDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckDayDetail)), CheckDayId = Request.Params["CheckDayId"], CheckItem = item }; Model.Check_ProjectCheckItemDetail checkItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (checkItemDetail != null) { detail.CheckContent = checkItemDetail.CheckContent; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; } } detail.Unqualified = "隐患"; detail.Suggestions = "整改"; detail.CompleteStatus = true; BLL.Check_CheckDayDetailService.AddCheckDayDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckSpecialId"])) { foreach (var item in parentIds) { Model.Check_CheckSpecialDetail detail = new Model.Check_CheckSpecialDetail { CheckSpecialDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckSpecialDetail)), CheckSpecialId = Request.Params["CheckSpecialId"], CheckItem = item }; Model.Check_ProjectCheckItemDetail checkItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (checkItemDetail != null) { detail.CheckContent = checkItemDetail.CheckContent; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; } } detail.Unqualified = "隐患"; detail.Suggestions = "整改"; detail.CompleteStatus = true; BLL.Check_CheckSpecialDetailService.AddCheckSpecialDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckColligationId"])) { foreach (var item in parentIds) { Model.Check_CheckColligationDetail detail = new Model.Check_CheckColligationDetail { CheckColligationDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckColligationDetail)), CheckColligationId = Request.Params["CheckColligationId"], CheckItem = item }; Model.Check_ProjectCheckItemDetail checkItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (checkItemDetail != null) { detail.CheckContent = checkItemDetail.CheckContent; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; } } detail.Unqualified = "隐患"; detail.Suggestions = "整改"; detail.CompleteStatus = true; BLL.Check_CheckColligationDetailService.AddCheckColligationDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckWorkId"])) { foreach (var item in parentIds) { Model.Check_CheckWorkDetail detail = new Model.Check_CheckWorkDetail { CheckWorkDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckWorkDetail)), CheckWorkId = Request.Params["CheckWorkId"], CheckItem = item, CheckResult = "合格", }; Model.Check_ProjectCheckItemDetail checkItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (checkItemDetail != null) { detail.CheckContent = checkItemDetail.CheckContent; detail.SortIndex = checkItemDetail.SortIndex; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; detail.SortIndex = projectCheckItemDetail.SortIndex; } } BLL.Check_CheckWorkDetailService.AddCheckWorkDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckHolidayId"])) { foreach (var item in parentIds) { Model.Check_CheckHolidayDetail detail = new Model.Check_CheckHolidayDetail { CheckHolidayDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckHolidayDetail)), CheckHolidayId = Request.Params["CheckHolidayId"], CheckItem = item, CheckResult = "合格", }; Model.Check_ProjectCheckItemDetail checkItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (checkItemDetail != null) { detail.CheckContent = checkItemDetail.CheckContent; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; } } BLL.Check_CheckHolidayDetailService.AddCheckHolidayDetail(detail); } } if (!string.IsNullOrEmpty(Request.Params["CheckDayId"])) { foreach (var item in list) { Model.Check_CheckDayDetail detail = new Model.Check_CheckDayDetail { CheckDayDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckDayDetail)), CheckDayId = Request.Params["CheckDayId"], CheckItem = item }; Model.Check_ProjectCheckItemSet checkItemSet = BLL.Check_ProjectCheckItemSetService.GetCheckItemSetById(item); if (checkItemSet != null) { detail.CheckContent = checkItemSet.CheckItemName; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; } } detail.Unqualified = "隐患"; detail.Suggestions = "整改"; detail.CompleteStatus = true; BLL.Check_CheckDayDetailService.AddCheckDayDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckSpecialId"])) { foreach (var item in list) { Model.Check_CheckSpecialDetail detail = new Model.Check_CheckSpecialDetail { CheckSpecialDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckSpecialDetail)), CheckSpecialId = Request.Params["CheckSpecialId"], CheckItem = item }; Model.Check_ProjectCheckItemSet checkItemSet = BLL.Check_ProjectCheckItemSetService.GetCheckItemSetById(item); if (checkItemSet != null) { detail.CheckContent = checkItemSet.CheckItemName; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; } } detail.Unqualified = "隐患"; detail.Suggestions = "整改"; detail.CompleteStatus = true; BLL.Check_CheckSpecialDetailService.AddCheckSpecialDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckColligationId"])) { foreach (var item in list) { Model.Check_CheckColligationDetail detail = new Model.Check_CheckColligationDetail { CheckColligationDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckColligationDetail)), CheckColligationId = Request.Params["CheckColligationId"], CheckItem = item }; Model.Check_ProjectCheckItemSet checkItemSet = BLL.Check_ProjectCheckItemSetService.GetCheckItemSetById(item); if (checkItemSet != null) { detail.CheckContent = checkItemSet.CheckItemName; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; } } detail.Unqualified = "隐患"; detail.Suggestions = "整改"; detail.CompleteStatus = true; BLL.Check_CheckColligationDetailService.AddCheckColligationDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckWorkId"])) { foreach (var item in list) { Model.Check_CheckWorkDetail detail = new Model.Check_CheckWorkDetail { CheckWorkDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckWorkDetail)), CheckWorkId = Request.Params["CheckWorkId"], CheckItem = item }; var checkItemSet = BLL.Check_ProjectCheckItemSetService.GetCheckItemSetById(item); if (checkItemSet != null) { detail.CheckContent = checkItemSet.CheckItemName; } else { var projectCheckItemDetail = BLL.Check_ProjectCheckItemDetailService.GetCheckItemDetailById(item); if (projectCheckItemDetail != null) { detail.CheckContent = projectCheckItemDetail.CheckContent; } } detail.CheckResult = "合格"; detail.CheckOpinion = "整改"; BLL.Check_CheckWorkDetailService.AddCheckWorkDetail(detail); } } else if (!string.IsNullOrEmpty(Request.Params["CheckHolidayId"])) { foreach (var item in list) { Model.Check_CheckHolidayDetail detail = new Model.Check_CheckHolidayDetail { CheckHolidayDetailId = SQLHelper.GetNewID(typeof(Model.Check_CheckHolidayDetail)), CheckHolidayId = Request.Params["CheckHolidayId"], CheckItem = item }; Model.Check_ProjectCheckItemSet checkItemSet = BLL.Check_ProjectCheckItemSetService.GetCheckItemSetById(item); if (checkItemSet != null) { detail.CheckContent = checkItemSet.CheckItemName; } detail.CheckResult = "合格"; detail.CheckOpinion = "整改"; BLL.Check_CheckHolidayDetailService.AddCheckHolidayDetail(detail); } } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }