コード例 #1
0
        public ActionResult SpecialQualify(SpecialQualifySaveModel model)
        {
            ControllerResult result = ControllerResult.SuccResult;

            try
            {
                string erroMsg = string.Empty;
                result.IsSucc = true;
                t_D_userTableSC saveModel = new t_D_userTableSC()
                {
                    unitName    = model.unitName,
                    frdb        = model.frdb,
                    sqnr        = model.sqnr,
                    ssfzr       = model.ssfzr,
                    onesjz      = model.onesjz,
                    onedbqk     = model.onedbqk,
                    twosjz      = model.twosjz,
                    twodbqk     = model.twodbqk,
                    threesjz    = model.threesjz,
                    threedbqk   = model.threedbqk,
                    foursjz     = model.foursjz,
                    fourdbqk    = model.fourdbqk,
                    fivesjzone  = model.fivesjzone,
                    fivedbqkone = model.fivedbqkone,
                    fivesjztwo  = model.fivesjztwo,
                    fivedbqktwo = model.fivedbqktwo,
                    sixsjz      = model.sixsjz,
                    sixdbqk     = model.sixdbqk,
                    sevensjz    = model.sevensjz,
                    sevendbqk   = model.sevendbqk,
                    shyj        = model.shyj,
                    username    = model.username,
                    createtime  = model.createtime,
                    addtime     = DateTime.Now,
                    pid         = model.pid
                };
                if (!checkQualifyService.SaveSpeicalQualify(saveModel, GetCurrentUserId(), out erroMsg))
                {
                    result         = ControllerResult.FailResult;
                    result.ErroMsg = erroMsg;
                    result.IsSucc  = false;
                }
                else
                {
                    LogUserAction("对单位:{0} 进行了[专项检测备案]审批操作".Fmt(model.unitName));
                }
            }
            catch (Exception ex)
            {
                result         = ControllerResult.FailResult;
                result.ErroMsg = ex.Message;
                result.IsSucc  = true;
            }

            return(Content(result.ToJson()));
        }
コード例 #2
0
        /// <summary>
        /// 专家 保存专项检测备案审核表
        /// </summary>
        /// <param name="saveModel"></param>
        /// <param name="userid"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public bool SaveSpeicalQualify(t_D_userTableSC saveModel, int userid, out string errorMsg)
        {
            using (var db = dbFactory.Open())
            {
                using (var dbTrans = db.OpenTransaction())
                {
                    try
                    {
                        errorMsg = string.Empty;

                        //保存 t_D_userTableSC 专项检测备案审核表 记录
                        var id = db.Insert(saveModel, true);

                        //更新状态
                        db.UpdateOnly(new t_D_UserExpertUnit
                        {
                            status           = 1,
                            speicalstatus    = 1,
                            speicalchecktime = DateTime.Now,
                            scid             = id
                        }, r => new
                        {
                            r.status,
                            r.speicalstatus,
                            r.speicalchecktime,
                            r.scid
                        }, r => r.pid == saveModel.pid && r.userid == userid);

                        //先提交
                        dbTrans.Commit();

                        //再查询判断所有专家的审批是否已经完成
                        int index         = 0;
                        int ApprovaledCnt = 0;
                        var ueus          = repExp.GetByCondition(r => r.pid == saveModel.pid);
                        foreach (var ueu in ueus)
                        {
                            index++;
                            if (ueu.needUnitBuildingQualify == 1 && ueu.needSpecialQualify == 1)
                            {
                                if (ueu.qualifystatus == 1 && ueu.speicalstatus == 1)
                                {
                                    ApprovaledCnt += 1;
                                }
                            }
                            else if (ueu.needUnitBuildingQualify == 1 && ueu.needSpecialQualify == 0)
                            {
                                if (ueu.qualifystatus == 1)
                                {
                                    ApprovaledCnt += 1;
                                }
                            }
                            else if (ueu.needUnitBuildingQualify == 0 && ueu.needSpecialQualify == 1)
                            {
                                if (ueu.speicalstatus == 1)
                                {
                                    ApprovaledCnt += 1;
                                }
                            }
                        }

                        //审批都已经经完成
                        if (index == ApprovaledCnt)
                        {
                            db.UpdateOnly(new t_D_UserTableTen
                            {
                                @static = 3
                            }, r => new
                            {
                                r.@static
                            }, r => r.pid == saveModel.pid);
                        }

                        return(true);
                    }
                    catch (Exception ex)
                    {
                        dbTrans.Rollback();
                        errorMsg = ex.Message;
                        return(false);
                    }
                }
            }
        }