public int luuDeChuan(DECHUAN de)
 {
     try
     {
         object[] valparams =
         {
             new SqlParameter("@tende",        de.TenDeChuan),
             new SqlParameter("@VARsubjectID", de.MaMon),
             new SqlParameter("@macathi",      de.MaCaThi),
             new SqlParameter("@sodehoanvi",   de.SoDeHoanVi),
             new SqlParameter("@thoigianthi",  de.ThoiGian),
         };
         int res = db.Database.ExecuteSqlCommand("setDECHUAN2 @tende, @VARsubjectID, @macathi, @sodehoanvi, @thoigianthi", valparams);
         db.SaveChanges();
         return(res);
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         return(-1);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return(-1);
     }
 }
示例#2
0
 public bool AddKHOATHI(KHOATHI KHOATHI)
 {
     try
     {
         dataContext.KHOATHIs.Add(KHOATHI);
         dataContext.SaveChanges();
     }
     catch (DbUpdateException e)
     {
         Debug.WriteLine(e.ToString());
         return(false);
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         return(false);
     }
     return(true);
 }
示例#3
0
 public int AddUser(User user)
 {
     try
     {
         db.Users.Add(user);
         db.SaveChanges();
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         throw;
     }
     return(user.ID);
 }
示例#4
0
 public int AddSubject(Subject PQ)
 {
     try
     {
         PQ.SubjectID = Guid.NewGuid();
         db.Subjects.Add(PQ);
         db.SaveChanges();
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         throw;
     }
     return(PQ.idSub);
 }
 public int AddTHISINH(THISINH THISINH)
 {
     try
     {
         dataContext.THISINHs.Add(THISINH);
         dataContext.SaveChanges();
     }
     catch (DbUpdateException e)
     {
         Debug.WriteLine(e.ToString());
         throw;
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
     return(THISINH.ID);
 }
 //public List<Question> getListQuestionIDModule(int idmodule)
 //{
 //    Guid idclass = new QClassDAO().GetListAll().Where(i => i.ClassID == idmodule).Select(p => p.ClassID).SingleOrDefault();
 //    List<Question> x = db.Questions.Where(o => o.ClassID == idclass).ToList();
 //    return x;
 //}
 public bool AddQuestion(Question PQ)
 {
     try
     {
         db.Questions.Add(PQ);
         db.SaveChanges();
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         return(false);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return(false);
     }
     return(true);
 }
示例#7
0
        public async Task <ApiJsonResult> Create(Order data)
        {
            var result   = new ApiJsonResult();
            var objOrder = new Order
            {
                Id           = data.Id,
                Address      = data.Address,
                CustomerName = data.CustomerName,
                Note         = data.Note,
                PhoneNumber  = data.PhoneNumber,
                OrderCode    = Constants.GenerateCode(),
                Price        = data.Price,
                TransportId  = 1,
                CreatedDate  = DateTime.Now
            };

            _dbContext.Order.Add(objOrder);
            _dbContext.SaveChanges();
            var test = objOrder.Id;

            foreach (var item in data.OrderItem)
            {
                var objOrderItem = new OrderItem
                {
                    ProductId = item.ProductId,
                    Number    = item.Number,
                    OrderId   = objOrder.Id
                };
                _dbContext.OrderItem.Add(objOrderItem);
            }
            _dbContext.SaveChanges();
            return(result);
        }
示例#8
0
 private void CreateContactDetail(WebClientDbContext context)
 {
     if (context.ContactDetails.Count() == 0)
     {
         try
         {
             var contactDetail = new WebClient.Model.Models.ContactDetail()
             {
                 Name    = "Trường đại học Tiền Giang",
                 Address = "119 Ấp Bắc - Phường 05 - Thành phố Mỹ Tho - Tỉnh Tiền Giang.",
                 Email   = "*****@*****.**",
                 Lat     = 37.0625,
                 Lng     = 95.677068,
                 Phone   = "0273 3 872 624 - 0273 6 250 200",
                 Website = "https://tgu.edu.vn",
                 Other   = "",
                 Status  = true
             };
             context.ContactDetails.Add(contactDetail);
             context.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             foreach (var eve in ex.EntityValidationErrors)
             {
                 Trace.WriteLine($"Entity of type \"{eve.Entry.Entity.GetType().Name}\" in state \"{eve.Entry.State}\" has the following validation error.");
                 foreach (var ve in eve.ValidationErrors)
                 {
                     Trace.WriteLine($"- Property: \"{ve.PropertyName}\", Error: \"{ve.ErrorMessage}\"");
                 }
             }
         }
     }
 }
示例#9
0
    //private void CreateSlide(WebClientDbContext context)
    //{
    //    if (context.SLIDEs.Count() == 0)
    //    {
    //        List<SLIDE> listSlide = new List<SLIDE>()
    //        {
    //            new SLIDE() {
    //                Name ="Slide 1",
    //                DisplayOrder =1,
    //                Status =true,
    //                Url ="#",
    //                Image ="/Assets/client/images/bag.jpg",
    //                Content =@"	<h2>FLAT 50% 0FF</h2>
    //                        <label>FOR ALL PURCHASE <b>VALUE</b></label>
    //                        <p>Lorem ipsum dolor sit amet, consectetur
    //                    adipisicing elit, sed do eiusmod tempor incididunt ut labore et </ p >
    //                <span class=""on-get"">GET NOW</span>" },
    //            new SLIDE() {
    //                Name ="Slide 2",
    //                DisplayOrder =2,
    //                Status =true,
    //                Url ="#",
    //                Image ="/Assets/client/images/bag1.jpg",
    //            Content=@"<h2>FLAT 50% 0FF</h2>
    //                        <label>FOR ALL PURCHASE <b>VALUE</b></label>

    //                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et </ p >

    //                        <span class=""on-get"">GET NOW</span>"},
    //        };
    //        context.SLIDEs.AddRange(listSlide);
    //        context.SaveChanges();
    //    }
    //}

    private void CreatePage(WebClientDbContext context)
    {
        if (context.PAGEs.Count() == 0)
        {
            try
            {
                var page = new PAGE()
                {
                    Name     = "Giới thiệu",
                    Alias    = "gioi-thieu",
                    PContent = @"Trường Đại học Tiền Giang mong muốn được hợp tác với các tổ chức, cá nhân trong và ngoài nước
về giáo dục, đào tạo, nghiên cứu, ứng dụng và chuyển giao khoa học - công nghệ.",
                    Status   = true
                };
                context.PAGEs.Add(page);
                context.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var eve in ex.EntityValidationErrors)
                {
                    Trace.WriteLine($"Entity of type \"{eve.Entry.Entity.GetType().Name}\" in state \"{eve.Entry.State}\" has the following validation error.");
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Trace.WriteLine($"- Property: \"{ve.PropertyName}\", Error: \"{ve.ErrorMessage}\"");
                    }
                }
            }
        }
    }
示例#10
0
 public bool AddQClass(QClass PQ)
 {
     try
     {
         if (PQ.ChuThich == null)
         {
             PQ.ChuThich = "Module mới";
         }
         object[] valparams =
         {
             new SqlParameter("@ClassID",   PQ.ClassID),
             new SqlParameter("@SubjectID", PQ.SubjectID),
             new SqlParameter("@Descr",     PQ.Descr),
             new SqlParameter("@ClassNbr",  PQ.ClassNbr),
             new SqlParameter("@ChuThich",  PQ.ChuThich),
             new SqlParameter("@TrangThai", PQ.TrangThai)
         };
         int res = db.Database.ExecuteSqlCommand("Insert_module @ClassID, @SubjectID, @ClassNbr, @Descr, @ChuThich, @TrangThai", valparams);
         db.SaveChanges();
         if (res == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         return(false);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return(false);
     }
 }
示例#11
0
 private void CreateFooter(WebClientDbContext context)
 {
     if (context.FOOTERs.Count(x => x.ID == CommonConstants.DefaultFooterId) == 0)
     {
         string content = "Footer";
         context.FOOTERs.Add(new FOOTER()
         {
             ID      = CommonConstants.DefaultFooterId,
             Content = content
         });
         context.SaveChanges();
     }
 }