コード例 #1
0
ファイル: UserInfoModel.cs プロジェクト: SaifAsad/garager
 public UserInformation GetUserInformation(string guId)
 {
     GarageDBEntities db = new GarageDBEntities();
     var info = (from x in db.UserInformations
                 where x.GUID == guId
                 select x).FirstOrDefault();
     return info;
 }
コード例 #2
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
 //return a list of cart objects of the current user
 public List<Cart> GetOrdersInCart(string userId)
 {
     GarageDBEntities db = new GarageDBEntities();
     List<Cart> orders = (from x in db.Carts
                          where x.ClientID == userId
                          && x.IsInCart
                          orderby x.DatePurchased descending
                          select x).ToList();
     return orders;
 }
コード例 #3
0
ファイル: ProductModel.cs プロジェクト: SaifAsad/garager
 public Product GetProduct(int id)
 {
     try
     {
         using (GarageDBEntities db = new GarageDBEntities())
         {
             Product product = db.Products.Find(id);
             return product;
         }
     }
     catch (Exception ex)
     {
         return null;
     }
 }
コード例 #4
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string InsertProductType(ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.ProductTypes.Add(productType);
            db.SaveChanges();

            return productType.Name + "was succesfully inserted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #5
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    //mark all the products in the shopping cart as paid
    //as soon as the user has completed the transaction
    public void MarkOrdersAsPaid(List<Cart> carts)
    {
        GarageDBEntities db = new GarageDBEntities();

        if (carts != null)
        {
            foreach (Cart cart in carts)
            {
                Cart oldCart = db.Carts.Find(cart.id);
                oldCart.DatePurchased = DateTime.Now;
                oldCart.IsInCart = false;
            }
            db.SaveChanges();
        }
    }
コード例 #6
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    public string InsertCart(Cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return "Order was succesfully inserted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #7
0
ファイル: ProductModel.cs プロジェクト: SaifAsad/garager
 public List<Product> GetAllProducts()
 {
     try
     {
         using (GarageDBEntities db = new GarageDBEntities())
         {
             List<Product> products = (from x in db.Products
                             select x).ToList();
             return products;
         }
     }
     catch (Exception ex)
     {
         return null;
     }
 }
コード例 #8
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    //return the total number of items in the shopping cart
    public int GetAmountOfOrders(string userId)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            int amount = (from x in db.Carts
                          where x.ClientID == userId
                          && x.IsInCart
                          select x.Amount).Sum();

            return amount;
        }
        catch
        {
            return 0;
        }
    }
コード例 #9
0
ファイル: ProductModel.cs プロジェクト: SaifAsad/garager
 public List<Product> GetProductsByType(int typeId)
 {
     try
     {
         using (GarageDBEntities db = new GarageDBEntities())
         {
             List<Product> products = (from x in db.Products
                                             where x.TypeID == typeId
                                             select x).ToList();
             return products;
         }
     }
     catch (Exception)
     {
         return null;
     }
 }
コード例 #10
0
    public string DeleteProduct(int id)
    {
        try
        {
            GarageDBEntities db      = new GarageDBEntities();
            Product          product = db.Products.Find(id);

            db.Products.Attach(product);
            db.Products.Remove(product);
            db.SaveChanges();

            return(product.Name + " was succesfully deleted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #11
0
    public string DeleteProductType(int id) // Delete from the primary key value
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            //First to find the objects to be deleted
            ProductType productType = db.ProductTypes.Find(id);

            db.ProductTypes.Attach(productType);
            db.ProductTypes.Remove(productType);
            db.SaveChanges();
            return(productType.Name + "was successfully Deleted...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #12
0
        public string deletePurchase(int id)
        {
            try
            {
                GarageDBEntities db       = new GarageDBEntities();
                Purchase         purchase = db.Purchases.Find(id);

                db.Purchases.Attach(purchase);
                db.Purchases.Remove(purchase);
                db.SaveChanges();

                return(purchase.Date + " was succesfully deleted");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
コード例 #13
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    public string DeleteCart(int id)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            Cart cart = db.Carts.Find(id);

            db.Carts.Attach(cart);
            db.Carts.Remove(cart);
            db.SaveChanges();

            return cart.DatePurchased + "was succesfully deleted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #14
0
    public int GetAmountOfOrders(string userID)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            int amount = (from x in db.Carts
                          where x.ClientId == userID &&
                          x.IsInCart
                          select x.Amount).Sum();

            return(amount);
        }
        catch (Exception)
        {
            return(0);
        }
    }
コード例 #15
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string DeleteProductType(int id)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            ProductType productType = db.ProductTypes.Find(id);

            db.ProductTypes.Attach(productType);
            db.ProductTypes.Remove(productType);
            db.SaveChanges();

            return productType.Name + "was succesfully deleted";
        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #16
0
 private async void SeekRec(string vin)
 {
     using (GarageDBEntities db = new GarageDBEntities())
     {
         var q = await(from m in db.Cars
                       from d in db.FeaturesCars
                       from c in db.Clientes
                       from r in db.ViewJob
                       where m.VinNumber == vin &&
                       d.VinNumber == m.VinNumber &&
                       c.VinNumber == d.VinNumber
                       select new
                       { m.VinNumber,
                         m.GosNumber,
                         d.PTC_number,
                         c.sName,
                         c.fName,
                         r.viewJob1 }).ToListAsync();
         await this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (ThreadStart) delegate()
         {
             foreach (var i in q)
             {
                 vintxtbox.Text        = null;
                 gosNumTxtBox.Text     = null;
                 ptcNumTxtBox.Text     = null;
                 secondNameTxtBox.Text = null;
                 fNameTxtBox.Text      = null;
                 viewJobTxtbox.Text    = null;
                 //vintxtbox.Text += string.Format("{0}\r\n", i.VinNumber);
                 vintxtbox.Text         = i.VinNumber;
                 gosNumTxtBox.Text     += string.Format("{0}\r\n", i.GosNumber);
                 ptcNumTxtBox.Text     += string.Format("{0}\r\n", i.PTC_number);
                 secondNameTxtBox.Text += string.Format("{0}\r\n", i.sName);
                 fNameTxtBox.Text      += string.Format("{0}\r\n", i.fName);
                 //viewJobTxtbox.Text += string.Format("{0}\r\n", i.viewJob1);
                 viewJobTxtbox.Text = i.viewJob1.ToString();
                 //viewJobTxtbox.SelectedIndex = 0;
                 //vintxtbox.SelectedIndex = 0;
                 //gosNumTxtBox.SelectedIndex = 0;
             }
         });
     }
 }
コード例 #17
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            //Fetch object from db
            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + "was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #18
0
ファイル: ProductTypeModel.cs プロジェクト: SaifAsad/garager
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            //Fetch object from db
            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return productType.Name + "was succesfully updated";

        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #19
0
 private void AcceptChange()
 {
     using (GarageDBEntities db = new GarageDBEntities())
     {
         var getOrder = dataGistoryOrder.SelectedItem as History;
         if (getOrder != null)
         {
             var seekOrder = db.History.Where(r => r.id == getOrder.id).FirstOrDefault();
             seekOrder.Result          = true;
             db.Entry(seekOrder).State = EntityState.Modified;
             db.SaveChanges();
             GetData();
         }
         else
         {
             MessageBox.Show("Выберите строку с заказ-нарядом!");
             return;
         }
     }
 }
コード例 #20
0
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            //To fetch productTypes from database
            ProductType p = db.ProductTypes.Find(id);   //find will return the entity with the given primary key values

            //To replace the data stored in object p by the data given in 'productType'.
            //We can actually update only the parameters in the 'productTypes'
            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + "was successfully updated...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #21
0
    public string DeleteCart(int id)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            Cart cart = db.Carts.Find(id);

            db.Carts.Attach(cart);
            db.Carts.Remove(cart);

            db.SaveChanges();

            return(cart.DatePurchased + " was successfully deleted");
        }
        catch (Exception e)
        {
            return("Error: " + e);
        }
    }
コード例 #22
0
        // поиск и вывод информации по гос номеру автомобиля
        private async void SeekGos(string gos)
        {
            using (GarageDBEntities db = new GarageDBEntities())
            {
                var vin  = db.Cars.Where(r => r.GosNumber == gos).FirstOrDefault();
                var quer = await(from m in db.Cars
                                 from t in db.FeaturesCars
                                 from c in db.Clientes
                                 where m.VinNumber == vin.VinNumber &&
                                 t.VinNumber == m.VinNumber &&
                                 c.VinNumber == t.VinNumber
                                 select new
                {
                    m.VinNumber,
                    m.GosNumber,
                    t.PTC_number,
                    c.sName,
                    c.fName
                }).ToListAsync();

                await this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (ThreadStart) delegate()
                {
                    foreach (var q in quer)
                    {
                        gosNumTxtBox.Text     = null;
                        ptcNumTxtBox.Text     = null;
                        secondNameTxtBox.Text = null;
                        fNameTxtBox.Text      = null;
                        //vintxtbox.Text += string.Format("{0}\r\n", q.VinNumber);
                        vintxtbox.Text         = q.VinNumber;
                        gosNumTxtBox.Text     += string.Format("{0}\r\n", q.GosNumber);
                        ptcNumTxtBox.Text     += string.Format("{0}\r\n", q.PTC_number);
                        secondNameTxtBox.Text += string.Format("{0}\r\n", q.sName);
                        fNameTxtBox.Text      += string.Format("{0}\r\n", q.fName);
                        //vintxtbox.SelectedIndex = 0;
                        // gosNumTxtBox.SelectedIndex = 0;
                    }
                });
            }
        }
コード例 #23
0
    public string UpdateCart(int id, cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            cart             p  = db.carts.Find(id);

            p.DatePurchased = cart.DatePurchased;
            p.ClientID      = cart.ClientID;
            p.Amount        = cart.Amount;
            p.IsInCart      = cart.IsInCart;
            p.ProductID     = cart.ProductID;

            db.SaveChanges();

            return(cart.DatePurchased + " was successfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #24
0
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            Product p = db.Products.Find(id);

            p.Name        = product.Name;
            p.Price       = product.Price;
            p.TypeId      = product.TypeId;
            p.Description = product.Description;
            p.Image       = product.Image;

            db.SaveChanges();

            return(product.Name + " was successfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #25
0
        public string updatePurchase(int id, Purchase purchase)
        {
            try
            {
                GarageDBEntities db = new GarageDBEntities();

                Purchase p = db.Purchases.Find(id);

                p.Date       = purchase.Date;
                p.CustomerID = purchase.CustomerID;
                p.Amount     = purchase.Amount;
                p.IsInCart   = purchase.IsInCart;
                p.ProductID  = purchase.ProductID;

                db.SaveChanges();

                return(purchase.Date + " was succesfully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
コード例 #26
0
 private void Delete()
 {
     try
     {
         using (GarageDBEntities db = new GarageDBEntities())
         {
             var sel = DataGrid.SelectedItem as ViewJob;
             if (sel != null)
             {
                 var result = db.ViewJob.Where(r => r.id == sel.id).FirstOrDefault();
                 if (result != null)
                 {
                     result.id = sel.id;
                     db.Entry(result).State = EntityState.Deleted;
                     db.SaveChanges();
                     Load();
                     MessageBox.Show("Запись удалена");
                 }
                 else
                 {
                     MessageBox.Show("Нельзя удалять пустую строку!");
                     return;
                 }
             }
             else
             {
                 MessageBox.Show("Необходимо выбрать строку для удаления!");
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #27
0
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();
            //To fetch carts from database
            Cart p = db.Carts.Find(id);   //find will return the entity with the given primary key values

            //To replace the data stored in object p by the data given in 'cart'.
            //We can actually update only the parameters in the 'carts'
            p.DatePurchased = cart.DatePurchased;
            p.ClientID      = cart.ClientID;
            p.Amount        = cart.Amount;
            p.IsInCart      = cart.IsInCart;
            p.ProductID     = cart.ProductID;

            db.SaveChanges();
            return(cart.DatePurchased + "was successfully updated...");
        }
        catch (Exception e)
        {
            return("Error :" + e);
        }
    }
コード例 #28
0
        private void NewRecord()
        {
            try
            {
                using (GarageDBEntities db = new GarageDBEntities())
                {
                    // добавление в таблицу VIN-номера
                    carClass.VinNumber = vinTxtbox.Text;
                    // Добавление гос номера
                    carClass.GosNumber = goxNumberTxtBox.Text;
                    // Добавление модели
                    carClass.Model = ModeltxtBox.Text;
                    // Добавление марки автомобиля
                    carClass.Mark = MarkTxtBox.Text;

                    db.Cars.Add(carClass);
                    db.SaveChanges();
                    int getId    = 0;
                    var countMax = from m in db.FeaturesCars
                                   select m.Id;
                    foreach (var cont in countMax)
                    {
                        getId = countMax.Max();
                    }
                    if (getId != 0)
                    {
                        var getNum = db.FeaturesCars.Where(r => r.Id == getId).FirstOrDefault();
                        if (getNum != null)
                        {
                            do
                            {
                                getId++;
                                features.Id = getId;
                            } while (getNum.Id == getId);
                        }
                    }
                    else
                    {
                        getId = 1;
                    }

                    // добавление VIN-номера в таблицу FeaturesCars
                    features.VinNumber = vinTxtbox.Text;
                    //Добавление ПТС номера
                    features.PTC_number = ptcTxtBox.Text;
                    //добавление цвета
                    features.Color = colorTxtBox.Text;
                    // добавление возраста автомобиля
                    //features.Age = Convert.ToDateTime(dataAge.Text);
                    // добавление типа двигателя
                    features.TypeEngien = TypeEngTxtBox.Text;
                    // Добавление объема двигателя
                    features.VolumeEngien = Convert.ToDouble(volumeEngine.Text);
                    // Добавление мощности двигателя
                    features.EngienPower = Convert.ToDouble(EngPowerTxtBox.Text);
                    // добавление типа привода
                    features.TypeDriveMachine = typeDrive.Text;
                    // добавление типа кузова
                    features.TypeFrame = frameTxtbox.Text;
                    //добавление возраста автомобиля
                    features.Age      = Convert.ToInt32(agetxtbox.Text);
                    features.Category = categoryTxtBox.Text;

                    db.FeaturesCars.Add(features);
                    db.SaveChanges();

                    clientes.Id = carClass.id;
                    var cId = db.Clientes.Where(r => r.Id == clientes.Id).FirstOrDefault();
                    if (cId == null)
                    {
                        clientes.Id = carClass.id;
                    }
                    clientes.VinNumber      = vinTxtbox.Text;
                    clientes.sName          = sNameTTxtBox.Text;
                    clientes.fName          = fNameTxtBox.Text;
                    clientes.city           = cityTxtBox.Text;
                    clientes.telephonNumber = teltxtBox.Text;
                    clientes.mail           = mailTxtBox.Text;

                    db.Clientes.Add(clientes);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #29
0
 public PurchaseModel()
 {
     garageDBEntities = new GarageDBEntities();
 }
コード例 #30
0
        // создание нового заказ-наряда
        private void CreateOrder()
        {
            using (GarageDBEntities db = new GarageDBEntities())
            {
                int getId = 0;
                var vN    = vintxtbox.Text;
                order.VinNumber = vN.ToString();
                var countMax = from m in db.Orders
                               select m.id;
                foreach (var c in countMax)
                {
                    getId = countMax.Max();
                }
                if (getId != 0)
                {
                    var getNum = db.Orders.Where(r => r.id == getId).FirstOrDefault();
                    if (getNum != null)
                    {
                        do
                        {
                            getId++;
                            order.id = getId;
                        } while (getNum.id == getId);
                    }
                }
                else
                {
                    getId = 1;
                }
                order.IdOrder = Convert.ToInt32(idOrderTxtBox.Text);
                var vinN = db.Clientes.Where(r => r.VinNumber == vN.ToString()).FirstOrDefault();
                if (vinN != null)
                {
                    order.IdClient = vinN.Id;
                }

                order.Descript  = DescriptJobTxtBox.Text;
                order.DateBegin = Convert.ToDateTime(beginDT.Text);
                order.DateEnd   = Convert.ToDateTime(EndDT.Text);
                TimeSpan timeBegin = TimeSpan.Parse(TimeStart.Text);
                order.timeStart = timeBegin;
                TimeSpan timeEnd = TimeSpan.Parse(TimeEnd.Text);
                order.TimeEnd = timeEnd;
                var emp = db.Employess.Where(r => r.sNameEnp == sNameTxtBox.Text).FirstOrDefault();
                if (emp != null)
                {
                    order.IdEmp = emp.Id;
                }
                //db.Orders.Add(order);
                //db.Entry(order).State = EntityState.Added;
                //db.SaveChanges();

                db.Orders.Add(order);
                db.SaveChanges();

                // добавление записей в историю
                history.id          = getId;    //vinN.Id;
                history.idORDER     = order.id; //Convert.ToInt32(idOrderTxtBox.Text);
                history.idVin       = vN.ToString();
                history.idEmployees = emp.Id;
                var featur = db.FeaturesCars.Where(r => r.VinNumber == order.VinNumber).FirstOrDefault();
                if (featur != null)
                {
                    history.idFeatures = featur.PTC_number;
                }

                history.DateHistory = Convert.ToDateTime(beginDT.Text);
                string viewJob = viewJobTxtbox.Text.ToString();

                history.EventHistory = viewJob;
                history.Result       = false;
                history.Descript     = DescriptJobTxtBox.Text;
                db.History.Add(history);
                db.SaveChanges();
                IDORder   = Convert.ToInt32(idOrderTxtBox.Text);
                VinNumber = vintxtbox.Text;
            }
        }
コード例 #31
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    //update the quantity of a selected product in the shopping cart
    public void UpdateQuantity(int id, int quantity)
    {
        GarageDBEntities db = new GarageDBEntities();
        Cart p = db.Carts.Find(id);
        p.Amount = quantity;

        db.SaveChanges();
    }
コード例 #32
0
ファイル: ProductModel.cs プロジェクト: SaifAsad/garager
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            //Fetch object from db
            Product p = db.Products.Find(id);

            p.Name = product.Name;
            p.Price = product.Price;
            p.TypeID = product.TypeID;
            p.Description = product.Description;
            p.Image = product.Image;

            db.SaveChanges();
            return product.Name + " was succesfully updated";

        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #33
0
ファイル: UserInfoModel.cs プロジェクト: SaifAsad/garager
 //this method will be called whenever a new user is created
 public void InsertUserDetail(UserInformation info)
 {
     GarageDBEntities db = new GarageDBEntities();
     db.UserInformations.Add(info);
     db.SaveChanges();
 }
コード例 #34
0
        private async void LoadOnID(int Id)
        {
            using (GarageDBEntities db = new GarageDBEntities())
            {
                var query = await(from m in db.Cars
                                  from c in db.Clientes
                                  from f in db.FeaturesCars
                                  where m.id == Id &&
                                  c.VinNumber == m.VinNumber &&
                                  f.VinNumber == m.VinNumber
                                  select new
                {
                    m.Mark,
                    m.Model,
                    m.GosNumber,
                    m.VinNumber,
                    c.sName,
                    c.fName,
                    c.city,
                    c.telephonNumber,
                    c.mail,
                    f.PTC_number,
                    f.TypeDriveMachine,
                    f.TypeEngien,
                    f.TypeFrame,
                    f.VolumeEngien,
                    f.Age,
                    f.Category,
                    f.Color,
                    f.EngienPower
                }).ToListAsync();

                await this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (ThreadStart) delegate()
                {
                    foreach (var q in query)
                    {
                        vinTxtbox.Text      = q.VinNumber;
                        vinTxtbox.IsEnabled = false;

                        goxNumberTxtBox.Text      = q.GosNumber;
                        goxNumberTxtBox.IsEnabled = false;

                        ptcTxtBox.Text      = q.PTC_number;
                        ptcTxtBox.IsEnabled = false;

                        ModeltxtBox.Text      = q.Model;
                        ModeltxtBox.IsEnabled = false;

                        MarkTxtBox.Text      = q.Mark;
                        MarkTxtBox.IsEnabled = false;

                        colorTxtBox.Text      = q.Color;
                        colorTxtBox.IsEnabled = false;

                        TypeEngTxtBox.Text      = q.TypeEngien;
                        TypeEngTxtBox.IsEnabled = false;

                        EngPowerTxtBox.Text      = q.EngienPower.ToString();
                        EngPowerTxtBox.IsEnabled = false;

                        volumeEngine.Text      = q.VolumeEngien.ToString();
                        volumeEngine.IsEnabled = false;

                        frameTxtbox.Text      = q.TypeFrame;
                        frameTxtbox.IsEnabled = false;

                        typeDrive.Text      = q.TypeDriveMachine;
                        typeDrive.IsEnabled = false;

                        categoryTxtBox.Text      = q.Category;
                        categoryTxtBox.IsEnabled = false;

                        sNameTTxtBox.Text      = q.sName;
                        sNameTTxtBox.IsEnabled = false;

                        fNameTxtBox.Text      = q.fName;
                        fNameTxtBox.IsEnabled = false;

                        cityTxtBox.Text      = q.city;
                        cityTxtBox.IsEnabled = false;

                        teltxtBox.Text      = q.telephonNumber;
                        teltxtBox.IsEnabled = false;

                        mailTxtBox.Text      = q.mail;
                        mailTxtBox.IsEnabled = false;

                        agetxtbox.Text      = q.Age.ToString();
                        agetxtbox.IsEnabled = false;
                    }
                });
            }
        }
コード例 #35
0
ファイル: CartModel.cs プロジェクト: SaifAsad/garager
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            GarageDBEntities db = new GarageDBEntities();

            //Fetch object from db
            Cart p = db.Carts.Find(id);

            p.DatePurchased = cart.DatePurchased;
            p.ClientID = cart.ClientID;
            p.Amount = cart.Amount;
            p.IsInCart = cart.IsInCart;
            p.ProductID = cart.ProductID;

            db.SaveChanges();
            return cart.DatePurchased + " was succesfully updated";

        }
        catch (Exception e)
        {
            return "Error:" + e;
        }
    }
コード例 #36
0
 public ProductModel()
 {
     garageDBEntities = new GarageDBEntities();
 }