예제 #1
0
        protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID)
        {
            if (isNew)
            {
                string engineeringInfo = GetQueryString("EngineeringInfo");
                if (string.IsNullOrEmpty(engineeringInfo))
                {
                    throw new Formula.Exceptions.BusinessValidationException("请选择项目!");
                }

                string sql = string.Format("select * from S_I_Engineering where ID='{0}' ", engineeringInfo);
                var    dt  = EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    throw new Formula.Exceptions.BusinessValidationException("所选项目不存在!");
                }
                var engineering = FormulaHelper.DataRowToDic(dt.Rows[0]);

                dic.SetValue("EngineeringInfo", engineering.GetValue("ID"));
                dic.SetValue("EngineeringInfoName", engineering.GetValue("Name"));

                dic.SetValue("ProNature", "严重");
                dic.SetValue("CheckDate", DateTime.Now.ToString("yyyy-MM-dd"));
                dic.SetValue("CheckerName", CurrentUserInfo.UserName);
                dic.SetValue("ID", FormulaHelper.CreateGuid());
            }
        }
        public ActionResult List()
        {
            var engineeringInfo = this.GetEntityByID <S_I_Engineering>(Request["EngineeringInfoID"]);

            if (engineeringInfo == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("工程信息不存在!");
            }

            var sql          = string.Format(@"select Top 1  ID,Name,SerialNumber,PartyA,PartyAName from S_M_ContractInfo where ProjectInfo='{0}' and ContractState='Sign' ", engineeringInfo.ID);
            var contractInfo = EPCSQLDB.ExecuteDataTable(sql);

            ViewBag.ContractInfo = JsonHelper.ToJson(contractInfo);

            var tab          = new Tab();
            var yearCategory = CategoryFactory.GetYearCategory("BelongYear", 5, 2, false, "年份");

            yearCategory.SetDefaultItem(DateTime.Now.Year.ToString());
            yearCategory.Multi = false;
            tab.Categories.Add(yearCategory);

            var monthCategory = CategoryFactory.GetMonthCategory("BelongMonth", false, "月份");

            monthCategory.SetDefaultItem(DateTime.Now.Month.ToString());
            monthCategory.Multi = false;
            tab.Categories.Add(monthCategory);
            tab.IsDisplay = true;
            ViewBag.Tab   = tab;

            return(View());
        }
예제 #3
0
        //关闭
        public JsonResult Close()
        {
            string id = GetQueryString("ID");

            if (string.IsNullOrEmpty(id))
            {
                throw new Formula.Exceptions.BusinessValidationException("此单不存在,请确认!");
            }
            string sql = string.Format("select * from S_C_RectifySheet_RectifyProblems where ID='{0}' ", id);
            var    dt  = EPCSQLDB.ExecuteDataTable(sql);

            if (dt.Rows.Count == 0)
            {
                throw new Formula.Exceptions.BusinessValidationException("此单不存在,请确认!");
            }

            var problem = FormulaHelper.DataRowToDic(dt.Rows[0]);

            if (problem.GetValue("RectifyState") != "Rectify")
            {
                throw new Formula.Exceptions.BusinessValidationException("只有状态为已整改的单才能关闭,请确认!");
            }

            sql = string.Format("update S_C_RectifySheet_RectifyProblems set RectifyState='Closed', CloseDate=GETDATE(), CloseUserID='{1}', CloseUserName='******' where ID ='{0}' and RectifyState='Rectify' ",
                                id, CurrentUserInfo.UserID, CurrentUserInfo.UserName);
            this.EPCSQLDB.ExecuteNonQuery(sql);
            LoggerHelper.InserLogger("S_C_RectifySheet_RectifyProblems", EnumOperaType.Update, id, problem.GetValue("EngineeringInfo"), problem.GetValue("Name"), "关闭问题");
            return(Json(""));
        }
예제 #4
0
        public ActionResult Detail()
        {
            string problemID = GetQueryString("ID");
            string sql       = string.Format("select * from S_C_RectifySheet_RectifyProblems where ID='{0}' ", problemID);
            var    dt        = EPCSQLDB.ExecuteDataTable(sql);

            if (dt.Rows.Count == 0)
            {
                throw new Formula.Exceptions.BusinessValidationException("此单不存在,请确认!");
            }

            var problem = FormulaHelper.DataRowToDic(dt.Rows[0]);

            ViewBag.ID              = problem.GetValue("ID");
            ViewBag.Name            = problem.GetValue("Name");
            ViewBag.RectifyState    = problem.GetValue("RectifyState");
            ViewBag.EngineeringInfo = problem.GetValue("EngineeringInfo");
            ViewBag.ProType         = problem.GetValue("ProType");
            ViewBag.JobContent      = problem.GetValue("JobContent");
            ViewBag.CheckDate       = string.IsNullOrEmpty(problem.GetValue("CheckDate")) ? string.Empty : Convert.ToDateTime(problem.GetValue("CheckDate")).ToString("yyyy-MM-dd");
            ViewBag.RectifyDate     = string.IsNullOrEmpty(problem.GetValue("RectifyDate")) ? string.Empty : Convert.ToDateTime(problem.GetValue("RectifyDate")).ToString("yyyy-MM-dd");
            ViewBag.CloseDate       = string.IsNullOrEmpty(problem.GetValue("CloseDate")) ? string.Empty : Convert.ToDateTime(problem.GetValue("CloseDate")).ToString("yyyy-MM-dd");
            ViewBag.LiablePerson    = problem.GetValue("LiablePerson");
            ViewBag.CheckerName     = problem.GetValue("CheckerName");

            ViewBag.BeforeImprovePictrue = problem.GetValue("BeforeImprovePictrue");
            ViewBag.AfterImprovePictrue  = problem.GetValue("AfterImprovePictrue");

            ViewBag.BeforeImprovePictrueList = problem.GetValue("BeforeImprovePictrue").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            ViewBag.AfterImprovePictrueList  = problem.GetValue("AfterImprovePictrue").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            return(View());
        }
        protected override void OnFlowEnd(T_I_ManagerChange entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing)
        {
            var updateSql = string.Empty;

            if (string.IsNullOrWhiteSpace(entity.LastVersionID))
            {
                var sql = string.Format(@"select * from T_I_ManagerNominate where ID='{0}' ", entity.ManagerNominateID);
                var dt  = EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    throw new Formula.Exceptions.BusinessValidationException("此项目的项目经理信息不存在,请确认!");
                }
                var firstChange = FormulaHelper.DataRowToDic(dt.Rows[0]);
                firstChange.SetValue("NewManager", firstChange.GetValue("Manager"));
                firstChange.SetValue("NewManagerName", firstChange.GetValue("ManagerName"));
                firstChange.SetValue("ManagerNominateID", firstChange.GetValue("ID"));
                firstChange.SetValue("LastVersionID", string.Empty);
                firstChange.SetValue("FirstOne", "true");
                updateSql += firstChange.CreateInsertSql(EPCSQLDB, "T_I_ManagerChange", FormulaHelper.CreateGuid());
            }
            var managerNominate = entity.ToDic();

            managerNominate.SetValue("FlowPhase", "End");
            managerNominate.SetValue("Manager", managerNominate.GetValue("NewManager"));
            managerNominate.SetValue("ManagerName", managerNominate.GetValue("NewManagerName"));
            updateSql += managerNominate.CreateUpdateSql(EPCSQLDB, "T_I_ManagerNominate", managerNominate.GetValue("ManagerNominateID"));
            EPCSQLDB.ExecuteNonQuery(updateSql);
        }
예제 #6
0
        //删除
        public JsonResult DeleteProblem()
        {
            string id = GetQueryString("ID");

            if (string.IsNullOrEmpty(id))
            {
                throw new Formula.Exceptions.BusinessValidationException("此单不存在,请确认!");
            }
            string sql = string.Format("select * from S_C_RectifySheet_RectifyProblems where ID='{0}' ", id);
            var    dt  = EPCSQLDB.ExecuteDataTable(sql);

            if (dt.Rows.Count == 0)
            {
                throw new Formula.Exceptions.BusinessValidationException("此单不存在,请确认!");
            }
            var problem = FormulaHelper.DataRowToDic(dt.Rows[0]);

            if (problem.GetValue("RectifyState") != "Register")
            {
                throw new Formula.Exceptions.BusinessValidationException("只有待整改的单才能删除,请确认!");
            }

            sql = string.Format("delete from S_C_RectifySheet_RectifyProblems where ID ='{0}' and RectifyState='Register' ", id);
            this.EPCSQLDB.ExecuteNonQuery(sql);
            LoggerHelper.InserLogger("S_C_RectifySheet_RectifyProblems", EnumOperaType.Delete, id, problem.GetValue("EngineeringInfo"), problem.GetValue("Name"));
            return(Json(""));
        }
        protected override void BeforeSave(Dictionary<string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            if (isNew)
            {
                dic.SetValue("FlowPhase", "End");
                dic.SetValue("EngineeringInfoID", dic.GetValue("EngineeringInfo"));
                dic.SetValue("MessageCompany", string.Empty);
                dic.SetValue("MessageCompanyName", string.Empty);
                dic.SetValue("Status", "Add");
            }
            else
            {
                string sql = string.Format("select * from T_C_WorkingContact where ID='{0}' ", dic.GetValue("ID"));
                var dt = EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                    throw new Formula.Exceptions.BusinessValidationException("联系单不存在,请确认!");

                string actionType = Request["actionType"];
                if (!string.IsNullOrEmpty(actionType) && actionType == "Resolve")
                {
                    var status = dt.Rows[0]["Status"].ToString();
                    if (!string.IsNullOrEmpty(status) && status == "Receive")
                    {
                        dic.SetValue("Status", "Resolve");
                        dic.SetValue("ResolveDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
                    }
                    else
                    {
                        throw new Formula.Exceptions.BusinessValidationException("只有已接收的联系单才能处理,请确认!");
                    }
                }

            }
        }
        public JsonResult SaveList()
        {
            var engineeringInfo = this.GetEntityByID <S_I_Engineering>(Request["EngineeringInfoID"]);

            if (engineeringInfo == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("工程信息不存在!");
            }

            var list       = JsonHelper.ToList(Request["List"]);
            var makeYear   = Convert.ToInt32(Request["MakeYear"]);
            var makeMonth  = Convert.ToInt32(Request["MakeMonth"]);
            var planMonths = JsonHelper.ToList(Request["planMonths"]);

            var userInfo = FormulaHelper.GetUserInfo();
            var sql      = string.Format(@"delete from S_F_EngineeringInvestPlan where EngineeringInfo='{0}' and MakeYear={1} and MakeMonth={2}  ",
                                         engineeringInfo.ID, makeYear, makeMonth);

            foreach (var item in list)
            {
                item.SetValue("EngineeringInfo", engineeringInfo.ID);
                item.SetValue("EngineeringInfoName", engineeringInfo.Name);
                item.SetValue("MakeDate", Convert.ToDateTime(string.Format("{0}-{1}-01", makeYear, makeMonth)));
                item.SetValue("MakeYear", makeYear);
                item.SetValue("MakeMonth", makeMonth);
                item.SetValue("ChargerDept", engineeringInfo.ChargerDept);
                item.SetValue("ChargerDeptName", engineeringInfo.ChargerDeptName);
                item.SetValue("CreateUserID", userInfo.UserID);
                item.SetValue("CreateUser", userInfo.UserName);
                item.SetValue("CreateDate", DateTime.Now);
                item.SetValue("ModifyUserID", userInfo.UserID);
                item.SetValue("ModifyUser", userInfo.UserName);
                item.SetValue("ModifyDate", DateTime.Now);
                var strMonthValue = string.Empty;
                var monthValue    = 0m;
                foreach (var planMonth in planMonths)
                {
                    strMonthValue = item.GetValue(planMonth.GetValue("ColumnName"));
                    if (string.IsNullOrWhiteSpace(strMonthValue))
                    {
                        continue;
                    }
                    if (decimal.TryParse(strMonthValue, out monthValue))
                    {
                        item.SetValue("PlanDate", Convert.ToDateTime(string.Format("{0}-{1}-01", planMonth.GetValue("Year"), planMonth.GetValue("Month"))));
                        item.SetValue("PlanYear", planMonth.GetValue("Year"));
                        item.SetValue("PlanMonth", planMonth.GetValue("Month"));
                        item.SetValue("Amount", monthValue);

                        sql += item.CreateInsertSql(EPCSQLDB, "S_F_EngineeringInvestPlan", FormulaHelper.CreateGuid());
                    }
                }
            }
            EPCSQLDB.ExecuteNonQuery(sql);

            return(Json(""));
        }
예제 #9
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            string sysName = dic.GetValue("SysName");

            if (string.IsNullOrEmpty(sysName))
            {
                throw new BusinessException("账号不能为空!");
            }

            string sql          = string.Format("select Count(ID) from S_A_ParticipantUser where SysName='{0}' and ID !='{1}' ", sysName, dic.GetValue("ID"));
            var    sysNameCount = Convert.ToInt32(EPCSQLDB.ExecuteScalar(sql));

            if (sysNameCount > 0)
            {
                throw new BusinessException(string.Format("用户名【{0}】已存在", sysName));
            }

            sql = string.Format("select * from S_A_ParticipantUser where Participant='{0}' and  IsAdmin='1' ", dic.GetValue("Participant"));
            var dtParticipant = EPCSQLDB.ExecuteDataTable(sql);

            if (isNew)
            {
                if (dtParticipant.Rows.Count > 0)
                {
                    throw new BusinessException(string.Format("参建方【{0}】已存在管理员账号【{1}】", dic.GetValue("ParticipantName"), sysName));
                }

                var password = dic.GetValue("Password");
                ValidatePwd(password);
                password = FormsAuthentication.HashPasswordForStoringInConfigFile(string.Format("{0}{1}", sysName.ToLower(), password), "SHA1");
                dic.SetValue("Password", password);
            }
            else
            {
                if (dtParticipant.Rows.Count == 1)
                {
                    if (dic.GetValue("ID") != dtParticipant.Rows[0]["ID"].ToString())
                    {
                        throw new BusinessException(string.Format("参建方【{0}】只能有一个管理员账号!", dic.GetValue("ParticipantName")));
                    }
                }
                else if (dtParticipant.Rows.Count > 1)
                {
                    throw new BusinessException(string.Format("参建方【{0}】只能有一个管理员账号!", dic.GetValue("ParticipantName")));
                }

                dic.Remove("Password");
            }

            dic.SetValue("IsAdmin", "true");
        }
        public JsonResult SaveList()
        {
            var engineeringInfo = this.GetEntityByID <S_I_Engineering>(Request["EngineeringInfoID"]);

            if (engineeringInfo == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("工程信息不存在!");
            }

            var list        = JsonHelper.ToList(Request["List"]);
            var belongYear  = Convert.ToInt32(Request["BelongYear"]);
            var belongMonth = Convert.ToInt32(Request["BelongMonth"]);

            var userInfo = FormulaHelper.GetUserInfo();
            var sql      = string.Format(@"delete from S_F_EngineeringFundPlan where EngineeringInfo='{0}' and BelongYear={1} and BelongMonth={2}  ",
                                         engineeringInfo.ID, belongYear, belongMonth);
            var index = 0;

            foreach (var item in list)
            {
                item.SetValue("SortIndex", index);
                index++;
                item.SetValue("EngineeringInfo", engineeringInfo.ID);
                item.SetValue("EngineeringInfoName", engineeringInfo.Name);
                item.SetValue("BelongDate", Convert.ToDateTime(string.Format("{0}-{1}-01", belongYear, belongMonth)));
                item.SetValue("BelongYear", belongYear);
                item.SetValue("BelongMonth", belongMonth);
                item.SetValue("ChargerDept", engineeringInfo.ChargerDept);
                item.SetValue("ChargerDeptName", engineeringInfo.ChargerDeptName);
                if (string.IsNullOrWhiteSpace(item.GetValue("CreateUserID")))
                {
                    item.SetValue("CreateUserID", userInfo.UserID);
                    item.SetValue("CreateUser", userInfo.UserName);
                    item.SetValue("CreateDate", DateTime.Now);
                }
                item.SetValue("ModifyUserID", userInfo.UserID);
                item.SetValue("ModifyUser", userInfo.UserName);
                item.SetValue("ModifyDate", DateTime.Now);
                item.SetValue("MakeYear", DateTime.Now.Year);
                item.SetValue("MakeMonth", DateTime.Now.Month);
                if (string.IsNullOrWhiteSpace(item.GetValue("ID")))
                {
                    item.SetValue("ID", FormulaHelper.CreateGuid());
                }
                sql += item.CreateInsertSql(EPCSQLDB, "S_F_EngineeringFundPlan", item.GetValue("ID"));
            }
            EPCSQLDB.ExecuteNonQuery(sql);

            return(Json(""));
        }
예제 #11
0
        public JsonResult Reset()
        {
            var password = Request["pwd"];

            if (string.IsNullOrEmpty(password))
            {
                throw new BusinessException("请输入密码!");
            }
            ValidatePwd(password);

            var listData = JsonHelper.ToList(Request["ListData"]);

            if (listData.Count == 0)
            {
                throw new BusinessException("请选择要操作的行!");
            }
            var idList = listData.Select(a => a.GetValue("ParticipantUserID"));

            string sql       = string.Format("select * from S_A_ParticipantUser where ID in ('{0}') and  IsAdmin='1' ", string.Join("','", idList));
            var    dt        = EPCSQLDB.ExecuteDataTable(sql);
            string updateSql = "";
            Dictionary <string, object> operaLog = new Dictionary <string, object>();
            var userInfo = FormulaHelper.GetUserInfo();

            foreach (DataRow dr in dt.Rows)
            {
                string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(string.Format("{0}{1}", dr["SysName"].ToString().ToLower(), password), "SHA1");
                if (pwd == dr["Password"].ToString())
                {
                    throw new BusinessException(string.Format("账号【{0}】的新密码与旧密码相同,请修改!", dr["SysName"].ToString()));
                }
                updateSql += string.Format("update S_A_ParticipantUser set Password = '******' where ID = '{1}' and  IsAdmin='1' ", pwd, dr["ID"]);

                operaLog.SetValue("OperateType", EnumOperaType.Update);
                operaLog.SetValue("TableIDs", dr["ID"].ToString());
                operaLog.SetValue("Name", dr["UserName"].ToString());
                operaLog.SetValue("EngineeringInfoID", string.Empty);
                operaLog.SetValue("DBTable", "S_A_ParticipantUser");
                operaLog.SetValue("DBTableName", "S_A_ParticipantUser");
                operaLog.SetValue("Remark", "重置密码");
                operaLog.SetValue("CreateUser", userInfo.UserName);
                operaLog.SetValue("CreateUserID", userInfo.UserID);
                operaLog.SetValue("CreateDate", DateTime.Now);
                updateSql += operaLog.CreateInsertSql(EPCSQLDB, "S_A_ParticipantOperaLog", FormulaHelper.CreateGuid());
            }
            EPCSQLDB.ExecuteNonQuery(updateSql);
            return(Json(""));
        }
예제 #12
0
        protected override void AfterSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            var flowPhase = dic.GetValue("FlowPhase");

            if (string.IsNullOrWhiteSpace(flowPhase) || flowPhase == "Start")
            {
                var list       = JsonHelper.ToList(dic.GetValue("dataGrid"));
                var makeDate   = Convert.ToDateTime(dic.GetValue("MakeDate"));
                var planMonths = GetPlanMonths(makeDate);

                var sql = string.Empty;
                if (!isNew)
                {
                    sql = string.Format(@"delete from S_F_InvestPlan_Detail where S_F_InvestPlanID='{0}'  ", dic.GetValue("ID"));
                }

                foreach (var item in list)
                {
                    item.SetValue("S_F_InvestPlanID", dic.GetValue("ID"));
                    var strMonthValue = string.Empty;
                    var monthValue    = 0m;
                    foreach (var planMonth in planMonths)
                    {
                        strMonthValue = item.GetValue(planMonth.GetValue("ColumnName"));
                        if (string.IsNullOrWhiteSpace(strMonthValue))
                        {
                            continue;
                        }
                        if (decimal.TryParse(strMonthValue, out monthValue))
                        {
                            item.SetValue("PlanDate", Convert.ToDateTime(string.Format("{0}-{1}-01", planMonth.GetValue("Year"), planMonth.GetValue("Month"))));
                            item.SetValue("PlanYear", planMonth.GetValue("Year"));
                            item.SetValue("PlanMonth", planMonth.GetValue("Month"));
                            item.SetValue("Amount", monthValue);

                            sql += item.CreateInsertSql(EPCSQLDB, "S_F_InvestPlan_Detail", FormulaHelper.CreateGuid());
                        }
                    }
                }
                EPCSQLDB.ExecuteNonQuery(sql);
            }
        }
        protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID)
        {
            if (isNew)
            {
                string engineeringInfo = GetQueryString("EngineeringInfo");
                if (string.IsNullOrEmpty(engineeringInfo))
                {
                    throw new Formula.Exceptions.BusinessValidationException("请选择项目!");
                }

                string sql = string.Format("select * from S_I_Engineering where ID='{0}' ", engineeringInfo);
                var    dt  = EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    throw new Formula.Exceptions.BusinessValidationException("所选项目不存在!");
                }
                var engineering = FormulaHelper.DataRowToDic(dt.Rows[0]);

                dic.SetValue("EngineeringInfo", engineering.GetValue("ID"));
                dic.SetValue("EngineeringInfoName", engineering.GetValue("Name"));
                dic.SetValue("Code", engineering.GetValue("SerialNumber"));

                SerialNumberParam param = new SerialNumberParam()
                {
                    Code            = "TCMWorkingContact",
                    PrjCode         = "",
                    OrgCode         = "",
                    UserCode        = "",
                    CategoryCode    = "",
                    SubCategoryCode = "",
                    OrderNumCode    = ""
                };
                var serialNumber = SerialNumberHelper.GetSerialNumberString("{YY}{MM}{DD}-{NNNN}", param, "YearCode,MonthCode", true);

                dic.SetValue("SerialNumber", serialNumber);
                dic.SetValue("MainCompany", engineering.GetValue("CustomerInfo"));
                dic.SetValue("MainCompanyName", engineering.GetValue("CustomerInfoName"));
                dic.SetValue("SendCompany", CurrentUserInfo.UserOrgID);
                dic.SetValue("SendCompanyName", CurrentUserInfo.UserOrgName);
                dic.SetValue("ID", FormulaHelper.CreateGuid());
            }
        }
 protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
 {
     if (isNew)
     {
         var sql = string.Format(@"select * from T_I_ManagerChange where ManagerNominateID='{0}' ", dic.GetValue("ManagerNominateID"));
         var dt  = EPCSQLDB.ExecuteDataTable(sql);
         if (dt.Rows.Count == 0)
         {
             dic.SetValue("FirstOne", "true");
         }
         else
         {
             var list = FormulaHelper.DataTableToListDic(dt);
             if (list.Exists(m => m.GetValue("FlowPhase") != "End"))
             {
                 throw new Formula.Exceptions.BusinessValidationException("此项目经理变更单在审核中,无法变更!");
             }
         }
     }
 }
예제 #15
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            if (isNew)
            {
                dic.SetValue("RectifyState", "Register");//初始状态-- >“待整改”
                if (string.IsNullOrEmpty(dic.GetValue("OpenDate")))
                {
                    dic.SetValue("OpenDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                dic.SetValue("CreateCompanyID", string.Empty);
            }
            else
            {
                string sql = string.Format("select * from S_C_RectifySheet_RectifyProblems where ID='{0}' ", dic.GetValue("ID"));
                var    dt  = EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    throw new Formula.Exceptions.BusinessValidationException("此单不存在,请确认!");
                }
                var problem      = FormulaHelper.DataRowToDic(dt.Rows[0]);
                var currentState = problem.GetValue("RectifyState");

                string actionType = GetQueryString("actionType");
                switch (actionType)
                {
                case "Rectify":    //整改
                    if (currentState != "Register")
                    {
                        throw new Formula.Exceptions.BusinessValidationException("只有待整改的单才能整改,请确认!");
                    }

                    dic.SetValue("RectifyState", "Rectify");    //状态-->“已整改”
                    if (string.IsNullOrEmpty(dic.GetValue("RectifyDate")))
                    {
                        throw new Formula.Exceptions.BusinessValidationException("请选择【整改时间】!");
                    }

                    dic.SetValue("RectifyUserID", CurrentUserInfo.UserID);
                    dic.SetValue("RectifyUserName", CurrentUserInfo.UserName);
                    break;

                case "Close":    //关闭
                    if (currentState != "Rectify")
                    {
                        throw new Formula.Exceptions.BusinessValidationException("只有状态为已整改的单才能关闭,请确认!");
                    }

                    dic.SetValue("RectifyState", "Closed");    //状态-- >“已关闭”
                    if (string.IsNullOrEmpty(dic.GetValue("CloseDate")))
                    {
                        throw new Formula.Exceptions.BusinessValidationException("请选择【关闭时间】!");
                    }

                    dic.SetValue("CloseUserID", CurrentUserInfo.UserID);
                    dic.SetValue("CloseUserName", CurrentUserInfo.UserName);
                    break;

                case "Reject":    //重新整改
                    if (currentState != "Rectify")
                    {
                        throw new Formula.Exceptions.BusinessValidationException("只有状态为已整改的单才能设置重新整改,请确认!");
                    }

                    dic.SetValue("RectifyState", "Register");    //状态-- >“待整改”
                    dic.SetValue("RectifyDate", string.Empty);   //整改时间
                    dic.SetValue("RectifyUserID", string.Empty);
                    dic.SetValue("RectifyUserName", string.Empty);
                    break;

                default:
                    if (currentState != "Register")
                    {
                        throw new Formula.Exceptions.BusinessValidationException("只有待整改的单才能修改,请确认!");
                    }
                    break;
                }
            }
        }
예제 #16
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            if (isNew)
            {
                dic.Remove("RectifyDate");
                dic.Remove("CloseDate");
            }
            else
            {
                string sql     = string.Format("select * from S_C_RectifySheet_RectifyProblems where ID='{0}' ", dic.GetValue("ID"));
                var    problem = EPCSQLDB.ExecuteDataTable(sql);
                if (problem.Rows.Count == 0)
                {
                    throw new Formula.Exceptions.BusinessValidationException("此单不存在,请确认!");
                }

                var currentState = problem.Rows[0]["RectifyState"] == null ? string.Empty: problem.Rows[0]["RectifyState"].ToString();
                if (string.IsNullOrEmpty(currentState))
                {
                    throw new Formula.Exceptions.BusinessValidationException("此单的状态为空,请确认!");
                }

                string actionType = GetQueryString("actionType");
                switch (actionType)
                {
                case "Rectify":    //整改
                    if (currentState != "Register")
                    {
                        throw new Formula.Exceptions.BusinessValidationException("此单已处理,不能重复处理,请确认!");
                    }

                    dic.SetValue("RectifyState", "Rectify");    //状态-->“已整改”
                    if (string.IsNullOrEmpty(dic.GetValue("RectifyDate")))
                    {
                        throw new Formula.Exceptions.BusinessValidationException("请选择【整改时间】!");
                    }
                    break;

                case "Close":    //关闭
                    if (currentState != "Rectify")
                    {
                        throw new Formula.Exceptions.BusinessValidationException("此单已关闭,不能重复关闭,请确认!");
                    }

                    dic.SetValue("RectifyState", "Closed");    //状态-- >“已关闭”
                    if (string.IsNullOrEmpty(dic.GetValue("CloseDate")))
                    {
                        throw new Formula.Exceptions.BusinessValidationException("请选择【关闭时间】!");
                    }
                    break;

                case "Reject":    //重新整改
                    if (currentState != "Rectify")
                    {
                        throw new Formula.Exceptions.BusinessValidationException("此单已关闭,不能重复关闭,请确认!");
                    }

                    dic.SetValue("RectifyState", "Register");    //状态-- >“待整改”
                    dic.SetValue("RectifyDate", string.Empty);   //整改时间
                    break;
                }
            }
        }