Beispiel #1
0
        //public StudentFixedDiscount SelectByIDs(int companyID)
        //{
        //    SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB();
        //    return db.Branch.ToList().Where(s => s.CompanyCode == companyID).ToList();
        //}

        public void save(StudentFixedDiscount StudentFixedDiscount, string userId, bool isNew)
        {
            try
            {
                using (var context = new SmsMisDB())
                {
                    var entry = context.Entry(StudentFixedDiscount);
                    if (entry != null)
                    {
                        StudentFixedDiscount.AddDateTime = DateTime.Now;
                        StudentFixedDiscount.AddByUserId = userId;

                        if (isNew)
                        {
                            entry.State = System.Data.Entity.EntityState.Added;
                        }
                        else
                        {
                            entry.State = System.Data.Entity.EntityState.Modified;
                        }

                        context.SaveChanges();
                    }
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                //throw ex;
            }
            catch (Exception ex)
            {
                // throw ex;
            }
        }
Beispiel #2
0
 public ContentResult deleteStudentFixedDiscount(StudentFixedDiscount StudentFixedDiscount)
 {
     try
     {
         new hdlStudentFixedDiscount().delete(StudentFixedDiscount);
     }
     catch (Exception ex)
     {
         Response.StatusCode = 500;
         Content(JsonConvert.SerializeObject(new { error = ex.Message }));
     }
     return(getAllStudentFixedDiscount(StudentFixedDiscount.CompanyCode));
 }
Beispiel #3
0
 public ContentResult saveStudentFixedDiscount(StudentFixedDiscount StudentFixedDiscount, bool isNew)
 {
     try
     {
         new hdlStudentFixedDiscount().save(StudentFixedDiscount, Convert.ToString(Session["User"]), isNew);
     }
     catch (Exception ex)
     {
         Response.StatusCode = 500;
         Content(JsonConvert.SerializeObject(new { error = ex.Message }));
     }
     return(getAllStudentFixedDiscount(StudentFixedDiscount.CompanyCode));
 }
Beispiel #4
0
 public void delete(StudentFixedDiscount StudentFixedDiscount)
 {
     try
     {
         var context = new SmsMisDB();
         context.StudentFixedDiscount.Attach(StudentFixedDiscount);
         var entry = context.Entry(StudentFixedDiscount);
         if (entry != null)
         {
             entry.State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException ex)
     {
         //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex);
         throw ex;
     }
     catch (Exception ex)
     {
         //throw SmsMis.Models.Console.Common.ExceptionTranslater.translate(ex);
         throw ex;
     }
 }