Example #1
0
        /// <summary>
        /// Method to Get the Product Structures(Hierachie) to fill the Category and Subcategory Combobox
        /// </summary>
        public void GetProductStructure()
        {
            if (CategoryList.Count() > 0)
            {
                CategoryList.Clear();
            }

            if (SubCategoryList.Count() > 0)
            {
                SubCategoryList.Clear();
            }

            using (var db = new DataSmartDBContext())
            {
                var structure = db.ProductStructure.ToList();

                if (structure != null)
                {
                    foreach (var d in structure)
                    {
                        CategoryList.Add(d.Category_1);
                        SubCategoryList.Add(d.Category_2);
                    }
                    CategoryList    = CategoryList.Distinct().ToList();
                    SubCategoryList = SubCategoryList.Distinct().ToList();
                }
            }
        }
Example #2
0
        public void UpdateEmployee()
        {
            using (var db = new DataSmartDBContext())
            {
                var employeeToUpdate = db.Employee.Find(SelectedEmployee.EmployeeId);

                // Check wether the new value of EmployeeSIN is identical to an existing Employee EmployeeSIN since this property value should be unique
                if (db.Employee.Any(o => o.EmployeeId != Employee.EmployeeId & o.EmployeeSIN == Employee.EmployeeSIN))
                {
                    MessageBox.Show("Il existe deja un employé avec le meme ID dans la base de donnée", "DataSmart Info", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else // Else apply updates to the selected employee
                {
                    // Show a dialog box to confirm the action. if result is Yes then apply changes otherwise do nothing
                    var result = MessageBox.Show("Vous êtes sur le point de modifier les informations de la ligne séctionnée avec les informations affichées. " +
                                                 "Voulez vous poursuivre la modification?", "DataSmart Info", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    if (result == MessageBoxResult.Yes)
                    {
                        // Update the selected entity property values with th new ones
                        db.Entry(employeeToUpdate).CurrentValues.SetValues(Employee);
                        db.SaveChanges();   // Save changes to the database
                        MessageBox.Show("Employé Mis À Jour", "DataSmart Info", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
        }
Example #3
0
 public void AddNewEmployee()
 {
     using (var db = new DataSmartDBContext())
     {
         if (db.Employee.Any(o => o.EmployeeSIN == Employee.EmployeeSIN))
         {
             MessageBox.Show("Employé deja existant dans la base de donnée. Aucun changement effectué", "DataSmart Info", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             db.Employee.Add(Employee);
             db.SaveChanges();
             MessageBox.Show("Nouvel employé sauvegardé dans la base données avec succès", "DataSmart Info", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
 }
Example #4
0
 public void DeleteEmployee()
 {
     using (var db = new DataSmartDBContext())
     {
         var employeeToDelete = db.Employee.Find(SelectedEmployee.EmployeeId);
         if (employeeToDelete != null)
         {
             var result = MessageBox.Show("Êtes vous sûre de supprimer définitivement Cet Employé?", "DataSmart Info", MessageBoxButton.YesNo, MessageBoxImage.Warning);
             if (result == MessageBoxResult.Yes)
             {
                 db.Employee.Remove(employeeToDelete);
                 db.SaveChanges();
                 MessageBox.Show("Employé Supprimé de la base de données avec succès!", "DataSmart Info", MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
 }
Example #5
0
 /// <summary>
 /// Method to Save new entity of Product
 /// </summary>
 public void AddNewProduct()
 {
     using (var db = new DataSmartDBContext())
     {
         if (db.Produits.Any(o => o.ProductName == Product.ProductName & o.ProductCategory_1 == Product.ProductCategory_1 & o.ProductCategory_2 == Product.ProductCategory_2))
         {
             MessageBox.Show("Il existe déja un produit avec le meme nom dans la base de données. Veuillez vérifier de nouveau les informations saisies." +
                             "Aucun Changement affectué.", "DataSmart Info", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             Product.DateOfRecord = DateTime.Now;
             db.Produits.Add(Product);
             db.SaveChanges();
             MessageBox.Show("Nouveau produit sauvegardé dans la base de données avec succès", "DataSmart", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
 }
Example #6
0
        public void FillEmployeeGrid()
        {
            if (EmployeeList.Count() > 0)
            {
                EmployeeList.Clear();
            }
            using (var db = new DataSmartDBContext())
            {
                var emp = db.Employee.ToList();

                if (emp != null)
                {
                    foreach (var d in emp)
                    {
                        EmployeeList.Add(d);
                    }
                }
            }
        }
Example #7
0
        // Method to fill the datagrid
        public void FillProductGrid()
        {
            if (ProductList.Count() > 0)
            {
                ProductList.Clear();
            }
            using (var db = new DataSmartDBContext())
            {
                var prod = db.Produits.ToList();

                if (prod != null)
                {
                    foreach (var d in prod)
                    {
                        ProductList.Add(d);
                    }
                }
            }
        }
Example #8
0
 public void SaveNewProductStructure()
 {
     using (var db = new DataSmartDBContext())
     {
         if (db.ProductStructure.Any(o => o.Category_1 == Product.ProductCategory_1 & o.Category_2 == Product.ProductCategory_2))
         {
             return;
         }
         else
         {
             ProductStructure Structure = new ProductStructure()
             {
                 Category_1 = Product.ProductCategory_1,
                 Category_2 = Product.ProductCategory_2
             };
             db.ProductStructure.Add(Structure);
             db.SaveChanges();
         }
     }
 }
Example #9
0
 /// <summary>
 ///  Method to update an Existing Entity of Product
 /// </summary>
 public void UpdateProduct()
 {
     using (var db = new DataSmartDBContext())
     {
         var productToUpdate = db.Produits.Find(SelectedProduct.ProductId);
         if (db.Produits.Any(o => o.ProductId != Product.ProductId & o.ProductName == Product.ProductName))
         {
             MessageBox.Show("Il existe deja un autre produit avec le meme nom dans la base de donnée", "DataSmart Info", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             var result = MessageBox.Show("Vous êtes sur le point de modifier les informations de la ligne séctionnée avec les informations affichées. " +
                                          "Voulez vous poursuivre la modification?", "DataSmart Info", MessageBoxButton.YesNo, MessageBoxImage.Warning);
             if (result == MessageBoxResult.Yes)
             {
                 db.Entry(productToUpdate).CurrentValues.SetValues(Product);
                 db.SaveChanges();
                 MessageBox.Show("Produit Mis à Jour!", "DataSmart Info", MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
 }