示例#1
0
        public void CreateVO(PCMHBSViewModel vm, int Intake_Assessment_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_HB_VistationOutcome newVO = new PCM_HB_VistationOutcome();

                    newVO.Intake_Assessment_Id = Intake_Assessment_Id;
                    newVO.Conatact_Number      = vm.Conatact_Number;
                    newVO.Process_Notes        = vm.Process_Notes;
                    newVO.Visitaion_Register   = vm.Visitaion_Register;
                    newVO.Compliance_Id        = vm.Compliance_Id;

                    db.PCM_HB_VistationOutcome.Add(newVO);
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);

                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
            }
        }
示例#2
0
        public PCMHBSViewModel GetVisitationOutcometById(int VisitoutId)
        {
            PCMHBSViewModel vm = new PCMHBSViewModel();

            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_HB_VistationOutcome act = db.PCM_HB_VistationOutcome.Find(VisitoutId);
                    if (act != null)
                    {
                        vm.HB_Visitaion_Outcome_Id = act.HB_Visitaion_Outcome_Id;
                        vm.Intake_Assessment_Id    = act.Intake_Assessment_Id;
                        vm.Conatact_Number         = act.Conatact_Number;
                        vm.Process_Notes           = act.Process_Notes;
                        vm.Visitaion_Register      = act.Visitaion_Register;
                        vm.Compliance_Id           = act.Compliance_Id;

                        if (act.Compliance_Id > 0)
                        {
                            vm.Compliance = db.apl_PCM_Compliance.Find(act.Compliance_Id).Description;
                        }
                    }
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }

                return(vm);
            }
        }
示例#3
0
        public PCMHBSViewModel EditVO(int HB_Visitaion_Outcome_Id)
        {
            PCMHBSViewModel vm = new PCMHBSViewModel();

            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    int?id = (from c in db.PCM_HB_VistationOutcome
                              where (c.HB_Visitaion_Outcome_Id == HB_Visitaion_Outcome_Id)
                              select c.HB_Visitaion_Outcome_Id).FirstOrDefault();

                    PCM_HB_VistationOutcome s = db.PCM_HB_VistationOutcome.Find(id);
                    if (s != null)
                    {
                        vm.HB_Visitaion_Outcome_Id = db.PCM_HB_VistationOutcome.Find(s.HB_Visitaion_Outcome_Id).HB_Visitaion_Outcome_Id;
                        vm.Intake_Assessment_Id    = s.Intake_Assessment_Id;
                        vm.Conatact_Number         = s.Conatact_Number;
                        vm.Process_Notes           = s.Process_Notes;
                        vm.Visitaion_Register      = s.Visitaion_Register;
                        vm.Compliance_Id           = s.Compliance_Id;

                        db.SaveChanges();
                    }
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
            }
            return(vm);
        }
示例#4
0
        public void UpdateVO(PCMHBSViewModel vm, int id, int Intake_Assessment_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_HB_VistationOutcome cc = db.PCM_HB_VistationOutcome.Find(id);
                    cc.Intake_Assessment_Id = Intake_Assessment_Id;
                    cc.Conatact_Number      = vm.Conatact_Number;
                    cc.Process_Notes        = vm.Process_Notes;
                    cc.Visitaion_Register   = vm.Visitaion_Register;
                    cc.Compliance_Id        = vm.Compliance_Id;

                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#5
0
        public void UpdateHBS(PCMHBSViewModel vm, int userId, int HomeBasedSupervision_Id, int assID)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_HB_Supervision newCC = db.PCM_HB_Supervision.Find(HomeBasedSupervision_Id);

                    newCC.HomeBasedSupervision_Id = HomeBasedSupervision_Id;
                    newCC.Conditions_Id           = vm.Conditions_Id;
                    newCC.Visitation_Period       = vm.Visitation_Period;
                    newCC.Number_of_Visit         = vm.Number_of_Visit;
                    newCC.Placement_Date          = vm.Placement_Date;
                    newCC.HBS_Supervisor_Id       = vm.HBS_Supervisor_Id;
                    newCC.Placement_Confirmed     = vm.Placement_Confirmed;

                    db.SaveChanges();

                    PCM_HB_VistationOutcome exist = db.PCM_HB_VistationOutcome.Where(x => x.HomeBasedSupervision_Id == HomeBasedSupervision_Id).SingleOrDefault();
                    if (exist == null)
                    {
                        PCM_HB_VistationOutcome newHB = new PCM_HB_VistationOutcome();

                        newHB.Intake_Assessment_Id    = assID;
                        newHB.HomeBasedSupervision_Id = vm.HomeBasedSupervision_Id;


                        db.PCM_HB_VistationOutcome.Add(newHB);
                        db.SaveChanges();
                    }

                    PCM_HB_CourtOutcome exist2 = db.PCM_HB_CourtOutcome.Where(x => x.HomeBasedSupervision_Id == HomeBasedSupervision_Id).SingleOrDefault();
                    if (exist2 == null)
                    {
                        PCM_HB_CourtOutcome newHB = new PCM_HB_CourtOutcome();

                        newHB.Intake_Assessment_Id    = assID;
                        newHB.HomeBasedSupervision_Id = vm.HomeBasedSupervision_Id;


                        db.PCM_HB_CourtOutcome.Add(newHB);
                        db.SaveChanges();
                    }
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
            }
        }