Esempio n. 1
0
        //Method for Updating Employee record
        //public int Update(PCMPretrailViewModel pVM)
        //{
        //    int i;
        //    using (SqlConnection con = new SqlConnection(cs))
        //    {
        //        con.Open();
        //        SqlCommand com = new SqlCommand("InsertUpdateEmployee", con);
        //        com.CommandType = CommandType.StoredProcedure;
        //        com.Parameters.AddWithValue("@PCM_Pretrial_Id", pVM.PCM_Pretrial_Id);
        //        com.Parameters.AddWithValue("@PCM_Case_Id", pVM.PCM_Case_Id);
        //        com.Parameters.AddWithValue("@Client_Id", pVM.Client_Id);
        //        com.Parameters.AddWithValue("@PCM_Preliminary_Id", pVM.PCM_Preliminary_Id);
        //        com.Parameters.AddWithValue("@PCM_Pretrial_Date", pVM.PCM_Pretrial_Date);
        //        com.Parameters.AddWithValue("@PCM_Court_Outcome_Id", pVM.PCM_Court_Outcome_Id);
        //        com.Parameters.AddWithValue("@PCM_Offence_Id", pVM.PCM_Offence_Id);
        //        com.Parameters.AddWithValue("@PCM_Recommendation_Id", pVM.PCM_Recommendation_Id);
        //        com.Parameters.AddWithValue("@PCM_Commemts", pVM.PCM_Commemts);
        //        com.Parameters.AddWithValue("@Created_By", pVM.Created_By);
        //        com.Parameters.AddWithValue("@Date_Created", pVM.Date_Created);
        //        com.Parameters.AddWithValue("@Modified_By", pVM.Modified_By);
        //        com.Parameters.AddWithValue("@Date_Modified", pVM.Date_Modified);
        //        com.Parameters.AddWithValue("@Action", "Update");
        //        i = com.ExecuteNonQuery();
        //    }
        //    return i;
        //}

        public void update(PCMPretrailViewModel vm, int PCM_Pretrial_Id, int Intake_Assessment_Id, int userId)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Pretrial_Details pp = db.PCM_Pretrial_Details.Find(PCM_Pretrial_Id);
                    pp.Intake_Assessment_Id = Intake_Assessment_Id;
                    pp.Educational_Summary  = vm.Educational_Summary;
                    pp.Offence_Sammary      = vm.Offence_Sammary;
                    pp.Victims_Sammary      = vm.Victims_Sammary;
                    pp.Modified_By          = userId;
                    pp.Date_Modified        = DateTime.Now;

                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Esempio n. 2
0
        //public PCMPretrailViewModel Update(int PCM_Pretrial_Id)
        //{
        //    PCMPretrailViewModel vm = new PCMPretrailViewModel();
        //    using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
        //    {
        //        try
        //        {
        //            //int? id = (from c in db.PCM_Pretrial_Details
        //            //           where (c.PCM_Pretrial_Id == PCM_Pretrial_Id)
        //            //           select c.PCM_Pretrial_Id).FirstOrDefault();

        //            PCM_Pretrial_Details p = db.PCM_Pretrial_Details.Find(id);
        //            if(p != null)
        //            {
        //                vm.PCM_Pretrial_Id = db.PCM_Pretrial_Details.Find(p.PCM_Pretrial_Id).PCM_Pretrial_Id;
        //                vm.PCM_Case_Id = p.PCM_Case_Id;
        //                vm.PCM_Pretrial_Date = p.PCM_Pretrial_Date;
        //                vm.PCM_Court_Outcome_Id = p.PCM_Court_Outcome_Id;
        //                vm.PCM_Commemts = vm.PCM_Commemts;
        //                //vm.Created_By = DateTime.Now;
        //                vm.Date_Created = DateTime.Now; ;
        //                vm.Modified_By = p.Modified_By;
        //                vm.Date_Modified = DateTime.Now;

        //                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;
        //}

        public void View(PCMPretrailViewModel vm, int userId, int PCM_Pretrial_Id)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Pretrial_Details p = db.PCM_Pretrial_Details.Find(PCM_Pretrial_Id);

                    vm.PCM_Case_Id          = p.PCM_Case_Id;
                    vm.PCM_Pretrial_Date    = p.PCM_Pretrial_Date;
                    vm.PCM_Court_Outcome_Id = p.PCM_Court_Outcome_Id;
                    vm.PCM_Commemts         = vm.PCM_Commemts;
                    vm.Date_Created         = DateTime.Now;;
                    vm.Modified_By          = p.Modified_By;
                    vm.Date_Modified        = DateTime.Now;

                    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;
                }
            }
        }
Esempio n. 3
0
        public void Add(PCMPretrailViewModel pVM, int Intake_Assessment_Id, int userId)
        {
            using (SDIIS_DatabaseEntities db = new SDIIS_DatabaseEntities())
            {
                try
                {
                    PCM_Pretrial_Details newPetrail = new PCM_Pretrial_Details();
                    newPetrail.Intake_Assessment_Id = Intake_Assessment_Id;
                    newPetrail.Educational_Summary  = pVM.Educational_Summary;
                    newPetrail.Offence_Sammary      = pVM.Offence_Sammary;
                    newPetrail.Victims_Sammary      = pVM.Victims_Sammary;
                    newPetrail.Created_By           = userId;
                    newPetrail.Date_Created         = DateTime.Now;

                    db.PCM_Pretrial_Details.Add(newPetrail);
                    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;
                }
            }
        }