Пример #1
0
        /// <summary>
        /// 计算合计
        /// </summary>
        private void OutputSummaryData()
        {
            Grid1.CommitChanges();
            decimal sumTotalMoney = 0, sumAuditTotalMoney = 0, totalMoney = 0, auditTotalMoney = 0, priceMoney = 0, auditPriceMoney = 0;
            int     counts = 0, auditCounts = 0;

            for (int i = 0; i < Grid1.Rows.Count; i++)
            {
                counts         = Funs.GetNewIntOrZero(this.Grid1.Rows[i].Values[3].ToString());
                priceMoney     = Funs.GetNewDecimalOrZero(this.Grid1.Rows[i].Values[4].ToString());
                totalMoney     = counts * priceMoney;
                sumTotalMoney += totalMoney;
                this.Grid1.Rows[i].Values[5] = totalMoney.ToString();
                auditCounts                  = Funs.GetNewIntOrZero(this.Grid1.Rows[i].Values[6].ToString());
                auditPriceMoney              = Funs.GetNewDecimalOrZero(this.Grid1.Rows[i].Values[7].ToString());
                auditTotalMoney              = auditCounts * auditPriceMoney;
                sumAuditTotalMoney          += auditTotalMoney;
                this.Grid1.Rows[i].Values[8] = auditTotalMoney.ToString();
            }
            if (this.Grid1.Rows.Count > 0)
            {
                JObject summary = new JObject();
                summary.Add("PriceMoney", "总计");
                summary.Add("TotalMoney", sumTotalMoney);
                summary.Add("AuditTotalMoney", sumAuditTotalMoney);
                Grid1.SummaryData = summary;
            }
            else
            {
                Grid1.SummaryData = null;
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.drpTestTraining.Value))
            {
                Model.Base_TrainTypeItem newItem = new Model.Base_TrainTypeItem()
                {
                    TrainTypeId = this.TrainTypeId,
                    TrainingId  = this.drpTestTraining.Value,
                    SCount      = Funs.GetNewIntOrZero(this.txtSCount.Text),
                    MCount      = Funs.GetNewIntOrZero(this.txtMCount.Text),
                    JCount      = Funs.GetNewIntOrZero(this.txtJCount.Text),
                };

                var deleteItem = Funs.DB.Base_TrainTypeItem.FirstOrDefault(x => x.TrainTypeId == newItem.TrainTypeId && x.TrainingId == newItem.TrainingId);
                if (deleteItem != null)
                {
                    TrainTypeService.DeleteTrainTypeItemById(deleteItem.TrainTypeItemId);
                }

                TrainTypeService.AddTrainTypeItem(newItem);
                this.BindGrid();
                this.reSetTable();

                this.ShowNotify("保存成功!", MessageBoxIcon.Success);
            }
        }
        /// <summary>
        /// 保存按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtCheckContent.Text))
            {
                Model.HSSE_Check_CheckItemDetail checkItemDetail = new Model.HSSE_Check_CheckItemDetail
                {
                    CheckItemSetId = this.CheckItemSetId,
                    CheckContent   = this.txtCheckContent.Text.Trim(),
                    SortIndex      = Funs.GetNewIntOrZero(this.txtSortIndex.Text.Trim())
                };

                if (string.IsNullOrEmpty(this.CheckItemDetailId))
                {
                    checkItemDetail.CheckItemDetailId = SQLHelper.GetNewID(typeof(Model.HSSE_Check_CheckItemDetail));
                    BLL.CheckItemDetailService.AddCheckItemDetail(checkItemDetail);
                    BLL.LogService.AddSys_Log(this.CurrUser, checkItemDetail.SortIndex.ToString(), checkItemDetail.CheckItemDetailId, BLL.Const.SpecialCheckTypesMenuId, BLL.Const.BtnAdd);
                }
                else
                {
                    checkItemDetail.CheckItemDetailId = this.CheckItemDetailId;
                    BLL.CheckItemDetailService.UpdateCheckItemDetail(checkItemDetail);
                    BLL.LogService.AddSys_Log(this.CurrUser, checkItemDetail.SortIndex.ToString(), checkItemDetail.CheckItemDetailId, BLL.Const.SpecialCheckTypesMenuId, BLL.Const.BtnModify);
                }

                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                Alert.ShowInParent("检查项内容不能为空!");
            }
        }
Пример #4
0
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strRowID = hfFormID.Text;

            Model.Base_SolutionTempleteType solutionTempleteType = new Model.Base_SolutionTempleteType
            {
                SolutionTempleteTypeCode = this.txtSolutionTempleteTypeCode.Text.Trim(),
                SolutionTempleteTypeName = this.txtSolutionTempleteTypeName.Text.Trim(),
                Remark    = txtRemark.Text.Trim(),
                SortIndex = Funs.GetNewIntOrZero(this.txtSolutionTempleteTypeCode.Text.Trim())
            };
            if (string.IsNullOrEmpty(strRowID))
            {
                BLL.SolutionTempleteTypeService.AddSolutionTempleteType(solutionTempleteType);
                BLL.LogService.AddSys_Log(this.CurrUser, solutionTempleteType.SolutionTempleteTypeCode, solutionTempleteType.SolutionTempleteTypeCode, BLL.Const.SolutionTempleteTypeMenuId, BLL.Const.BtnAdd);
            }
            else
            {
                BLL.SolutionTempleteTypeService.UpdateSolutionTempleteType(solutionTempleteType);
                BLL.LogService.AddSys_Log(this.CurrUser, solutionTempleteType.SolutionTempleteTypeCode, solutionTempleteType.SolutionTempleteTypeCode, BLL.Const.SolutionTempleteTypeMenuId, BLL.Const.BtnModify);
            }
            this.SimpleForm1.Reset();
            // 重新绑定表格,并点击当前编辑或者新增的行
            BindGrid();
            PageContext.RegisterStartupScript(String.Format("F('{0}').selectRow('{1}');", Grid1.ClientID, solutionTempleteType.SolutionTempleteTypeCode));
        }
Пример #5
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="type"></param>
        private void SaveData(string type)
        {
            Model.Accident_AccidentReportOther accidentReportOther = new Model.Accident_AccidentReportOther
            {
                ProjectId = this.CurrUser.LoginProjectId,
                AccidentReportOtherCode = this.txtAccidentReportOtherCode.Text.Trim(),
                AccidentReportOtherName = this.txtAccidentReportOtherName.Text.Trim()
            };
            if (this.drpAccidentTypeId.SelectedValue != BLL.Const._Null)
            {
                accidentReportOther.AccidentTypeId = this.drpAccidentTypeId.SelectedValue;
            }
            accidentReportOther.Abstract     = this.txtAbstract.Text.Trim();
            accidentReportOther.AccidentDate = Funs.GetNewDateTime(this.txtAccidentDate.Text.Trim());
            accidentReportOther.WorkArea     = this.txtWorkArea.Text;
            accidentReportOther.PeopleNum    = Funs.GetNewIntOrZero(this.txtPeopleNum.Text.Trim());
            if (this.drpUnitId.SelectedValue != BLL.Const._Null)
            {
                accidentReportOther.UnitId = this.drpUnitId.SelectedValue;
            }
            accidentReportOther.WorkingHoursLoss     = 0;
            accidentReportOther.EconomicLoss         = Funs.GetNewDecimalOrZero(this.txtEconomicLoss.Text.Trim());
            accidentReportOther.EconomicOtherLoss    = Funs.GetNewDecimalOrZero(this.txtEconomicOtherLoss.Text.Trim());
            accidentReportOther.ReportMan            = this.txtReportMan.Text.Trim();
            accidentReportOther.ReporterUnit         = this.txtReporterUnit.Text.Trim();
            accidentReportOther.ReportDate           = Funs.GetNewDateTime(this.txtReportDate.Text.Trim());
            accidentReportOther.ProcessDescription   = this.txtProcessDescription.Text.Trim();
            accidentReportOther.EmergencyMeasures    = this.txtEmergencyMeasures.Text.Trim();
            accidentReportOther.ImmediateCause       = this.txtImmediateCause.Text.Trim();
            accidentReportOther.IndirectReason       = this.txtIndirectReason.Text.Trim();
            accidentReportOther.CorrectivePreventive = this.txtCorrectivePreventive.Text.Trim();
            accidentReportOther.FileContent          = HttpUtility.HtmlEncode(this.txtFileContents.Text);
            if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
            {
                accidentReportOther.CompileMan = this.drpCompileMan.SelectedValue;
            }
            accidentReportOther.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim());
            accidentReportOther.States      = BLL.Const.State_0;
            if (type == BLL.Const.BtnSubmit)
            {
                accidentReportOther.States = this.ctlAuditFlow.NextStep;
            }
            if (!string.IsNullOrEmpty(this.AccidentReportOtherId))
            {
                accidentReportOther.AccidentReportOtherId = this.AccidentReportOtherId;
                BLL.AccidentReportOtherService.UpdateAccidentReportOther(accidentReportOther);
                BLL.LogService.AddSys_Log(this.CurrUser, accidentReportOther.AccidentReportOtherCode, accidentReportOther.AccidentReportOtherId, BLL.Const.ProjectAccidentReportOtherMenuId, Const.BtnModify);
            }
            else
            {
                this.AccidentReportOtherId = SQLHelper.GetNewID(typeof(Model.Accident_AccidentReportOther));
                accidentReportOther.AccidentReportOtherId = this.AccidentReportOtherId;
                BLL.AccidentReportOtherService.AddAccidentReportOther(accidentReportOther);
                BLL.LogService.AddSys_Log(this.CurrUser, accidentReportOther.AccidentReportOtherCode, accidentReportOther.AccidentReportOtherId, BLL.Const.ProjectAccidentReportOtherMenuId, Const.BtnAdd);
            }

            //保存流程审核数据
            this.ctlAuditFlow.btnSaveData(this.CurrUser.LoginProjectId, BLL.Const.ProjectAccidentReportOtherMenuId, this.AccidentReportOtherId, (type == BLL.Const.BtnSubmit ? true : false), accidentReportOther.AccidentReportOtherCode, "../Accident/AccidentReportOtherView.aspx?AccidentReportOtherId={0}");
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        private void InitTextValue()
        {
            string   unitId = this.drpUnitId.SelectedValue;
            int      year   = Funs.GetNewIntOrZero(this.drpYear.SelectedValue);
            int      month  = Funs.GetNewIntOrZero(this.drpMonths.SelectedValue);
            DateTime?Months = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonths.SelectedValue);

            this.HSSECostManageId     = string.Empty;
            this.HSSECostUnitManageId = string.Empty;
            decimal pMainIncome = 0, pConstructionIncome = 0, pSafetyCosts = 0;
            var     sumHsseCostMange = BLL.HSSECostManageService.GetListHSSECostManageByProjectIdMonth(this.ProjectId, Months);

            if (sumHsseCostMange.Count() > 0)
            {
                pMainIncome         = sumHsseCostMange.Sum(x => x.MainIncome) ?? 0;
                pConstructionIncome = sumHsseCostMange.Sum(x => x.ConstructionIncome) ?? 0;
                pSafetyCosts        = sumHsseCostMange.Sum(x => x.SafetyCosts) ?? 0;
            }
            Model.CostGoods_HSSECostUnitManage hsseCostUnitManage = new Model.CostGoods_HSSECostUnitManage();
            var hsseCostManage = BLL.HSSECostManageService.GetHSSECostManageByProjectIdMonth(ProjectId, year, month);

            if (hsseCostManage != null)
            {
                this.HSSECostManageId                  = hsseCostManage.HSSECostManageId;
                this.txtCode.Text                      = BLL.CodeRecordsService.ReturnCodeByDataId(hsseCostManage.HSSECostManageId);
                this.txtReportDate.Text                = string.Format("{0:yyyy-MM-dd}", hsseCostManage.ReportDate);
                this.txtMainIncome.Text                = hsseCostManage.MainIncome.ToString();
                this.txtProjectMainIncome.Text         = (pMainIncome + (hsseCostManage.MainIncome ?? 0)).ToString();
                this.txtRemark1.Text                   = hsseCostManage.Remark1;
                this.txtConstructionIncome.Text        = hsseCostManage.ConstructionIncome.ToString();
                this.txtProjectConstructionIncome.Text = (pConstructionIncome + (hsseCostManage.ConstructionIncome ?? 0)).ToString();
                this.txtRemark2.Text                   = hsseCostManage.Remark2;
                this.txtSafetyCosts.Text               = hsseCostManage.SafetyCosts.ToString();
                this.txtProjectSafetyCosts.Text        = (pSafetyCosts + (hsseCostManage.SafetyCosts ?? 0)).ToString();
                this.txtRemark3.Text                   = hsseCostManage.Remark3;
                hsseCostUnitManage                     = BLL.HSSECostUnitManageService.GetHSSECostUnitManageByHSSECostManageIdUnitId(this.HSSECostManageId, this.drpUnitId.SelectedValue);
                if (hsseCostManage.States == BLL.Const.State_2)
                {
                    this.btnSave.Hidden   = true;
                    this.btnSubmit.Hidden = true;
                }
            }
            else
            {
                this.txtReportDate.Text         = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                this.txtCode.Text               = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectHSSECostManageMenuId, this.ProjectId, string.Empty);
                this.txtMainIncome.Text         = "0";
                this.txtConstructionIncome.Text = "0";
                this.txtSafetyCosts.Text        = "0";

                this.txtProjectMainIncome.Text         = pMainIncome.ToString();
                this.txtProjectConstructionIncome.Text = pConstructionIncome.ToString();
                this.txtProjectSafetyCosts.Text        = pSafetyCosts.ToString();
                hsseCostUnitManage = BLL.HSSECostUnitManageService.GetHSSECostUnitManageByProjectIdUnitIdYearMonth(this.ProjectId, this.drpUnitId.SelectedValue, year, month);
            }

            this.InitTextUnitValue(hsseCostUnitManage);
        }
Пример #7
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="type"></param>
        private void SaveData(string type)
        {
            Model.Accident_AccidentHandle accidentHandle = new Model.Accident_AccidentHandle
            {
                ProjectId              = this.ProjectId,
                AccidentHandleCode     = this.txtAccidentHandleCode.Text.Trim(),
                AccidentHandleName     = this.txtAccidentHandleName.Text.Trim(),
                AccidentDate           = Convert.ToDateTime(this.txtAccidentDate.Text.Trim()),
                AccidentDef            = this.txtAccidentDef.Text.Trim(),
                MoneyLoss              = Funs.GetNewDecimalOrZero(this.txtMoneyLoss.Text.Trim()),
                WorkHoursLoss          = Funs.GetNewDecimalOrZero(this.txtWorkHoursLoss.Text.Trim()),
                MinorInjuriesPersonNum = Funs.GetNewIntOrZero(this.txtMinorInjuriesPersonNum.Text.Trim()),
                InjuriesPersonNum      = Funs.GetNewIntOrZero(this.txtInjuriesPersonNum.Text.Trim()),
                DeathPersonNum         = Funs.GetNewIntOrZero(this.txtDeathPersonNum.Text.Trim()),
                AccidentHandle         = this.txtAccidentHandle.Text.Trim(),
                Remark      = this.txtRemark.Text.Trim(),
                CompileMan  = this.CurrUser.UserId,
                CompileDate = DateTime.Now,
                States      = BLL.Const.State_0
            };
            if (this.drpUnitId.SelectedValue != BLL.Const._Null)
            {
                accidentHandle.UnitId = this.drpUnitId.SelectedValue;
            }

            if (type == BLL.Const.BtnSubmit)
            {
                var flowOperate = Funs.DB.Sys_FlowOperate.FirstOrDefault(x => x.DataId == this.AccidentHandleId && x.State == BLL.Const.State_2 && x.IsClosed == true);
                if (flowOperate != null)
                {
                    accidentHandle.States = BLL.Const.State_2;
                }
                else
                {
                    accidentHandle.States = this.ctlAuditFlow.NextStep;
                }
            }
            if (!string.IsNullOrEmpty(this.AccidentHandleId))
            {
                accidentHandle.AccidentHandleId = this.AccidentHandleId;
                BLL.AccidentHandleService.UpdateAccidentHandle(accidentHandle);
                BLL.LogService.AddSys_Log(this.CurrUser, this.txtAccidentHandleCode.Text, this.AccidentHandleId, BLL.Const.ProjectAccidentHandleMenuId, Const.BtnModify);
            }
            else
            {
                this.AccidentHandleId           = SQLHelper.GetNewID(typeof(Model.Accident_AccidentHandle));
                accidentHandle.AccidentHandleId = this.AccidentHandleId;
                BLL.AccidentHandleService.AddAccidentHandle(accidentHandle);
                BLL.LogService.AddSys_Log(this.CurrUser, this.txtAccidentHandleCode.Text, this.AccidentHandleId, BLL.Const.ProjectAccidentHandleMenuId, Const.BtnAdd);
            }
            ////保存流程审核数据
            this.ctlAuditFlow.btnSaveData(this.ProjectId, BLL.Const.ProjectAccidentHandleMenuId, this.AccidentHandleId, (type == BLL.Const.BtnSubmit ? true : false), accidentHandle.AccidentHandleName, "../Accident/AccidentHandleView.aspx?AccidentHandleId={0}");
        }
Пример #8
0
 /// <summary>
 /// 保存数据
 /// </summary>
 /// <param name="type"></param>
 private void SaveData(string type)
 {
     Model.CostGoods_GoodsManage goodsManage = new Model.CostGoods_GoodsManage
     {
         ProjectId = this.ProjectId,
         GoodsCode = this.txtGoodsCode.Text.Trim(),
         GoodsName = this.txtGoodsName.Text.Trim()
     };
     if (this.drpUnitId.SelectedValue != BLL.Const._Null)
     {
         goodsManage.UnitId = this.drpUnitId.SelectedValue;
     }
     if (this.drpGoodsCategory.SelectedValue != BLL.Const._Null)
     {
         goodsManage.GoodsCategoryId = this.drpGoodsCategory.SelectedValue;
     }
     goodsManage.SizeModel = this.txtSizeModel.Text.Trim();
     goodsManage.FactoryCode = this.txtFactoryCode.Text.Trim();
     goodsManage.CheckDate = Funs.GetNewDateTime(this.txtCheckDate.Text);
     if (!string.IsNullOrEmpty(this.txtEnableYear.Text.Trim()))
     {
         goodsManage.EnableYear = Funs.GetNewIntOrZero(this.txtEnableYear.Text);
     }
     if (this.drpCheckPerson.SelectedValue != BLL.Const._Null)
     {
         goodsManage.CheckPerson = this.drpCheckPerson.SelectedValue;
     }
     goodsManage.InTime = Funs.GetNewDateTime(this.txtInTime.Text.Trim());
     goodsManage.States = BLL.Const.State_0;
     if (type == BLL.Const.BtnSubmit)
     {
         goodsManage.States = this.ctlAuditFlow.NextStep;
     }
     goodsManage.CompileMan = this.CurrUser.UserId;
     goodsManage.CompileDate = DateTime.Now;
     goodsManage.Remark = this.txtRemark.Text.Trim();
     if (!string.IsNullOrEmpty(this.GoodsManageId))
     {
         goodsManage.GoodsManageId = this.GoodsManageId;
         BLL.GoodsManageService.UpdateGoodsManage(goodsManage);
         BLL.LogService.AddSys_Log(this.CurrUser, goodsManage.GoodsCode, goodsManage.GoodsManageId, BLL.Const.GoodsManageMenuId, BLL.Const.BtnAdd);
     }
     else
     {
         this.GoodsManageId = SQLHelper.GetNewID(typeof(Model.CostGoods_GoodsManage));
         goodsManage.GoodsManageId = this.GoodsManageId;
         BLL.GoodsManageService.AddGoodsManage(goodsManage);
         BLL.LogService.AddSys_Log(this.CurrUser, goodsManage.GoodsCode, goodsManage.GoodsManageId,BLL.Const.GoodsManageMenuId,BLL.Const.BtnModify);
     }
     ////保存流程审核数据
     this.ctlAuditFlow.btnSaveData(this.ProjectId, BLL.Const.GoodsManageMenuId, this.GoodsManageId, (type == BLL.Const.BtnSubmit ? true : false), goodsManage.GoodsName, "../CostGoods/GoodsManageView.aspx?GoodsManageId={0}");
 }
Пример #9
0
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string staName = this.txtCheckItemName.Text.Trim();

            if (!string.IsNullOrEmpty(staName))
            {
                if (!BLL.Check_ProjectCheckItemSetService.IsExistCheckItemName(this.ProjectId, this.Type, this.CheckItemSetId, this.SupCheckItem, staName))
                {
                    Model.Check_ProjectCheckItemSet checkItemSet = new Model.Check_ProjectCheckItemSet
                    {
                        CheckItemName = staName,
                        SupCheckItem  = this.SupCheckItem,
                        MapCode       = this.txtMapCode.Text.Trim(),
                        SortIndex     = Funs.GetNewIntOrZero(this.txtSortIndex.Text.Trim()),
                        IsEndLever    = Convert.ToBoolean(this.chkIsEndLevel.Checked),
                        CheckType     = Request.Params["checkType"]
                    };
                    if (string.IsNullOrEmpty(this.CheckItemSetId))
                    {
                        checkItemSet.CheckItemSetId = SQLHelper.GetNewID(typeof(Model.Check_ProjectCheckItemSet));
                        checkItemSet.ProjectId      = this.CurrUser.LoginProjectId;
                        BLL.Check_ProjectCheckItemSetService.AddCheckItemSet(checkItemSet);
                        BLL.LogService.AddSys_Log(this.CurrUser, checkItemSet.MapCode, checkItemSet.CheckItemSetId, BLL.Const.ProjectCheckItemSetMenuId, BLL.Const.BtnAdd);
                    }
                    else
                    {
                        checkItemSet.CheckItemSetId = this.CheckItemSetId;
                        BLL.Check_ProjectCheckItemSetService.UpdateCheckItemSet(checkItemSet);
                        BLL.LogService.AddSys_Log(this.CurrUser, checkItemSet.MapCode, checkItemSet.CheckItemSetId, BLL.Const.ProjectCheckItemSetMenuId, BLL.Const.BtnModify);
                    }
                }
                else
                {
                    Alert.ShowInTop("检查项目名称已存在!", MessageBoxIcon.Warning);
                    return;
                }

                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                Alert.ShowInTop("检查项目名称不能为空!", MessageBoxIcon.Warning);
                return;
            }
        }
Пример #10
0
        /// <summary>
        /// 检查并保存其他HSE管理活动集合
        /// </summary>
        private void jerqueSaveMonthPlanList()
        {
            costManageItems.Clear();
            JArray mergedData = Grid1.GetMergedData();

            foreach (JObject mergedRow in mergedData)
            {
                string  status = mergedRow.Value <string>("status");
                JObject values = mergedRow.Value <JObject>("values");
                int     i      = mergedRow.Value <int>("index");
                Model.CostGoods_CostManageItem costManageItem = new Model.CostGoods_CostManageItem
                {
                    CostManageItemId  = this.Grid1.Rows[i].DataKeys[0].ToString(),
                    InvestCostProject = values.Value <string>("InvestCostProject").ToString(),
                    UseReason         = values.Value <string>("UseReason").ToString(),
                    Counts            = Funs.GetNewIntOrZero(values.Value <string>("Counts").ToString()),
                    PriceMoney        = Funs.GetNewDecimalOrZero(values.Value <string>("PriceMoney").ToString()),
                    AuditCounts       = !string.IsNullOrEmpty(values.Value <string>("AuditCounts").ToString()) ? Funs.GetNewInt(values.Value <string>("AuditCounts").ToString()) : null,
                    AuditPriceMoney   = !string.IsNullOrEmpty(values.Value <string>("AuditPriceMoney").ToString()) ? Funs.GetNewDecimal(values.Value <string>("AuditPriceMoney").ToString()) : null
                };
                costManageItems.Add(costManageItem);
            }
        }
Пример #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnNew_Click(object sender, EventArgs e)
        {
            if (this.drpYear.SelectedValue != BLL.Const._Null && this.drpMonths.SelectedValue != BLL.Const._Null &&
                this.drpUnitId.SelectedValue != BLL.Const._Null && this.drpUnitId.SelectedValue != BLL.Const._Null)
            {
                DateTime?Months           = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonths.SelectedValue);
                string   hsseCostManageId = string.Empty;
                string   unitId           = this.drpUnitId.SelectedValue;
                var      hsseCost         = BLL.HSSECostManageService.GetHSSECostManageByProjectIdMonth(this.ProjectId, Funs.GetNewIntOrZero(this.drpYear.SelectedValue), Funs.GetNewIntOrZero(this.drpMonths.SelectedValue));
                if (hsseCost != null)
                {
                    hsseCostManageId = hsseCost.HSSECostManageId;
                }
                else
                {
                    hsseCostManageId = SQLHelper.GetNewID(typeof(Model.CostGoods_HSSECostManage));
                    Model.CostGoods_HSSECostManage newHSSECostManage = new Model.CostGoods_HSSECostManage
                    {
                        HSSECostManageId = hsseCostManageId,
                        ProjectId        = this.ProjectId,
                        Month            = Months,
                        Code             = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectHSSECostManageMenuId, this.ProjectId, string.Empty),
                        ReportDate       = System.DateTime.Now,
                        CompileDate      = System.DateTime.Now,
                    };

                    BLL.HSSECostManageService.AddHSSECostManage(newHSSECostManage);
                }
                var unitCost = BLL.HSSECostUnitManageService.GetHSSECostUnitManageByHSSECostManageIdUnitId(hsseCostManageId, unitId);
                if (unitCost == null)
                {
                    string HSSECostUnitManageId = SQLHelper.GetNewID(typeof(Model.CostGoods_HSSECostUnitManage));
                    Model.CostGoods_HSSECostUnitManage newHSSECostUnit = new Model.CostGoods_HSSECostUnitManage
                    {
                        HSSECostUnitManageId = HSSECostUnitManageId,
                        HSSECostManageId     = hsseCostManageId,
                        UnitId       = unitId,
                        StateType    = "1",
                        States       = "0",
                        CompileManId = this.CurrUser.UserId,
                        CompileDate  = DateTime.Now,
                        CostA1       = 0,
                        CostA2       = 0,
                        CostA3       = 0,
                        CostA4       = 0,
                        CostA5       = 0,
                        CostA6       = 0,
                        CostA7       = 0,
                        CostA8       = 0,
                        CostB1       = 0,
                        CostB2       = 0,
                        CostC1       = 0,
                        CostD1       = 0,
                        CostD2       = 0,
                        CostD3       = 0,
                    };

                    BLL.HSSECostUnitManageService.AddHSSECostUnitManage(newHSSECostUnit);

                    PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HSSECostUnitManageEdit.aspx?HSSECostUnitManageId={0}", HSSECostUnitManageId, "编辑 - ")));
                }
                else
                {
                    Alert.ShowInTop("当月已存在费用表!", MessageBoxIcon.Warning);
                }
            }
            else
            {
                Alert.ShowInTop("请选择月份、单位!", MessageBoxIcon.Warning);
            }
        }
        /// <summary>
        /// 将Dataset的数据导入数据库
        /// </summary>
        /// <param name="pds">数据集</param>
        /// <param name="Cols">数据集行数</param>
        /// <returns></returns>
        private bool AddDatasetToSQL(DataTable pds, int Cols)
        {
            string result = string.Empty;
            int    ic, ir;

            ic = pds.Columns.Count;
            if (ic < Cols)
            {
                ShowNotify("导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "行", MessageBoxIcon.Warning);
            }

            ir = pds.Rows.Count;
            if (pds != null && ir > 0)
            {
                for (int i = 1; i < ir; i++)
                {
                    string row1   = pds.Rows[i][0].ToString();
                    string unitId = string.Empty;
                    if (!string.IsNullOrEmpty(row1))
                    {
                        var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == row1.Trim());
                        if (unit == null)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "单位名称" + "," + "[" + row1 + "]不存在!" + "|";
                        }
                        else
                        {
                            unitId = unit.UnitId;
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "单位名称" + "," + "此项为必填项!" + "|";
                    }

                    string row2 = pds.Rows[i][1].ToString();
                    if (!string.IsNullOrEmpty(row2))
                    {
                        try
                        {
                            Int32 year = Convert.ToInt32(row2.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "年份" + "," + "[" + row2 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "年份" + "," + "此项为必填项!" + "|";
                    }

                    string row3 = pds.Rows[i][2].ToString();
                    if (!string.IsNullOrEmpty(row3))
                    {
                        try
                        {
                            Int32 month = Convert.ToInt32(row3.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "季度" + "," + "[" + row3 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "季度" + "," + "此项为必填项!" + "|";
                    }

                    ////判断是否 已存在该季度数据
                    var drillConductedQuarterlyReport = BLL.DrillConductedQuarterlyReportService.GetDrillConductedQuarterlyReportByUnitIdAndYearAndQuarters(unitId, Funs.GetNewIntOrZero(row2.Trim()), Funs.GetNewIntOrZero(row3.Trim()));
                    if (drillConductedQuarterlyReport != null)
                    {
                        result += "第" + (i + 2).ToString() + "行," + "已存在该季度季报!" + "|";
                    }

                    string row5 = pds.Rows[i][4].ToString().Trim();
                    if (!string.IsNullOrEmpty(row5))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row5);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "总体情况举办次数" + "," + "[" + row5 + "]错误!" + "|";
                        }
                    }
                    string row6 = pds.Rows[i][5].ToString().Trim();
                    if (!string.IsNullOrEmpty(row6))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row6);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "总体情况参演人数" + "," + "[" + row6 + "]错误!" + "|";
                        }
                    }
                    string row7 = pds.Rows[i][6].ToString().Trim();
                    if (!string.IsNullOrEmpty(row7))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row7);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "总体情况直接投入" + "," + "[" + row7 + "]错误!" + "|";
                        }
                    }
                    string row8 = pds.Rows[i][7].ToString().Trim();
                    if (!string.IsNullOrEmpty(row8))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row8);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "企业总部举办次数" + "," + "[" + row8 + "]错误!" + "|";
                        }
                    }
                    string row9 = pds.Rows[i][8].ToString().Trim();
                    if (!string.IsNullOrEmpty(row9))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row9);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "企业总部参演人数" + "," + "[" + row9 + "]错误!" + "|";
                        }
                    }
                    string row10 = pds.Rows[i][9].ToString().Trim();
                    if (!string.IsNullOrEmpty(row10))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row10);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "企业总部直接投入" + "," + "[" + row10 + "]错误!" + "|";
                        }
                    }
                    string row11 = pds.Rows[i][10].ToString().Trim();
                    if (!string.IsNullOrEmpty(row11))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row11);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "基层单位举办次数" + "," + "[" + row11 + "]错误!" + "|";
                        }
                    }
                    string row12 = pds.Rows[i][11].ToString().Trim();
                    if (!string.IsNullOrEmpty(row12))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row12);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "基层单位参演人数" + "," + "[" + row12 + "]错误!" + "|";
                        }
                    }
                    string row13 = pds.Rows[i][12].ToString().Trim();
                    if (!string.IsNullOrEmpty(row13))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row13);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "基层单位直接投入" + "," + "[" + row13 + "]错误!" + "|";
                        }
                    }
                    string row14 = pds.Rows[i][13].ToString().Trim();
                    if (!string.IsNullOrEmpty(row14))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row14);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "综合演练" + "," + "[" + row14 + "]错误!" + "|";
                        }
                    }
                    string row15 = pds.Rows[i][14].ToString().Trim();
                    if (!string.IsNullOrEmpty(row15))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row15);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "综合演练其中现场" + "," + "[" + row15 + "]错误!" + "|";
                        }
                    }
                    string row16 = pds.Rows[i][15].ToString().Trim();
                    if (!string.IsNullOrEmpty(row16))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row16);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "综合演练其中桌面" + "," + "[" + row16 + "]错误!" + "|";
                        }
                    }

                    string row17 = pds.Rows[i][16].ToString().Trim();
                    if (!string.IsNullOrEmpty(row17))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row17);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "专项演练" + "," + "[" + row17 + "]错误!" + "|";
                        }
                    }
                    string row18 = pds.Rows[i][17].ToString().Trim();
                    if (!string.IsNullOrEmpty(row18))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row18);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "专项演练其中现场" + "," + "[" + row18 + "]错误!" + "|";
                        }
                    }
                    string row19 = pds.Rows[i][18].ToString().Trim();
                    if (!string.IsNullOrEmpty(row19))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row19);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "专项演练其中桌面" + "," + "[" + row19 + "]错误!" + "|";
                        }
                    }
                }
                if (!string.IsNullOrEmpty(result))
                {
                    result = result.Substring(0, result.LastIndexOf("|"));
                    ShowNotify(result, MessageBoxIcon.Warning);
                    //Session["errorInfos"] = result;
                }
                else
                {
                    ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
                }
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
            }
            return(true);
        }
Пример #13
0
        /// <summary>
        /// 将Dataset的数据导入数据库
        /// </summary>
        /// <param name="pds">数据集</param>
        /// <param name="Cols">数据集行数</param>
        /// <returns></returns>
        private bool AddDatasetToSQL(DataTable pds, int Cols)
        {
            string result = string.Empty;
            int    ic, ir;

            ic = pds.Columns.Count;
            if (ic < Cols)
            {
                ShowNotify("导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "行", MessageBoxIcon.Warning);
            }

            ir = pds.Rows.Count;
            if (pds != null && ir > 0)
            {
                var accidentTypes = from x in Funs.DB.Sys_Const where x.GroupId == "0012" select x;
                for (int i = 0; i < ir; i++)
                {
                    string row1   = pds.Rows[i][0].ToString();
                    string unitId = string.Empty;
                    if (!string.IsNullOrEmpty(row1))
                    {
                        var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == row1.Trim());
                        if (unit == null)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "填报单位" + "," + "[" + row1 + "]不存在!" + "|";
                        }
                        else
                        {
                            unitId = unit.UnitId;
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "填报单位" + "," + "此项为必填项!" + "|";
                    }
                    string row2 = pds.Rows[i][1].ToString();
                    if (string.IsNullOrEmpty(row2))
                    {
                        result += "第" + (i + 2).ToString() + "行," + "编号" + "," + "此项为必填项!" + "|";
                    }
                    string row3 = pds.Rows[i][2].ToString();
                    if (!string.IsNullOrEmpty(row3))
                    {
                        try
                        {
                            Int32 year = Convert.ToInt32(row3.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "年份" + "," + "[" + row3 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "年份" + "," + "此项为必填项!" + "|";
                    }
                    string row4 = pds.Rows[i][3].ToString();
                    if (!string.IsNullOrEmpty(row4))
                    {
                        try
                        {
                            Int32 month = Convert.ToInt32(row4.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "月份" + "," + "[" + row4 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "月份" + "," + "此项为必填项!" + "|";
                    }

                    ////判断是否 已存在该月份数据
                    var accidentCauseReport = BLL.AccidentCauseReportService.GetAccidentCauseReportByUnitIdAndYearAndMonth(unitId, Funs.GetNewIntOrZero(row3.Trim()), Funs.GetNewIntOrZero(row4.Trim()));
                    if (accidentCauseReport != null)
                    {
                        result += "第" + (i + 2).ToString() + "行," + "已存在该月份月报!" + "|";
                    }

                    string row5 = pds.Rows[i][4].ToString().Trim();
                    if (!string.IsNullOrEmpty(row5))
                    {
                        try
                        {
                            Int32 deathAccident = Convert.ToInt32(row5);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "死亡事故数" + "," + "[" + row5 + "]错误!" + "|";
                        }
                    }
                    string row6 = pds.Rows[i][5].ToString().Trim();
                    if (!string.IsNullOrEmpty(row6))
                    {
                        try
                        {
                            Int32 deathToll = Convert.ToInt32(row6);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "死亡人数" + "," + "[" + row6 + "]错误!" + "|";
                        }
                    }
                    string row7 = pds.Rows[i][6].ToString().Trim();
                    if (!string.IsNullOrEmpty(row7))
                    {
                        try
                        {
                            Int32 injuredAccident = Convert.ToInt32(row7);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重伤事故" + "," + "[" + row7 + "]错误!" + "|";
                        }
                    }
                    string row8 = pds.Rows[i][7].ToString().Trim();
                    if (!string.IsNullOrEmpty(row8))
                    {
                        try
                        {
                            Int32 injuredToll = Convert.ToInt32(row8);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重伤人数" + "," + "[" + row8 + "]错误!" + "|";
                        }
                    }
                    string row9 = pds.Rows[i][8].ToString().Trim();
                    if (!string.IsNullOrEmpty(row9))
                    {
                        try
                        {
                            Int32 minorWoundAccident = Convert.ToInt32(row9);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "轻伤事故" + "," + "[" + row9 + "]错误!" + "|";
                        }
                    }
                    string row10 = pds.Rows[i][9].ToString().Trim();
                    if (!string.IsNullOrEmpty(row10))
                    {
                        try
                        {
                            Int32 minorWoundToll = Convert.ToInt32(row10);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "轻伤人数" + "," + "[" + row10 + "]错误!" + "|";
                        }
                    }
                    string row11 = pds.Rows[i][10].ToString().Trim();
                    if (!string.IsNullOrEmpty(row11))
                    {
                        try
                        {
                            Decimal averageTotalHours = Funs.GetNewDecimalOrZero(row11);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "平均工时总数" + "," + "[" + row11 + "]错误!" + "|";
                        }
                    }
                    string row12 = pds.Rows[i][11].ToString().Trim();
                    if (!string.IsNullOrEmpty(row12))
                    {
                        try
                        {
                            Int32 averageManHours = Convert.ToInt32(row12);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "平均工时人数" + "," + "[" + row12 + "]错误!" + "|";
                        }
                    }
                    string row13 = pds.Rows[i][12].ToString().Trim();
                    if (!string.IsNullOrEmpty(row13))
                    {
                        try
                        {
                            Int32 totalLossMan = Convert.ToInt32(row13);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "损失工时总数" + "," + "[" + row13 + "]错误!" + "|";
                        }
                    }
                    string row14 = pds.Rows[i][13].ToString().Trim();
                    if (!string.IsNullOrEmpty(row14))
                    {
                        try
                        {
                            Int32 lastMonthLossHoursTotal = Convert.ToInt32(row14);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "上月损失工时总数" + "," + "[" + row14 + "]错误!" + "|";
                        }
                    }
                    string row15 = pds.Rows[i][14].ToString().Trim();
                    if (!string.IsNullOrEmpty(row15))
                    {
                        try
                        {
                            Int32 knockOffTotal = Convert.ToInt32(row15);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "歇工总日数" + "," + "[" + row15 + "]错误!" + "|";
                        }
                    }
                    string row16 = pds.Rows[i][15].ToString().Trim();
                    if (!string.IsNullOrEmpty(row16))
                    {
                        try
                        {
                            Int32 directLoss = Convert.ToInt32(row16);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "直接损失" + "," + "[" + row16 + "]错误!" + "|";
                        }
                    }
                    string row17 = pds.Rows[i][16].ToString().Trim();
                    if (!string.IsNullOrEmpty(row17))
                    {
                        try
                        {
                            Int32 indirectLosses = Convert.ToInt32(row17);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "间接损失" + "," + "[" + row17 + "]错误!" + "|";
                        }
                    }
                    string row18 = pds.Rows[i][17].ToString().Trim();
                    if (!string.IsNullOrEmpty(row18))
                    {
                        try
                        {
                            Int32 totalLoss = Convert.ToInt32(row18);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "总损失" + "," + "[" + row18 + "]错误!" + "|";
                        }
                    }
                    string row19 = pds.Rows[i][18].ToString().Trim();
                    if (!string.IsNullOrEmpty(row19))
                    {
                        try
                        {
                            Int32 totalLossTime = Convert.ToInt32(row19);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "无损失工时总数" + "," + "[" + row19 + "]错误!" + "|";
                        }
                    }
                    //string row20 = pds.Rows[i][19].ToString().Trim();
                    string row21 = pds.Rows[i][20].ToString().Trim();
                    if (!string.IsNullOrEmpty(row21))
                    {
                        if (accidentTypes.Where(x => x.ConstValue == row21.Trim()).FirstOrDefault() == null)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "事故类别" + "," + "[" + row21 + "]不存在!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "事故类别" + "," + "此项为必填项!" + "|";
                    }
                    string row22 = pds.Rows[i][21].ToString().Trim();
                    if (!string.IsNullOrEmpty(row22))
                    {
                        try
                        {
                            Int32 death1 = Convert.ToInt32(row22);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "防护保险信号缺失死亡数" + "," + "[" + row22 + "]错误!" + "|";
                        }
                    }
                    string row23 = pds.Rows[i][22].ToString().Trim();
                    if (!string.IsNullOrEmpty(row23))
                    {
                        try
                        {
                            Int32 injuries1 = Convert.ToInt32(row23);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "防护保险信号缺失重伤数" + "," + "[" + row23 + "]错误!" + "|";
                        }
                    }
                    string row24 = pds.Rows[i][23].ToString().Trim();
                    if (!string.IsNullOrEmpty(row24))
                    {
                        try
                        {
                            Int32 minorInjuries1 = Convert.ToInt32(row24);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "防护保险信号缺失轻伤数" + "," + "[" + row24 + "]错误!" + "|";
                        }
                    }
                    string row25 = pds.Rows[i][24].ToString().Trim();
                    if (!string.IsNullOrEmpty(row25))
                    {
                        try
                        {
                            Int32 death2 = Convert.ToInt32(row25);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "设备工具缺陷死亡数" + "," + "[" + row25 + "]错误!" + "|";
                        }
                    }
                    string row26 = pds.Rows[i][25].ToString().Trim();
                    if (!string.IsNullOrEmpty(row26))
                    {
                        try
                        {
                            Int32 injuries2 = Convert.ToInt32(row26);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "设备工具缺陷重伤数" + "," + "[" + row26 + "]错误!" + "|";
                        }
                    }
                    string row27 = pds.Rows[i][26].ToString().Trim();
                    if (!string.IsNullOrEmpty(row27))
                    {
                        try
                        {
                            Int32 minorInjuries2 = Convert.ToInt32(row27);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "设备工具缺陷轻伤数" + "," + "[" + row27 + "]错误!" + "|";
                        }
                    }
                    string row28 = pds.Rows[i][27].ToString().Trim();
                    if (!string.IsNullOrEmpty(row28))
                    {
                        try
                        {
                            Int32 death3 = Convert.ToInt32(row28);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "个人防护缺陷死亡数" + "," + "[" + row28 + "]错误!" + "|";
                        }
                    }
                    string row29 = pds.Rows[i][28].ToString().Trim();
                    if (!string.IsNullOrEmpty(row29))
                    {
                        try
                        {
                            Int32 injuries3 = Convert.ToInt32(row29);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "个人防护缺陷重伤数" + "," + "[" + row29 + "]错误!" + "|";
                        }
                    }
                    string row30 = pds.Rows[i][29].ToString().Trim();
                    if (!string.IsNullOrEmpty(row30))
                    {
                        try
                        {
                            Int32 minorInjuries3 = Convert.ToInt32(row30);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "个人防护缺陷轻伤数" + "," + "[" + row30 + "]错误!" + "|";
                        }
                    }
                    string row31 = pds.Rows[i][30].ToString().Trim();
                    if (!string.IsNullOrEmpty(row31))
                    {
                        try
                        {
                            Int32 death4 = Convert.ToInt32(row31);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "光线不足死亡数" + "," + "[" + row31 + "]错误!" + "|";
                        }
                    }
                    string row32 = pds.Rows[i][31].ToString().Trim();
                    if (!string.IsNullOrEmpty(row32))
                    {
                        try
                        {
                            Int32 injuries4 = Convert.ToInt32(row32);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "光线不足重伤数" + "," + "[" + row32 + "]错误!" + "|";
                        }
                    }
                    string row33 = pds.Rows[i][32].ToString().Trim();
                    if (!string.IsNullOrEmpty(row33))
                    {
                        try
                        {
                            Int32 minorInjuries4 = Convert.ToInt32(row33);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "光线不足轻伤数" + "," + "[" + row33 + "]错误!" + "|";
                        }
                    }
                    string row34 = pds.Rows[i][33].ToString().Trim();
                    if (!string.IsNullOrEmpty(row34))
                    {
                        try
                        {
                            Int32 death5 = Convert.ToInt32(row34);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "劳动组织不合理死亡数" + "," + "[" + row34 + "]错误!" + "|";
                        }
                    }
                    string row35 = pds.Rows[i][34].ToString().Trim();
                    if (!string.IsNullOrEmpty(row35))
                    {
                        try
                        {
                            Int32 injuries5 = Convert.ToInt32(row35);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "劳动组织不合理重伤数" + "," + "[" + row35 + "]错误!" + "|";
                        }
                    }
                    string row36 = pds.Rows[i][35].ToString().Trim();
                    if (!string.IsNullOrEmpty(row36))
                    {
                        try
                        {
                            Int32 minorInjuries5 = Convert.ToInt32(row36);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "劳动组织不合理轻伤数" + "," + "[" + row36 + "]错误!" + "|";
                        }
                    }
                    string row37 = pds.Rows[i][36].ToString().Trim();
                    if (!string.IsNullOrEmpty(row37))
                    {
                        try
                        {
                            Int32 death6 = Convert.ToInt32(row37);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "现场指导错误死亡数" + "," + "[" + row37 + "]错误!" + "|";
                        }
                    }
                    string row38 = pds.Rows[i][37].ToString().Trim();
                    if (!string.IsNullOrEmpty(row38))
                    {
                        try
                        {
                            Int32 injuries6 = Convert.ToInt32(row38);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "现场指导错误重伤数" + "," + "[" + row38 + "]错误!" + "|";
                        }
                    }
                    string row39 = pds.Rows[i][38].ToString().Trim();
                    if (!string.IsNullOrEmpty(row39))
                    {
                        try
                        {
                            Int32 minorInjuries6 = Convert.ToInt32(row39);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "现场指导错误轻伤数" + "," + "[" + row39 + "]错误!" + "|";
                        }
                    }
                    string row40 = pds.Rows[i][39].ToString().Trim();
                    if (!string.IsNullOrEmpty(row40))
                    {
                        try
                        {
                            Int32 death7 = Convert.ToInt32(row40);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "设计有缺陷死亡数" + "," + "[" + row40 + "]错误!" + "|";
                        }
                    }
                    string row41 = pds.Rows[i][40].ToString().Trim();
                    if (!string.IsNullOrEmpty(row41))
                    {
                        try
                        {
                            Int32 injuries7 = Convert.ToInt32(row41);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "设计有缺陷重伤数" + "," + "[" + row41 + "]错误!" + "|";
                        }
                    }
                    string row42 = pds.Rows[i][41].ToString().Trim();
                    if (!string.IsNullOrEmpty(row42))
                    {
                        try
                        {
                            Int32 minorInjuries7 = Convert.ToInt32(row42);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "设计有缺陷轻伤数" + "," + "[" + row42 + "]错误!" + "|";
                        }
                    }
                    string row43 = pds.Rows[i][42].ToString().Trim();
                    if (!string.IsNullOrEmpty(row43))
                    {
                        try
                        {
                            Int32 death8 = Convert.ToInt32(row43);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "不懂操作死亡数" + "," + "[" + row43 + "]错误!" + "|";
                        }
                    }
                    string row44 = pds.Rows[i][43].ToString().Trim();
                    if (!string.IsNullOrEmpty(row44))
                    {
                        try
                        {
                            Int32 injuries8 = Convert.ToInt32(row44);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "不懂操作重伤数" + "," + "[" + row44 + "]错误!" + "|";
                        }
                    }
                    string row45 = pds.Rows[i][44].ToString().Trim();
                    if (!string.IsNullOrEmpty(row45))
                    {
                        try
                        {
                            Int32 minorInjuries8 = Convert.ToInt32(row45);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "不懂操作轻伤数" + "," + "[" + row45 + "]错误!" + "|";
                        }
                    }
                    string row46 = pds.Rows[i][45].ToString().Trim();
                    if (!string.IsNullOrEmpty(row46))
                    {
                        try
                        {
                            Int32 death9 = Convert.ToInt32(row46);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "违反操作死亡数" + "," + "[" + row46 + "]错误!" + "|";
                        }
                    }
                    string row47 = pds.Rows[i][46].ToString().Trim();
                    if (!string.IsNullOrEmpty(row47))
                    {
                        try
                        {
                            Int32 injuries9 = Convert.ToInt32(row47);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "违反操作重伤数" + "," + "[" + row47 + "]错误!" + "|";
                        }
                    }
                    string row48 = pds.Rows[i][47].ToString().Trim();
                    if (!string.IsNullOrEmpty(row48))
                    {
                        try
                        {
                            Int32 minorInjuries9 = Convert.ToInt32(row48);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "违反操作轻伤数" + "," + "[" + row48 + "]错误!" + "|";
                        }
                    }
                    string row49 = pds.Rows[i][48].ToString().Trim();
                    if (!string.IsNullOrEmpty(row49))
                    {
                        try
                        {
                            Int32 death10 = Convert.ToInt32(row49);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "没有安全操作死亡数" + "," + "[" + row49 + "]错误!" + "|";
                        }
                    }
                    string row50 = pds.Rows[i][49].ToString().Trim();
                    if (!string.IsNullOrEmpty(row50))
                    {
                        try
                        {
                            Int32 injuries10 = Convert.ToInt32(row50);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "没有安全操作重伤数" + "," + "[" + row50 + "]错误!" + "|";
                        }
                    }
                    string row51 = pds.Rows[i][50].ToString().Trim();
                    if (!string.IsNullOrEmpty(row51))
                    {
                        try
                        {
                            Int32 minorInjuries10 = Convert.ToInt32(row51);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "没有安全操作轻伤数" + "," + "[" + row51 + "]错误!" + "|";
                        }
                    }
                    string row52 = pds.Rows[i][51].ToString().Trim();
                    if (!string.IsNullOrEmpty(row52))
                    {
                        try
                        {
                            Int32 death11 = Convert.ToInt32(row52);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "其他死亡数" + "," + "[" + row52 + "]错误!" + "|";
                        }
                    }
                    string row53 = pds.Rows[i][52].ToString().Trim();
                    if (!string.IsNullOrEmpty(row53))
                    {
                        try
                        {
                            Int32 injuries11 = Convert.ToInt32(row53);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "其他重伤数" + "," + "[" + row53 + "]错误!" + "|";
                        }
                    }
                    string row54 = pds.Rows[i][53].ToString().Trim();
                    if (!string.IsNullOrEmpty(row54))
                    {
                        try
                        {
                            Int32 minorInjuries11 = Convert.ToInt32(row54);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "其他轻伤数" + "," + "[" + row54 + "]错误!" + "|";
                        }
                    }
                }
                if (!string.IsNullOrEmpty(result))
                {
                    result = result.Substring(0, result.LastIndexOf("|"));
                    ShowNotify(result, MessageBoxIcon.Warning);
                    Session["errorInfos"] = result;
                }
                else
                {
                    Session["errorInfos"] = null;
                    ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
                }
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
            }
            return(true);
        }
Пример #14
0
        /// <summary>
        /// 将Dataset的数据导入数据库
        /// </summary>
        /// <param name="pds">数据集</param>
        /// <param name="Cols">数据集行数</param>
        /// <returns></returns>
        private bool AddDatasetToSQL(DataTable pds, int Cols)
        {
            string result = string.Empty;
            int    ic, ir;

            ic = pds.Columns.Count;
            if (ic < Cols)
            {
                ShowNotify("导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "行", MessageBoxIcon.Warning);
            }

            ir = pds.Rows.Count;
            if (pds != null && ir > 0)
            {
                for (int i = 0; i < ir; i++)
                {
                    string row1   = pds.Rows[i][0].ToString();
                    string unitId = string.Empty;
                    if (!string.IsNullOrEmpty(row1))
                    {
                        var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == row1.Trim());
                        if (unit == null)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "单位名称" + "," + "[" + row1 + "]不存在!" + "|";
                        }
                        else
                        {
                            unitId = unit.UnitId;
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "单位名称" + "," + "此项为必填项!" + "|";
                    }

                    string row2 = pds.Rows[i][1].ToString();
                    if (!string.IsNullOrEmpty(row2))
                    {
                        try
                        {
                            Int32 yearId = Convert.ToInt32(row2.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "年度" + "," + "[" + row2 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "年度" + "," + "此项为必填项!" + "|";
                    }

                    string row3 = pds.Rows[i][2].ToString();
                    if (!string.IsNullOrEmpty(row3))
                    {
                        try
                        {
                            Int32 quarters = Convert.ToInt32(row3.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "季度" + "," + "[" + row3 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "季度" + "," + "此项为必填项!" + "|";
                    }

                    ////判断是否 已存在该季度数据
                    var safetyQuarterlyReport = BLL.SafetyQuarterlyReportService.GetSafetyQuarterlyReportByUnitIdAndYearAndQuarters(unitId, Funs.GetNewIntOrZero(row2.Trim()), Funs.GetNewIntOrZero(row3.Trim()));
                    if (safetyQuarterlyReport != null)
                    {
                        result += "第" + (i + 2).ToString() + "行," + "已存在该季度季报!" + "|";
                    }

                    string row4 = pds.Rows[i][3].ToString();
                    if (!string.IsNullOrEmpty(row4))
                    {
                        try
                        {
                            Int32 totalInWorkHours = Convert.ToInt32(row4.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "总投入工时数" + "," + "[" + row4 + "]错误!" + "|";
                        }
                    }
                    //string row5 = pds.Rows[i][4].ToString();
                    string row6 = pds.Rows[i][5].ToString();
                    if (!string.IsNullOrEmpty(row6))
                    {
                        try
                        {
                            Int32 totalOutWorkHours = Convert.ToInt32(row6.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "总损失工时数" + "," + "[" + row6 + "]错误!" + "|";
                        }
                    }
                    //string row7 = pds.Rows[i][6].ToString();
                    string row8 = pds.Rows[i][7].ToString();
                    if (!string.IsNullOrEmpty(row8))
                    {
                        try
                        {
                            Decimal workHoursLossRate = Convert.ToDecimal(row8.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "百万工时损失率" + "," + "[" + row8 + "]错误!" + "|";
                        }
                    }
                    //string row9 = pds.Rows[i][8].ToString().Trim();
                    string row10 = pds.Rows[i][9].ToString().Trim();
                    if (!string.IsNullOrEmpty(row10))
                    {
                        try
                        {
                            Decimal workHoursAccuracy = Convert.ToDecimal(row10.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "工时统计准确率" + "," + "[" + row10 + "]错误!" + "|";
                        }
                    }
                    //string row11 = pds.Rows[i][10].ToString().Trim();
                    string row12 = pds.Rows[i][11].ToString().Trim();
                    if (!string.IsNullOrEmpty(row12))
                    {
                        try
                        {
                            Decimal mainBusinessIncome = Convert.ToDecimal(row12);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "主营业务收入/亿元" + "," + "[" + row12 + "]错误!" + "|";
                        }
                    }
                    //string row13 = pds.Rows[i][12].ToString().Trim();
                    string row14 = pds.Rows[i][13].ToString().Trim();
                    if (!string.IsNullOrEmpty(row14))
                    {
                        try
                        {
                            Decimal constructionRevenue = Convert.ToDecimal(row14);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "施工收入/亿元" + "," + "[" + row14 + "]错误!" + "|";
                        }
                    }
                    //string row15 = pds.Rows[i][14].ToString().Trim();
                    string row16 = pds.Rows[i][15].ToString().Trim();
                    if (!string.IsNullOrEmpty(row16))
                    {
                        try
                        {
                            Decimal unitTimeIncome = Convert.ToDecimal(row16);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "单位工时收入/元" + "," + "[" + row16 + "]错误!" + "|";
                        }
                    }
                    //string row17 = pds.Rows[i][16].ToString().Trim();
                    string row18 = pds.Rows[i][17].ToString().Trim();
                    if (!string.IsNullOrEmpty(row18))
                    {
                        try
                        {
                            Decimal billionsOutputMortality = Convert.ToDecimal(row18);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "百亿产值死亡率" + "," + "[" + row18 + "]错误!" + "|";
                        }
                    }
                    //string row19 = pds.Rows[i][18].ToString().Trim();
                    string row20 = pds.Rows[i][19].ToString().Trim();
                    if (!string.IsNullOrEmpty(row20))
                    {
                        try
                        {
                            Int32 majorFireAccident = Convert.ToInt32(row20);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重大火灾事故报告数" + "," + "[" + row20 + "]错误!" + "|";
                        }
                    }
                    //string row21 = pds.Rows[i][20].ToString().Trim();
                    string row22 = pds.Rows[i][21].ToString().Trim();
                    if (!string.IsNullOrEmpty(row22))
                    {
                        try
                        {
                            Int32 majorEquipAccident = Convert.ToInt32(row22);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重大机械设备事故报告数" + "," + "[" + row22 + "]错误!" + "|";
                        }
                    }
                    //string row23 = pds.Rows[i][22].ToString().Trim();
                    string row24 = pds.Rows[i][23].ToString().Trim();
                    if (!string.IsNullOrEmpty(row24))
                    {
                        try
                        {
                            Decimal accidentFrequency = Convert.ToDecimal(row24);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "事故发生频率(占总收入之比)" + "," + "[" + row24 + "]错误!" + "|";
                        }
                    }
                    //string row25 = pds.Rows[i][24].ToString().Trim();
                    string row26 = pds.Rows[i][25].ToString().Trim();
                    if (!string.IsNullOrEmpty(row26))
                    {
                        try
                        {
                            Int32 seriousInjuryAccident = Convert.ToInt32(row26);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重伤以上事故报告数" + "," + "[" + row26 + "]错误!" + "|";
                        }
                    }
                    //string row27 = pds.Rows[i][26].ToString().Trim();
                    string row28 = pds.Rows[i][27].ToString().Trim();
                    if (!string.IsNullOrEmpty(row28))
                    {
                        try
                        {
                            Int32 fireAccident = Convert.ToInt32(row28);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "火灾事故统计报告数" + "," + "[" + row28 + "]错误!" + "|";
                        }
                    }
                    //string row29 = pds.Rows[i][28].ToString().Trim();
                    string row30 = pds.Rows[i][29].ToString().Trim();
                    if (!string.IsNullOrEmpty(row30))
                    {
                        try
                        {
                            Int32 equipmentAccident = Convert.ToInt32(row30);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "装备事故统计报告数" + "," + "[" + row30 + "]错误!" + "|";
                        }
                    }
                    //string row31 = pds.Rows[i][30].ToString().Trim();
                    string row32 = pds.Rows[i][31].ToString().Trim();
                    if (!string.IsNullOrEmpty(row32))
                    {
                        try
                        {
                            Int32 poisoningAndInjuries = Convert.ToInt32(row32);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "中毒及职业伤害报告数" + "," + "[" + row32 + "]错误!" + "|";
                        }
                    }
                    //string row33 = pds.Rows[i][32].ToString().Trim();
                    string row34 = pds.Rows[i][33].ToString().Trim();
                    if (!string.IsNullOrEmpty(row34))
                    {
                        try
                        {
                            Int32 productionSafetyInTotal = Convert.ToInt32(row34);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "安全生产投入总额/元" + "," + "[" + row34 + "]错误!" + "|";
                        }
                    }
                    //string row35 = pds.Rows[i][34].ToString().Trim();
                    string row36 = pds.Rows[i][35].ToString().Trim();
                    if (!string.IsNullOrEmpty(row36))
                    {
                        try
                        {
                            Decimal protectionInput = Convert.ToDecimal(row36);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "安全防护投入/元" + "," + "[" + row36 + "]错误!" + "|";
                        }
                    }
                    //string row37 = pds.Rows[i][36].ToString().Trim();
                    string row38 = pds.Rows[i][37].ToString().Trim();
                    if (!string.IsNullOrEmpty(row38))
                    {
                        try
                        {
                            Decimal laboAndHealthIn = Convert.ToDecimal(row38);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "劳动保护及职业健康投入/元" + "," + "[" + row38 + "]错误!" + "|";
                        }
                    }
                    //string row39 = pds.Rows[i][38].ToString().Trim();
                    string row40 = pds.Rows[i][39].ToString().Trim();
                    if (!string.IsNullOrEmpty(row40))
                    {
                        try
                        {
                            Decimal technologyProgressIn = Convert.ToDecimal(row40);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "安全技术进步投入/元" + "," + "[" + row40 + "]错误!" + "|";
                        }
                    }
                    //string row41 = pds.Rows[i][40].ToString().Trim();
                    string row42 = pds.Rows[i][41].ToString().Trim();
                    if (!string.IsNullOrEmpty(row42))
                    {
                        try
                        {
                            Decimal educationTrainIn = Convert.ToDecimal(row42);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "安全教育培训投入/元" + "," + "[" + row42 + "]错误!" + "|";
                        }
                    }
                    //string row43 = pds.Rows[i][42].ToString().Trim();
                    string row44 = pds.Rows[i][43].ToString().Trim();
                    if (!string.IsNullOrEmpty(row44))
                    {
                        try
                        {
                            Decimal projectCostRate = Convert.ToDecimal(row44);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "工程造价占比(%)" + "," + "[" + row44 + "]错误!" + "|";
                        }
                    }
                    //string row45 = pds.Rows[i][44].ToString().Trim();
                    string row46 = pds.Rows[i][45].ToString().Trim();
                    if (!string.IsNullOrEmpty(row46))
                    {
                        try
                        {
                            Decimal productionInput = Convert.ToDecimal(row46);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "百万工时安全生产投入额/万元" + "," + "[" + row46 + "]错误!" + "|";
                        }
                    }
                    //string row47 = pds.Rows[i][46].ToString().Trim();
                    string row48 = pds.Rows[i][47].ToString().Trim();
                    if (!string.IsNullOrEmpty(row48))
                    {
                        try
                        {
                            Decimal revenue = Convert.ToDecimal(row48);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "安全生产投入占施工收入之比" + "," + "[" + row48 + "]错误!" + "|";
                        }
                    }
                    //string row49 = pds.Rows[i][48].ToString().Trim();
                    string row50 = pds.Rows[i][49].ToString().Trim();
                    if (!string.IsNullOrEmpty(row50))
                    {
                        try
                        {
                            Int32 fullTimeMan = Convert.ToInt32(row50);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "安全专职人员总数" + "," + "[" + row50 + "]错误!" + "|";
                        }
                    }
                    //string row51 = pds.Rows[i][50].ToString().Trim();
                    string row52 = pds.Rows[i][51].ToString().Trim();
                    if (!string.IsNullOrEmpty(row52))
                    {
                        try
                        {
                            Int32 pMMan = Convert.ToInt32(row52);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "项目经理人员总数" + "," + "[" + row52 + "]错误!" + "|";
                        }
                    }
                    //string row53 = pds.Rows[i][52].ToString().Trim();
                    string row54 = pds.Rows[i][53].ToString().Trim();
                    if (!string.IsNullOrEmpty(row54))
                    {
                        try
                        {
                            Int32 corporateDirectorEdu = Convert.ToInt32(row54);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "企业负责人安全生产继续教育数" + "," + "[" + row54 + "]错误!" + "|";
                        }
                    }
                    //string row55 = pds.Rows[i][54].ToString().Trim();
                    string row56 = pds.Rows[i][55].ToString().Trim();
                    if (!string.IsNullOrEmpty(row56))
                    {
                        try
                        {
                            Int32 projectLeaderEdu = Convert.ToInt32(row56);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "项目负责人安全生产继续教育数" + "," + "[" + row56 + "]错误!" + "|";
                        }
                    }
                    //string row57 = pds.Rows[i][56].ToString().Trim();
                    string row58 = pds.Rows[i][57].ToString().Trim();
                    if (!string.IsNullOrEmpty(row58))
                    {
                        try
                        {
                            Int32 fullTimeEdu = Convert.ToInt32(row58);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "安全专职人员安全生产继续教育数" + "," + "[" + row58 + "]错误!" + "|";
                        }
                    }
                    //string row59 = pds.Rows[i][58].ToString().Trim();
                    string row60 = pds.Rows[i][59].ToString().Trim();
                    if (!string.IsNullOrEmpty(row60))
                    {
                        try
                        {
                            Decimal threeKidsEduRate = Convert.ToDecimal(row60);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "安全生产三类人员继续教育覆盖率" + "," + "[" + row60 + "]错误!" + "|";
                        }
                    }
                    //string row61 = pds.Rows[i][60].ToString().Trim();
                    string row62 = pds.Rows[i][61].ToString().Trim();
                    if (!string.IsNullOrEmpty(row62))
                    {
                        try
                        {
                            Decimal uplinReportRate = Convert.ToDecimal(row62);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "上行报告履行率" + "," + "[" + row62 + "]错误!" + "|";
                        }
                    }
                    //string row63 = pds.Rows[i][62].ToString().Trim();
                    string row64 = pds.Rows[i][63].ToString().Trim();
                    if (!string.IsNullOrEmpty(row64))
                    {
                        try
                        {
                            Int32 keyEquipmentTotal = Convert.ToInt32(row64);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重点装备总数" + "," + "[" + row64 + "]错误!" + "|";
                        }
                    }
                    //string row65 = pds.Rows[i][64].ToString().Trim();
                    string row66 = pds.Rows[i][65].ToString().Trim();
                    if (!string.IsNullOrEmpty(row66))
                    {
                        try
                        {
                            Int32 keyEquipmentReportCount = Convert.ToInt32(row66);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重点装备安全控制检查报告数" + "," + "[" + row66 + "]错误!" + "|";
                        }
                    }
                    //string row67 = pds.Rows[i][66].ToString().Trim();
                    string row68 = pds.Rows[i][67].ToString().Trim();
                    if (!string.IsNullOrEmpty(row68))
                    {
                        try
                        {
                            Int32 chemicalAreaProjectCount = Convert.ToInt32(row68);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "化工界区施工作业项目数" + "," + "[" + row68 + "]错误!" + "|";
                        }
                    }
                    //string row69 = pds.Rows[i][68].ToString().Trim();
                    string row70 = pds.Rows[i][69].ToString().Trim();
                    if (!string.IsNullOrEmpty(row70))
                    {
                        try
                        {
                            Int32 harmfulMediumCoverCount = Convert.ToInt32(row70);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "化工界区施工作业有害介质检测复测覆盖数" + "," + "[" + row70 + "]错误!" + "|";
                        }
                    }
                    //string row71 = pds.Rows[i][70].ToString().Trim();
                    string row72 = pds.Rows[i][71].ToString().Trim();
                    if (!string.IsNullOrEmpty(row72))
                    {
                        try
                        {
                            Decimal harmfulMediumCoverRate = Convert.ToDecimal(row72);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "施工作业安全技术交底覆盖率(%)" + "," + "[" + row72 + "]错误!" + "|";
                        }
                    }
                    //string row73 = pds.Rows[i][72].ToString().Trim();
                    //string row74 = pds.Rows[i][73].ToString().Trim();
                }
                if (!string.IsNullOrEmpty(result))
                {
                    result = result.Substring(0, result.LastIndexOf("|"));
                    ShowNotify(result, MessageBoxIcon.Warning);
                    //Session["errorInfos"] = result;
                }
                else
                {
                    ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
                }
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
            }
            return(true);
        }
        /// <summary>
        /// 将Dataset的数据导入数据库
        /// </summary>
        /// <param name="pds">数据集</param>
        /// <param name="Cols">数据集行数</param>
        /// <returns></returns>
        private bool AddDatasetToSQL(DataTable pds, int Cols)
        {
            string result = string.Empty;
            int    ic, ir;

            ic = pds.Columns.Count;
            if (ic < Cols)
            {
                ShowNotify("导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "行", MessageBoxIcon.Warning);
            }

            ir = pds.Rows.Count;
            if (pds != null && ir > 0)
            {
                for (int i = 0; i < ir; i++)
                {
                    string row1   = pds.Rows[i][0].ToString();
                    string unitId = string.Empty;
                    if (!string.IsNullOrEmpty(row1))
                    {
                        var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == row1.Trim());
                        if (unit == null)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "单位名称" + "," + "[" + row1 + "]不存在!" + "|";
                        }
                        else
                        {
                            unitId = unit.UnitId;
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "单位名称" + "," + "此项为必填项!" + "|";
                    }

                    string row2 = pds.Rows[i][1].ToString();
                    if (!string.IsNullOrEmpty(row2))
                    {
                        try
                        {
                            Int32 year = Convert.ToInt32(row2.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "年份" + "," + "[" + row2 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "年份" + "," + "此项为必填项!" + "|";
                    }

                    string row3 = pds.Rows[i][2].ToString();
                    if (!string.IsNullOrEmpty(row3))
                    {
                        try
                        {
                            Int32 month = Convert.ToInt32(row3.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "半年度" + "," + "[" + row3 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "半年度" + "," + "此项为必填项!" + "|";
                    }

                    ////判断是否 已存在该半年数据
                    var drillPlanHalfYearReport = BLL.DrillPlanHalfYearReportService.GetDrillPlanHalfYearReportByUnitIdAndYearAndHalfYear(unitId, Funs.GetNewIntOrZero(row2.Trim()), Funs.GetNewIntOrZero(row3.Trim()));
                    if (drillPlanHalfYearReport != null)
                    {
                        result += "第" + (i + 2).ToString() + "行," + "已存在该半年度半年报!" + "|";
                    }
                }

                if (!string.IsNullOrEmpty(result))
                {
                    result = result.Substring(0, result.LastIndexOf("|"));
                    ShowNotify(result, MessageBoxIcon.Warning);
                    //Session["errorInfos"] = result;
                }
                else
                {
                    ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
                }
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
            }
            return(true);
        }
Пример #16
0
 /// <summary>
 /// 分页显示条数下拉框
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.Grid1.PageSize = Funs.GetNewIntOrZero(this.ddlPageSize.SelectedValue);
     BindGrid();
 }
Пример #17
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="type"></param>
        private void SaveData(string type)
        {
            Model.Check_CheckDayXA checkDay = new Model.Check_CheckDayXA
            {
                CheckDayCode = this.txtCheckDayCode.Text.Trim(),
                ProjectId    = this.ProjectId,
                NotOKNum     = Funs.GetNewIntOrZero(this.txtNotOKNum.Text.Trim()),
                CheckDate    = Funs.GetNewDateTimeOrNow(this.txtCheckDate.Text.Trim())
            };
            if (this.trUnit.Hidden == false)
            {
                //受检单位
                string unitIds = string.Empty;
                foreach (var item in this.drpDutyUnitIds.SelectedValueArray)
                {
                    unitIds += item + ",";
                }
                if (!string.IsNullOrEmpty(unitIds))
                {
                    unitIds = unitIds.Substring(0, unitIds.LastIndexOf(","));
                }
                checkDay.DutyUnitIds = unitIds;
            }
            if (this.trTeamGroup.Hidden == false)
            {
                //受检班组
                string teamGroupIds = string.Empty;
                foreach (var item in this.drpDutyTeamGroupIds.SelectedValueArray)
                {
                    teamGroupIds += item + ",";
                }
                if (!string.IsNullOrEmpty(teamGroupIds))
                {
                    teamGroupIds = teamGroupIds.Substring(0, teamGroupIds.LastIndexOf(","));
                }
                checkDay.DutyTeamGroupIds = teamGroupIds;
            }
            //检查区域
            string workAreaIds = string.Empty;

            foreach (var item in this.drpWorkAreaIds.SelectedValueArray)
            {
                workAreaIds += item + ",";
            }
            if (!string.IsNullOrEmpty(workAreaIds))
            {
                workAreaIds = workAreaIds.Substring(0, workAreaIds.LastIndexOf(","));
            }
            checkDay.WorkAreaIds = workAreaIds;
            checkDay.Unqualified = this.txtUnqualified.Text.Trim();
            if (this.drpCheckMan.SelectedValue != BLL.Const._Null)
            {
                checkDay.CompileMan = this.drpCheckMan.SelectedValue;
            }
            else
            {
                checkDay.CompileMan = this.CurrUser.UserId;
            }
            ////单据状态
            //checkDay.States = BLL.Const.State_0;
            //if (type == BLL.Const.BtnSubmit)
            //{
            //    checkDay.States = this.ctlAuditFlow.NextStep;
            //}
            if (!string.IsNullOrEmpty(this.CheckDayId))
            {
                checkDay.CheckDayId = this.CheckDayId;
                BLL.Check_CheckDayXAService.UpdateCheckDay(checkDay);
                BLL.LogService.AddSys_Log(this.CurrUser, checkDay.CheckDayCode, checkDay.CheckDayId, BLL.Const.ProjectCheckDayXAMenuId, BLL.Const.BtnModify);
            }
            else
            {
                checkDay.CheckDayId  = SQLHelper.GetNewID(typeof(Model.Check_CheckDayXA));
                this.CheckDayId      = checkDay.CheckDayId;
                checkDay.CompileUnit = this.CurrUser.UnitId;
                BLL.Check_CheckDayXAService.AddCheckDay(checkDay);
                BLL.LogService.AddSys_Log(this.CurrUser, checkDay.CheckDayCode, checkDay.CheckDayId, BLL.Const.ProjectCheckDayXAMenuId, BLL.Const.BtnAdd);
            }
        }
Пример #18
0
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <param name="type"></param>
        private void SaveData(string type)
        {
            if (this.drpAccidentTypeId.SelectedValue == BLL.Const._Null)
            {
                Alert.ShowInTop("请选择事故类型!", MessageBoxIcon.Warning);
                return;
            }
            if (this.rbIsNotConfirm.SelectedValue == "True")
            {
                if (this.drpUnitId2.SelectedValue == BLL.Const._Null)
                {
                    Alert.ShowInTop("请选择事故责任单位!", MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                if (this.drpUnitId.SelectedValue == BLL.Const._Null)
                {
                    Alert.ShowInTop("请选择事故责任单位!", MessageBoxIcon.Warning);
                    return;
                }
            }

            Model.Accident_AccidentReport accidentReport = new Model.Accident_AccidentReport
            {
                ProjectId          = this.ProjectId,
                AccidentReportCode = this.txtAccidentReportCode.Text.Trim(),
                //accidentReport.AccidentReportType = this.drpAccidentReportType.SelectedValue;
                FileContent = HttpUtility.HtmlEncode(this.txtFileContents.Text)
            };
            if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
            {
                accidentReport.CompileMan = this.drpCompileMan.SelectedValue;
            }
            accidentReport.CompileDate        = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim());
            accidentReport.States             = BLL.Const.State_0;
            accidentReport.AccidentReportName = this.txtAccidentReportName.Text.Trim();
            if (this.drpAccidentTypeId.SelectedValue != BLL.Const._Null)
            {
                accidentReport.AccidentTypeId = this.drpAccidentTypeId.SelectedValue;
                if (this.rbIsNotConfirm.Hidden == false)
                {
                    accidentReport.IsNotConfirm = Convert.ToBoolean(this.rbIsNotConfirm.SelectedValue);
                }
            }
            accidentReport.Abstract     = this.txtAbstract.Text.Trim();
            accidentReport.AccidentDate = Funs.GetNewDateTime(this.txtAccidentDate.Text.Trim());
            accidentReport.WorkArea     = this.txtWorkArea.Text;
            accidentReport.PeopleNum    = Funs.GetNewIntOrZero(this.txtPeopleNum.Text.Trim());
            if (accidentReport.IsNotConfirm == true)  //待定事故
            {
                accidentReport.UnitId = this.drpUnitId2.SelectedValue;
                accidentReport.NotConfirmWorkingHoursLoss  = this.txtNotConfirmWorkingHoursLoss.Text.Trim();
                accidentReport.NotConfirmEconomicLoss      = this.txtNotConfirmEconomicLoss.Text.Trim();
                accidentReport.NotConfirmEconomicOtherLoss = this.txtNotConfirmEconomicOtherLoss.Text.Trim();
            }
            else
            {
                accidentReport.UnitId            = this.drpUnitId.SelectedValue;
                accidentReport.WorkingHoursLoss  = Funs.GetNewDecimalOrZero(this.txtWorkingHoursLoss.Text.Trim());
                accidentReport.EconomicLoss      = Funs.GetNewDecimalOrZero(this.txtEconomicLoss.Text.Trim());
                accidentReport.EconomicOtherLoss = Funs.GetNewDecimalOrZero(this.txtEconomicOtherLoss.Text.Trim());
            }
            accidentReport.ReportMan          = this.txtReportMan.Text.Trim();
            accidentReport.ReporterUnit       = this.txtReporterUnit.Text.Trim();
            accidentReport.ReportDate         = Funs.GetNewDateTime(this.txtReportDate.Text.Trim());
            accidentReport.ProcessDescription = this.txtProcessDescription.Text.Trim();
            accidentReport.EmergencyMeasures  = this.txtEmergencyMeasures.Text.Trim();
            if (type == BLL.Const.BtnSubmit)
            {
                accidentReport.States = this.ctlAuditFlow.NextStep;
            }
            if (!string.IsNullOrEmpty(this.AccidentReportId))
            {
                accidentReport.AccidentReportId = this.AccidentReportId;
                BLL.AccidentReport2Service.UpdateAccidentReport(accidentReport);
                BLL.LogService.AddSys_Log(this.CurrUser, this.txtAccidentReportCode.Text, this.AccidentReportId, BLL.Const.ProjectAccidentReportMenuId, Const.BtnModify);
                Model.Accident_AccidentReport a = BLL.AccidentReport2Service.GetAccidentReportById(this.AccidentReportId);
                if (type == BLL.Const.BtnSubmit && accidentReport.States == BLL.Const.State_2 && a.NotConfirmed == true)
                {
                    //更新待定事故之前月报
                    DateTime startMonth = Convert.ToDateTime(a.AccidentDate.Value.Year + "-" + a.AccidentDate.Value.Month + "-01");
                    Model.Manager_MonthReportB startMonthReport = BLL.MonthReportBService.GetMonthReportByMonth(startMonth, this.ProjectId);
                    if (startMonthReport != null)  //事故当月月报
                    {
                        Model.Manager_AccidentSortB sort = new Model.Manager_AccidentSortB();
                        if (a.AccidentTypeId == "1")
                        {
                            sort = (from x in Funs.DB.Manager_AccidentSortB
                                    where x.AccidentType == "死 亡 事 故" && x.MonthReportId == startMonthReport.MonthReportId
                                    select x).FirstOrDefault();
                        }
                        else if (a.AccidentTypeId == "2")
                        {
                            sort = (from x in Funs.DB.Manager_AccidentSortB
                                    where x.AccidentType == "重 伤 事 故" && x.MonthReportId == startMonthReport.MonthReportId
                                    select x).FirstOrDefault();
                        }
                        else if (a.AccidentTypeId == "3")
                        {
                            sort = (from x in Funs.DB.Manager_AccidentSortB
                                    where x.AccidentType == "轻 伤 事 故" && x.MonthReportId == startMonthReport.MonthReportId
                                    select x).FirstOrDefault();
                        }
                        if (sort != null)
                        {
                            sort.Number         += 1;
                            sort.TotalNum       += 1;
                            sort.PersonNum      += a.PeopleNum ?? 0;
                            sort.TotalPersonNum += a.PeopleNum ?? 0;
                            sort.LoseHours      += Funs.GetNewIntOrZero((a.WorkingHoursLoss ?? 0).ToString());
                            sort.TotalLoseHours += Funs.GetNewIntOrZero((a.WorkingHoursLoss ?? 0).ToString());
                            sort.LoseMoney      += (a.EconomicLoss ?? 0) + (a.EconomicOtherLoss ?? 0);
                            sort.TotalLoseMoney += (a.EconomicLoss ?? 0) + (a.EconomicOtherLoss ?? 0);
                            Funs.DB.SubmitChanges();
                        }
                        List <Model.Manager_MonthReportB> monthReports = (from x in Funs.DB.Manager_MonthReportB
                                                                          where x.Months > startMonth && x.ProjectId == this.ProjectId
                                                                          select x).ToList();
                        foreach (var monthReport in monthReports)
                        {
                            if (monthReport != null)
                            {
                                Model.Manager_AccidentSortB sort1 = new Model.Manager_AccidentSortB();
                                if (a.AccidentTypeId == "1")
                                {
                                    sort1 = (from x in Funs.DB.Manager_AccidentSortB
                                             where x.AccidentType == "死 亡 事 故" && x.MonthReportId == monthReport.MonthReportId
                                             select x).FirstOrDefault();
                                }
                                else if (a.AccidentTypeId == "2")
                                {
                                    sort1 = (from x in Funs.DB.Manager_AccidentSortB
                                             where x.AccidentType == "重 伤 事 故" && x.MonthReportId == monthReport.MonthReportId
                                             select x).FirstOrDefault();
                                }
                                else if (a.AccidentTypeId == "3")
                                {
                                    sort1 = (from x in Funs.DB.Manager_AccidentSortB
                                             where x.AccidentType == "轻 伤 事 故" && x.MonthReportId == monthReport.MonthReportId
                                             select x).FirstOrDefault();
                                }
                                if (sort1 != null)
                                {
                                    sort1.TotalNum       += 1;
                                    sort1.TotalPersonNum += a.PeopleNum ?? 0;
                                    sort1.TotalLoseHours += Funs.GetNewIntOrZero((a.WorkingHoursLoss ?? 0).ToString());
                                    sort1.TotalLoseMoney += (a.EconomicLoss ?? 0) + (a.EconomicOtherLoss ?? 0);
                                    Funs.DB.SubmitChanges();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                this.AccidentReportId           = SQLHelper.GetNewID(typeof(Model.Accident_AccidentReport));
                accidentReport.AccidentReportId = this.AccidentReportId;
                if (accidentReport.IsNotConfirm == true)  //待定事故
                {
                    accidentReport.NotConfirmed = true;
                }
                BLL.AccidentReport2Service.AddAccidentReport(accidentReport);
                BLL.LogService.AddSys_Log(this.CurrUser, this.txtAccidentReportCode.Text, this.AccidentReportId, BLL.Const.ProjectAccidentReportMenuId, Const.BtnAdd);
            }
            //保存流程审核数据
            this.ctlAuditFlow.btnSaveData(this.ProjectId, BLL.Const.ProjectAccidentReportMenuId, this.AccidentReportId, (type == BLL.Const.BtnSubmit ? true : false), accidentReport.AccidentReportCode, "../Accident/AccidentReportView.aspx?AccidentReportId={0}");
        }
Пример #19
0
        /// <summary>
        /// 将Dataset的数据导入数据库
        /// </summary>
        /// <param name="pds">数据集</param>
        /// <param name="Cols">数据集行数</param>
        /// <returns></returns>
        private bool AddDatasetToSQL(DataTable pds, int Cols)
        {
            string result = string.Empty;
            int    ic, ir;

            ic = pds.Columns.Count;
            if (ic < Cols)
            {
                ShowNotify("导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "行", MessageBoxIcon.Warning);
            }

            ir = pds.Rows.Count;
            if (pds != null && ir > 0)
            {
                var units = from x in Funs.DB.Base_Unit select x;
                for (int i = 0; i < ir; i++)
                {
                    string row1   = pds.Rows[i][0].ToString();
                    string unitId = string.Empty;
                    if (!string.IsNullOrEmpty(row1))
                    {
                        var unit = units.FirstOrDefault(x => x.UnitName == row1.Trim());
                        if (unit == null)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "单位名称" + "," + "[" + row1 + "]不存在!" + "|";
                        }
                        else
                        {
                            unitId = unit.UnitId;
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "单位名称" + "," + "此项为必填项!" + "|";
                    }

                    string row2 = pds.Rows[i][1].ToString();
                    if (!string.IsNullOrEmpty(row2))
                    {
                        try
                        {
                            Int32 year = Convert.ToInt32(row2.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "年份" + "," + "[" + row2 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "年份" + "," + "此项为必填项!" + "|";
                    }

                    string row3 = pds.Rows[i][2].ToString();
                    if (!string.IsNullOrEmpty(row3))
                    {
                        try
                        {
                            Int32 month = Convert.ToInt32(row3.Trim());
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "月份" + "," + "[" + row3 + "]错误!" + "|";
                        }
                    }
                    else
                    {
                        result += "第" + (i + 2).ToString() + "行," + "月份" + "," + "此项为必填项!" + "|";
                    }

                    ////判断是否 已存在该月份数据
                    var millionsMonthlyReport = BLL.MillionsMonthlyReportService.GetMillionsMonthlyReportByUnitIdAndYearAndMonth(unitId, Funs.GetNewIntOrZero(row2.Trim()), Funs.GetNewIntOrZero(row3.Trim()));
                    if (millionsMonthlyReport != null)
                    {
                        result += "第" + (i + 2).ToString() + "行," + "已存在该月份月报!" + "|";
                    }

                    string row4 = pds.Rows[i][3].ToString();
                    if (string.IsNullOrEmpty(row4))
                    {
                        result += "第" + (i + 2).ToString() + "行," + "负责人" + "," + "此项为必填项!" + "|";
                    }
                    string row5 = pds.Rows[i][4].ToString().Trim();
                    if (!string.IsNullOrEmpty(row5))
                    {
                        try
                        {
                            Decimal recordableIncidentRate = Convert.ToDecimal(row5);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "百万工时总可记录事故率" + "," + "[" + row5 + "]错误!" + "|";
                        }
                    }
                    string row6 = pds.Rows[i][5].ToString().Trim();
                    if (!string.IsNullOrEmpty(row6))
                    {
                        try
                        {
                            Decimal lostTimeRate = Convert.ToDecimal(row6);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "百万工时损失工时率" + "," + "[" + row6 + "]错误!" + "|";
                        }
                    }
                    string row7 = pds.Rows[i][6].ToString().Trim();
                    if (!string.IsNullOrEmpty(row7))
                    {
                        try
                        {
                            Decimal lostTimeInjuryRate = Convert.ToDecimal(row7);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "百万工时损失工时伤害事故率" + "," + "[" + row7 + "]错误!" + "|";
                        }
                    }
                    string row8 = pds.Rows[i][7].ToString().Trim();
                    if (!string.IsNullOrEmpty(row8))
                    {
                        try
                        {
                            Decimal deathAccidentFrequency = Convert.ToDecimal(row8);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "百万工时死亡事故频率" + "," + "[" + row8 + "]错误!" + "|";
                        }
                    }
                    string row9 = pds.Rows[i][8].ToString().Trim();
                    if (!string.IsNullOrEmpty(row9))
                    {
                        try
                        {
                            Decimal accidentMortality = Convert.ToDecimal(row9);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "百万工时事故死亡率" + "," + "[" + row9 + "]错误!" + "|";
                        }
                    }
                    //string row10 = pds.Rows[i][9].ToString().Trim();
                    //string row11 = pds.Rows[i][10].ToString().Trim();
                    string row12 = pds.Rows[i][11].ToString().Trim();
                    if (!string.IsNullOrEmpty(row12))
                    {
                        try
                        {
                            Int32 postPersonNum = Convert.ToInt32(row12);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "在岗员工数" + "," + "[" + row12 + "]错误!" + "|";
                        }
                    }
                    string row13 = pds.Rows[i][12].ToString().Trim();
                    if (!string.IsNullOrEmpty(row13))
                    {
                        try
                        {
                            Int32 snapPersonNum = Convert.ToInt32(row13);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "临时员工数" + "," + "[" + row13 + "]错误!" + "|";
                        }
                    }
                    string row14 = pds.Rows[i][13].ToString().Trim();
                    if (!string.IsNullOrEmpty(row14))
                    {
                        try
                        {
                            Int32 contractorNum = Convert.ToInt32(row14);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "承包商数量" + "," + "[" + row14 + "]错误!" + "|";
                        }
                    }
                    string row15 = pds.Rows[i][14].ToString().Trim();
                    if (!string.IsNullOrEmpty(row15))
                    {
                        try
                        {
                            Int32 sumPersonNum = Convert.ToInt32(row15);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "员工总数合计" + "," + "[" + row15 + "]错误!" + "|";
                        }
                    }
                    string row16 = pds.Rows[i][15].ToString().Trim();
                    if (!string.IsNullOrEmpty(row16))
                    {
                        try
                        {
                            Decimal totalWorkNum = Convert.ToDecimal(row16);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "总工时数(万)" + "," + "[" + row16 + "]错误!" + "|";
                        }
                    }
                    string row17 = pds.Rows[i][16].ToString().Trim();
                    if (!string.IsNullOrEmpty(row17))
                    {
                        try
                        {
                            Int32 seriousInjuriesNum = Convert.ToInt32(row17);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重伤事故起数" + "," + "[" + row17 + "]错误!" + "|";
                        }
                    }
                    string row18 = pds.Rows[i][17].ToString().Trim();
                    if (!string.IsNullOrEmpty(row18))
                    {
                        try
                        {
                            Int32 seriousInjuriesPersonNum = Convert.ToInt32(row18);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重伤事故人数" + "," + "[" + row18 + "]错误!" + "|";
                        }
                    }
                    string row19 = pds.Rows[i][18].ToString().Trim();
                    if (!string.IsNullOrEmpty(row19))
                    {
                        try
                        {
                            Int32 seriousInjuriesLossHour = Convert.ToInt32(row19);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "重伤事故损失工时" + "," + "[" + row19 + "]错误!" + "|";
                        }
                    }
                    string row20 = pds.Rows[i][19].ToString().Trim();
                    if (!string.IsNullOrEmpty(row20))
                    {
                        try
                        {
                            Int32 minorAccidentNum = Convert.ToInt32(row20);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "轻伤事故起数" + "," + "[" + row20 + "]错误!" + "|";
                        }
                    }
                    string row21 = pds.Rows[i][20].ToString().Trim();
                    if (!string.IsNullOrEmpty(row21))
                    {
                        try
                        {
                            Int32 minorAccidentPersonNum = Convert.ToInt32(row21);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "轻伤事故人数" + "," + "[" + row21 + "]错误!" + "|";
                        }
                    }
                    string row22 = pds.Rows[i][21].ToString().Trim();
                    if (!string.IsNullOrEmpty(row22))
                    {
                        try
                        {
                            Int32 minorAccidentLossHour = Convert.ToInt32(row22);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "轻伤事故损失工时" + "," + "[" + row22 + "]错误!" + "|";
                        }
                    }
                    string row23 = pds.Rows[i][22].ToString().Trim();
                    if (!string.IsNullOrEmpty(row23))
                    {
                        try
                        {
                            Int32 otherAccidentNum = Convert.ToInt32(row23);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "其它事故起数" + "," + "[" + row23 + "]错误!" + "|";
                        }
                    }
                    string row24 = pds.Rows[i][23].ToString().Trim();
                    if (!string.IsNullOrEmpty(row24))
                    {
                        try
                        {
                            Int32 otherAccidentPersonNum = Convert.ToInt32(row24);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "其它事故人数" + "," + "[" + row24 + "]错误!" + "|";
                        }
                    }
                    string row25 = pds.Rows[i][24].ToString().Trim();
                    if (!string.IsNullOrEmpty(row25))
                    {
                        try
                        {
                            Int32 otherAccidentLossHour = Convert.ToInt32(row25);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "其它事故损失工时" + "," + "[" + row25 + "]错误!" + "|";
                        }
                    }
                    string row26 = pds.Rows[i][25].ToString().Trim();
                    if (!string.IsNullOrEmpty(row26))
                    {
                        try
                        {
                            Int32 restrictedWorkPersonNum = Convert.ToInt32(row26);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "工作受限人数" + "," + "[" + row26 + "]错误!" + "|";
                        }
                    }
                    string row27 = pds.Rows[i][26].ToString().Trim();
                    if (!string.IsNullOrEmpty(row27))
                    {
                        try
                        {
                            Int32 restrictedWorkLossHour = Convert.ToInt32(row27);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "工作受限损失工时" + "," + "[" + row27 + "]错误!" + "|";
                        }
                    }
                    string row28 = pds.Rows[i][27].ToString().Trim();
                    if (!string.IsNullOrEmpty(row28))
                    {
                        try
                        {
                            Int32 medicalTreatmentPersonNum = Convert.ToInt32(row28);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "医疗处置人数" + "," + "[" + row28 + "]错误!" + "|";
                        }
                    }
                    string row29 = pds.Rows[i][28].ToString().Trim();
                    if (!string.IsNullOrEmpty(row29))
                    {
                        try
                        {
                            Int32 medicalTreatmentLossHour = Convert.ToInt32(row29);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "医疗处置损失工时" + "," + "[" + row29 + "]错误!" + "|";
                        }
                    }
                    string row30 = pds.Rows[i][29].ToString().Trim();
                    if (!string.IsNullOrEmpty(row30))
                    {
                        try
                        {
                            Int32 fireNum = Convert.ToInt32(row30);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "火灾起数" + "," + "[" + row30 + "]错误!" + "|";
                        }
                    }
                    string row31 = pds.Rows[i][30].ToString().Trim();
                    if (!string.IsNullOrEmpty(row31))
                    {
                        try
                        {
                            Int32 explosionNum = Convert.ToInt32(row31);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "爆炸起数" + "," + "[" + row31 + "]错误!" + "|";
                        }
                    }
                    string row32 = pds.Rows[i][31].ToString().Trim();
                    if (!string.IsNullOrEmpty(row32))
                    {
                        try
                        {
                            Int32 trafficNum = Convert.ToInt32(row32);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "交通起数" + "," + "[" + row32 + "]错误!" + "|";
                        }
                    }
                    string row33 = pds.Rows[i][32].ToString().Trim();
                    if (!string.IsNullOrEmpty(row33))
                    {
                        try
                        {
                            Int32 equipmentNum = Convert.ToInt32(row33);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "机械设备起数" + "," + "[" + row33 + "]错误!" + "|";
                        }
                    }
                    string row34 = pds.Rows[i][33].ToString().Trim();
                    if (!string.IsNullOrEmpty(row34))
                    {
                        try
                        {
                            Int32 qualityNum = Convert.ToInt32(row34);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "质量起数" + "," + "[" + row34 + "]错误!" + "|";
                        }
                    }
                    string row35 = pds.Rows[i][34].ToString().Trim();
                    if (!string.IsNullOrEmpty(row35))
                    {
                        try
                        {
                            Int32 otherNum = Convert.ToInt32(row35);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "其它起数" + "," + "[" + row35 + "]错误!" + "|";
                        }
                    }
                    string row36 = pds.Rows[i][35].ToString().Trim();
                    if (!string.IsNullOrEmpty(row36))
                    {
                        try
                        {
                            Int32 firstAidDressingsNum = Convert.ToInt32(row36);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "急救包扎起数" + "," + "[" + row36 + "]错误!" + "|";
                        }
                    }
                    string row37 = pds.Rows[i][36].ToString().Trim();
                    if (!string.IsNullOrEmpty(row37))
                    {
                        try
                        {
                            Int32 attemptedEventNum = Convert.ToInt32(row37);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "未遂事件起数" + "," + "[" + row37 + "]错误!" + "|";
                        }
                    }
                    string row38 = pds.Rows[i][37].ToString().Trim();
                    if (!string.IsNullOrEmpty(row38))
                    {
                        try
                        {
                            Int32 lossDayNum = Convert.ToInt32(row38);
                        }
                        catch (Exception)
                        {
                            result += "第" + (i + 2).ToString() + "行," + "损失工日" + "," + "[" + row38 + "]错误!" + "|";
                        }
                    }
                }
                if (!string.IsNullOrEmpty(result))
                {
                    result = result.Substring(0, result.LastIndexOf("|"));
                    ShowNotify(result, MessageBoxIcon.Warning);
                    //Session["errorInfos"] = result;
                }
                else
                {
                    ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
                }
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
            }
            return(true);
        }