示例#1
0
        public static int Add(Order order)
        {
            try
            {
                using (var db = new MTSEntities())
                {
                    var item = new Order
                    {
                        Cila        = order.Cila,
                        CustomerId  = order.CustomerId,
                        Description = order.Description,
                        FinishDate  = order.FinishDate,
                        KaporaPrice = order.KaporaPrice,

                        KartelaId      = order.KartelaId,
                        KartelaModelId = order.KartelaModelId,
                        ModelId        = order.ModelId,

                        ProductId  = order.ProductId,
                        StartDate  = order.StartDate,
                        TotalPrice = order.TotalPrice,

                        ProductId2      = order.ProductId2,
                        ModelId2        = order.ModelId2,
                        KartelaId2      = order.KartelaId2,
                        KartelaModelId2 = order.KartelaModelId2,
                        Cila2           = order.Cila2,
                        Description2    = order.Description2,

                        ProductId3      = order.ProductId3,
                        ModelId3        = order.ModelId3,
                        KartelaId3      = order.KartelaId3,
                        KartelaModelId3 = order.KartelaModelId3,
                        Cila3           = order.Cila3,
                        Description3    = order.Description3,

                        ProductId4      = order.ProductId4,
                        ModelId4        = order.ModelId4,
                        KartelaId4      = order.KartelaId4,
                        KartelaModelId4 = order.KartelaModelId4,
                        Cila4           = order.Cila4,
                        Description4    = order.Description4,

                        KaporaType  = order.KaporaType,
                        PaymentType = order.PaymentType,
                    };
                    db.Order.Add(item);
                    db.SaveChanges();
                    return(1);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
示例#2
0
        public static int Update(Order order)
        {
            try
            {
                using (var db = new MTSEntities())
                {
                    Order temp = db.Order.SingleOrDefault(x => x.Id == order.Id);
                    temp.FinishDate = order.FinishDate;
                    temp.StartDate  = order.StartDate;

                    temp.ProductId  = order.ProductId;
                    temp.ProductId2 = order.ProductId2;
                    temp.ProductId3 = order.ProductId3;
                    temp.ProductId4 = order.ProductId4;

                    temp.ModelId  = order.ModelId;
                    temp.ModelId2 = order.ModelId2;
                    temp.ModelId3 = order.ModelId3;
                    temp.ModelId4 = order.ModelId4;

                    temp.KartelaModelId  = order.KartelaModelId;
                    temp.KartelaModelId2 = order.KartelaModelId2;
                    temp.KartelaModelId3 = order.KartelaModelId3;
                    temp.KartelaModelId4 = order.KartelaModelId4;

                    temp.KartelaId  = order.KartelaId;
                    temp.KartelaId2 = order.KartelaId2;
                    temp.KartelaId3 = order.KartelaId3;
                    temp.KartelaId4 = order.KartelaId4;

                    temp.Description  = order.Description;
                    temp.Description2 = order.Description2;
                    temp.Description3 = order.Description3;
                    temp.Description4 = order.Description4;

                    temp.CustomerId = order.CustomerId;

                    temp.Cila  = order.Cila;
                    temp.Cila2 = order.Cila2;
                    temp.Cila3 = order.Cila3;
                    temp.Cila4 = order.Cila4;

                    temp.TotalPrice = order.TotalPrice;
                    db.SaveChanges();
                    return(1);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
示例#3
0
 public static int Update(Kartela kartela)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var item = db.Kartela.SingleOrDefault(x => x.Id == kartela.Id);
             item.KartelaName = kartela.KartelaName;
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#4
0
 public static int Update(Product product)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             Product temp = db.Product.SingleOrDefault(x => x.Id == product.Id);
             temp.ProductName = product.ProductName;
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#5
0
 public static int Update(tblModel model)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             tblModel temp = db.tblModel.SingleOrDefault(x => x.Id == model.Id);
             temp.ModelName = model.ModelName;
             temp.ProductId = model.ProductId;
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#6
0
 public static int Update(User user)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             User temp = db.User.SingleOrDefault(x => x.Id == user.Id);
             temp.NameSurname = user.NameSurname;
             temp.Password    = user.Password;
             temp.Email       = user.Email;
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#7
0
 public static int Update(KartelaProduct kp)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             KartelaProduct temp = db.KartelaProduct.SingleOrDefault(x => x.Id == kp.Id);
             temp.KartelaId   = kp.KartelaId;
             temp.ProductName = kp.ProductName;
             temp.ProductCode = kp.ProductCode;
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#8
0
 public static int Add(Kartela kartela)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var item = new Kartela
             {
                 KartelaName = kartela.KartelaName
             };
             db.Kartela.Add(item);
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#9
0
 public static int Add(Product product)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var temp = new Product
             {
                 ProductName = product.ProductName
             };
             db.Product.Add(temp);
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#10
0
 public static int Add(tblModel model)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var temp = new tblModel
             {
                 ProductId = model.ProductId,
                 ModelName = model.ModelName
             };
             db.tblModel.Add(temp);
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#11
0
 public static int Add(User user)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var temp = new User
             {
                 Email       = user.Email,
                 NameSurname = user.NameSurname,
                 Password    = user.Password
             };
             db.User.Add(temp);
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#12
0
 public static int Add(KartelaProduct kp)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var item = new KartelaProduct
             {
                 KartelaId   = kp.KartelaId,
                 ProductName = kp.ProductName,
                 ProductCode = kp.ProductCode
             };
             db.KartelaProduct.Add(item);
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#13
0
 public static int Delete(int Id)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var item = db.Kartela.SingleOrDefault(x => x.Id == Id);
             if (item != null)
             {
                 db.Kartela.Remove(item);
                 db.SaveChanges();
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#14
0
 public static int Delete(int Id)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var tempRemove = db.tblModel.SingleOrDefault(x => x.Id == Id);
             if (tempRemove != null)
             {
                 db.tblModel.Remove(tempRemove);
                 db.SaveChanges();
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#15
0
 public static int Delete(int Id)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var removeTo = db.Order.SingleOrDefault(x => x.Id == Id);
             if (removeTo != null)
             {
                 db.Order.Remove(removeTo);
                 db.SaveChanges();
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
示例#16
0
 public static int Add(Customer customer)
 {
     try
     {
         using (var db = new MTSEntities())
         {
             var item = new Customer
             {
                 NameSurname = customer.NameSurname,
                 Adress      = customer.Adress,
                 Email       = customer.Email,
                 Phone1      = customer.Phone1,
                 Phone2      = customer.Phone2
             };
             db.Customer.Add(item);
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }