Exemplo n.º 1
0
        public int UpdateResult(MBO_Result res, int role)
        {
            if (role == 2)
            {
                return(DBManager <MBO_Result> .Execute(StoredProcedure.UPDATE_RESULT, new
                {
                    ID = res.ID,
                    MBO_SELF_SCORE = res.MBO_SELF_SCORE,
                    MBO_M1_SCORE = res.MBO_M1_SCORE,
                    MBO_M2_SCORE = res.MBO_M2_SCORE,
                    MBO_FINAL_SCORE = res.MBO_FINAL_SCORE,
                    CAP_M1 = res.CAP_M1,
                    CAP_M2 = res.CAP_M2,
                    CAP_FINAL_SCORE = res.CAP_FINAL_SCORE,
                    TOTAL_SCORE = res.TOTAL_SCORE,
                    GRADE = res.GRADE,
                    M1_FINAL_SCORE = res.M1_FINAL_SCORE,
                    M1_GRADE = res.M1_GRADE
                }
                                                       ));
            }
            if (role == 1)
            {
                return(DBManager <MBO_Result> .Execute(StoredProcedure.UPDATE_RESULT_M1, new
                {
                    ID = res.ID,

                    MBO_M1_SCORE = res.MBO_M1_SCORE,
                    M1_FINAL_SCORE = res.M1_FINAL_SCORE,
                    M1_GRADE = @res.M1_GRADE,
                    CAP_M1 = res.CAP_M1
                }
                                                       ));
            }
            return(DBManager <MBO_Result> .Execute(StoredProcedure.UPDATE_RESULT_SELF, new
            {
                ID = res.ID,
                MBO_SELF_SCORE = res.MBO_SELF_SCORE
            }
                                                   ));
        }
Exemplo n.º 2
0
        public int SavePlan(string EVA_TIME, string EMP_ID, int RESULT_ID, List <MBO_Plan> PLANS, string DEL, List <MBO_Plan> EDIT_PLANS)
        {
            foreach (var p in PLANS)
            {
                if (p.RESULT != null)
                {
                    p.RESULT = p.RESULT.Replace("\r\n", "<br/>");
                }
                p.ACTION_PLAN = p.ACTION_PLAN.Replace("\r\n", "<br/>");
                p.CONT        = p.CONT.Replace("\r\n", "<br/>");
                p.TARGET      = p.TARGET.Replace("\r\n", "<br/>");
            }
            foreach (var p in EDIT_PLANS)
            {
                if (p.RESULT != null)
                {
                    p.RESULT = p.RESULT.Replace("\r\n", "<br/>");
                }
                p.ACTION_PLAN = p.ACTION_PLAN.Replace("\r\n", "<br/>");
                p.CONT        = p.CONT.Replace("\r\n", "<br/>");
                p.TARGET      = p.TARGET.Replace("\r\n", "<br/>");
            }
            int result = 0;

            MBO_Result ExistId = DBManager <MBO_Result> .ExecuteReader(StoredProcedure.GET_MBO_RESULTID, new { EMP_ID = EMP_ID, PERIOD_ID = EVA_TIME }).FirstOrDefault();

            if (ExistId == null)
            {
                int t = DBManager <MBO_Result> .Execute(StoredProcedure.INSERT_MBO_RESULT, new { EMP_ID = EMP_ID, PERIOD_ID = EVA_TIME });

                if (t > 0)
                {
                    MBO_Result NewId = DBManager <MBO_Result> .ExecuteReader(StoredProcedure.GET_MBO_RESULTID, new { EMP_ID = EMP_ID, PERIOD_ID = EVA_TIME }).FirstOrDefault();

                    foreach (var plan in PLANS)
                    {
                        if (NewId != null)
                        {
                            result = DBManager <MBO_Plan> .Execute(StoredProcedure.INSERT_MBO_PLAN, new
                            {
                                RESULT_ID   = NewId.ID,
                                CONT        = plan.CONT,
                                ACTION_PLAN = plan.ACTION_PLAN,
                                TARGET      = plan.TARGET,
                                WEIGHT      = plan.WEIGHT,
                                LVL         = plan.LVL
                            });
                        }
                    }
                }
            }
            else
            {
                foreach (var plan in PLANS)
                {
                    result = DBManager <MBO_Plan> .Execute(StoredProcedure.INSERT_MBO_PLAN, new
                    {
                        RESULT_ID   = ExistId.ID,
                        CONT        = plan.CONT,
                        ACTION_PLAN = plan.ACTION_PLAN,
                        TARGET      = plan.TARGET,
                        WEIGHT      = plan.WEIGHT,
                        LVL         = plan.LVL
                    });
                }
                foreach (var plan in EDIT_PLANS)
                {
                    result = DBManager <MBO_Plan> .Execute(StoredProcedure.UPDATE_PLAN_REGISTER, new
                    {
                        ID          = plan.ID,
                        CONT        = plan.CONT,
                        ACTION_PLAN = plan.ACTION_PLAN,
                        TARGET      = plan.TARGET,
                        WEIGHT      = plan.WEIGHT,
                        LVL         = plan.LVL
                    });
                }
                if (!string.IsNullOrWhiteSpace(DEL))
                {
                    string[] ids = DEL.Split(',');
                    foreach (var id in ids)
                    {
                        int planId = Convert.ToInt32(id);
                        result = DBManager <MBO_Plan> .Execute(StoredProcedure.DELETE_MBO_PLAN, new { ID = planId });
                    }
                }
            }
            return(result);
        }