public string AddNewProvider(string comanyName, string contactTitle, string contactName, string address,
            string country, string region, string city, string postalCode, string phone, string homePage, string email,
            string fax, string rC, string nF, string nIs, string aI, int status, byte[] photo)
        {
            try
            {
                _gestionDb = new GcdbEntities();
                Provider newProvider = new Provider
                {
                    CompanyName = comanyName,
                    ContactTitle = contactTitle,
                    ContactName = contactName,
                    Address = address,
                    Country = country,
                    Region = region,
                    City = city,
                    PostalCode = postalCode,
                    Photo = photo,
                    HomePage = homePage,
                    Email = email,
                    RC = rC,
                    NF = nF,
                    NIS = nIs,
                    AI = aI,
                    Status = status,

                };
                _gestionDb.Providers.Add(newProvider);
                _gestionDb.SaveChanges();
                Telephone newTelephone = new Telephone
                {
                    SupplierID = newProvider.SupplierID,
                    TELEPHONETYPE = "Fix",
                    TELEPHONENUMBER = fax

                };
                _gestionDb.Telephones.Add(newTelephone);
                _gestionDb.SaveChanges();
                Telephone newTelephone2 = new Telephone
                {
                    SupplierID = newProvider.SupplierID,
                    TELEPHONETYPE = "mobile",
                    TELEPHONENUMBER = phone

                };
                _gestionDb.Telephones.Add(newTelephone2);
                _gestionDb.SaveChanges();
                return "Ajouté avec succés";
            }
            catch (Exception)
            {
                return "Erreur";
            }
        }
 public string AddNewCustomer(string companName, string contactTitle, string contactName, string address, string country, string region, string city, string postalCode, string phone, string homePage, string email, string fax, string rC, string nF, string nIs, string aI, int status, byte[] photo)
 {
     try
     {
         _gestionDb = new GcdbEntities();
         Customer newCustomer = new Customer();
         newCustomer.CompanyName = companName;
         newCustomer.ContactTitle = contactTitle;
         newCustomer.ContactName = contactName;
         newCustomer.Address = address;
         newCustomer.Country = country;
         newCustomer.Region = region;
         newCustomer.City = city;
         newCustomer.PostalCode = postalCode;
         newCustomer.Phone = phone;
         newCustomer.HomePage = homePage;
         newCustomer.Email = email;
         newCustomer.Fax = fax;
         newCustomer.RC = rC;
         newCustomer.NF = nF;
         newCustomer.NIS = nIs;
         newCustomer.AI = aI;
         newCustomer.Photo = photo;
         newCustomer.Status = status;
         _gestionDb.Customers.Add(newCustomer);
         _gestionDb.SaveChanges();
         return "Ajouté avec succés";
     }
     catch (Exception)
     {
         return "Erreur";
     }
 }
Пример #3
0
        public string AddNewProduct(string categoryName, string subCategoryName, string productName,
            string productMeasure, string productType, string productReferenceIntenrne, int qteMin, int qteMax,
            string productDesignation, string productRemarks, int state)
        {
            try
            {
                _gestionDb = new GcdbEntities();

                int getSubCategoryId = GetSubCategoryId(categoryName, subCategoryName);
                var newProduct = new Product
                {
                    SubCategoryID = getSubCategoryId,

                    ProductName = productName,
                    MeasureUnit = productMeasure,
                    ProductMaxQte = qteMax,
                    ProductMinQte = qteMin,
                    ReferenceInterne = productReferenceIntenrne,
                    Designation = productDesignation,
                    Remarks = productRemarks,
                    productType = productType,
                    Status = state
                };
                _gestionDb.Products.Add(newProduct);
                _gestionDb.SaveChanges();
                return "Ajouté avec succés";
            }
            catch (Exception)
            {
                return "Erreur";
            }
        }
        public String AddPurchase(Purchase pur)
        {
            _gestionDb = new GcdbEntities();
            if (IsPurchaseExist(pur)) return "Achat existe déjà";

            _gestionDb.Purchases.Add(pur);
            _gestionDb.SaveChanges();

            return "Achat ajouter avec succes";
        }
Пример #5
0
        public String AddOrder(Order order)
        {
            _gestionDb = new GcdbEntities();
            if (IsOrderExist(order)) return "Ordre existe déjà";

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

            return "Order ajouter avec succes";
        }
        public String AddOrderDetails(OrderDetail od)
        {
            _gestionDb = new GcdbEntities();
            if (IsOrderDetailsExist(od)) return "OrderDetails existe déjà";

            _gestionDb.OrderDetails.Add(od);
            _gestionDb.SaveChanges();

            return "OrderDetails ajouter avec succes";
        }
 public void RemoveMeasure(int measureId)
 {
     _gestionDb = new GcdbEntities();
     var query = from t in _gestionDb.ProductMeasures
                 where t.ProMeasureID == measureId
         select t;
     if (!query.Any()) return;
     _gestionDb.ProductMeasures.Remove(query.First());
     _gestionDb.SaveChanges();
 }
        public String AddCustomer(Customer c)
        {
            _gestionDb = new GcdbEntities();
            if (IsCustomerExist(c)) return "Client existe déjà";

            _gestionDb.Customers.Add(c);
            _gestionDb.SaveChanges();

            return "Ajouté avec succes";
        }
Пример #9
0
        public String DelTva(TVA tva)
        {
            _gestionDb = new GcdbEntities();
            if (!IsTvaExist(tva)) return "TVA n'existante pas";
            var tva1 = _gestionDb.TVAs.Single(t => t.TVAID == tva.TVAID);
            _gestionDb.TVAs.Remove(tva);
            _gestionDb.SaveChanges();

            return "TVA supprimer avec succes";
        }
Пример #10
0
        public String AddTva(TVA tva)
        {
            _gestionDb = new GcdbEntities();
            if (IsTvaExist(tva)) return "TVA existe déjà";

            _gestionDb.TVAs.Add(tva);
            _gestionDb.SaveChanges();

            return "TVA ajouter avec succes";
        }
Пример #11
0
 public void UpdateMeasure(int measureId, string name)
 {
     _gestionDb = new GcdbEntities();
     var query = from t in _gestionDb.ProductMeasures
                 where t.ProMeasureID == measureId
         select t;
     if (!query.Any()) return;
     query.First().ProMeasureUnit = name;
     _gestionDb.SaveChanges();
 }
        public String AddFacture(Facture fact)
        {
            _gestionDb = new GcdbEntities();
            if (IsFactureExist(fact)) return "Facture existe déjà";

            _gestionDb.Factures.Add(fact);
            _gestionDb.SaveChanges();

            return "Facture ajouter avec succes";
        }
Пример #13
0
        public void AddMeasure(string name)
        {
            _gestionDb = new GcdbEntities();
            var theMeasure = new ProductMeasure
            {

                ProMeasureUnit = name
            };
            _gestionDb.ProductMeasures.Add(theMeasure);
            _gestionDb.SaveChanges();
        }
        public String DelCustomer(Customer c)
        {
            _gestionDb = new GcdbEntities();
            if (!IsCustomerExist(c)) return "Client n'existante pas";
            var customer = _gestionDb.Customers.Single(cus => cus.CustomerID.Equals(c.CustomerID));
            _gestionDb.Customers.Remove(customer);

            _gestionDb.SaveChanges();

            return "Client supprimer avec succes";
        }
Пример #15
0
        public String DelPurchase(Purchase pur)
        {
            _gestionDb = new GcdbEntities();
            if (!IsPurchaseExist(pur)) return "Achat n'existante pas";

            Purchase purchase = _gestionDb.Purchases.Single(p => p.PurchaseID == pur.PurchaseID);
            _gestionDb.Purchases.Remove(pur);
            _gestionDb.SaveChanges();

            return "Achat supprimer avec succes";
        }
        public String DelOrderDetails(OrderDetail od)
        {
            _gestionDb = new GcdbEntities();
            if (!IsOrderDetailsExist(od)) return "OrderDetails n'existante pas";

            OrderDetail orderDetails = _gestionDb.OrderDetails.Single(od1 => (od1.OrderID == od.OrderID) && (od1.ProductID == od.ProductID));
            _gestionDb.OrderDetails.Remove(orderDetails);
            _gestionDb.SaveChanges();

            return "OrderDetails supprimer avec succes";
        }
Пример #17
0
        public String AddProduct(Product produit)
        {
            _gestionDb = new GcdbEntities();

            if (IsProductExist(produit))
            {
                return "Produit existe déjà ...";
            }

               _gestionDb.Products.Add(produit);
               _gestionDb.SaveChanges();

               return "Produit ajouter avec succes";
        }
Пример #18
0
        public String ActivatUser(Password pass)
        {
            _gestionDb = new GcdbEntities();

            if (!IsUserExist(pass)) return "Utilisateur n'existante pas";

            Password user = _gestionDb.Passwords.Single(pw => pw.Login.Equals(pass.Login));

            user.Status = 1;

            _gestionDb.SaveChanges();

            return "Utilisateur activer avec succes";
        }
Пример #19
0
        public String DelProduct(Product p)
        {
            _gestionDb = new GcdbEntities();
            if (!IsProductExist(p)) return "Product n'existante pas";
            var objRd = _gestionDb.Products.Where(prod => prod.ProductName.Equals(p.ProductName));
            if (objRd.Any())
            {
                foreach (Product objR in objRd)
                {
                    _gestionDb.Products.Add(objR);
                }
            }
            _gestionDb.SaveChanges();

            return "Produit supprimer avec succes";
        }
        public String AddEmployee(Employee emp)
        {
            try
            {
                _gestionDb = new GcdbEntities();
                if (IsEmployeeExist(emp)) return "Employee existe déjà";

                _gestionDb.Employees.Add(emp);
                _gestionDb.SaveChanges();

                return "Employee ajouter avec succes";
            }
            catch (Exception e)
            {
                return "";
            }
        }
        public String DelEmployee(Employee emp)
        {
            try
            {
                _gestionDb = new GcdbEntities();
                if (!IsEmployeeExist(emp)) return "Employee n'existante pas";

                var employee = _gestionDb.Employees.Single(em => em.EmployeeID.Equals(emp.EmployeeID));
                _gestionDb.Employees.Remove(employee);
                _gestionDb.SaveChanges();

                return "Employee supprimer avec succes";
            }
            catch (Exception e)
            {
                return "";
            }
        }
Пример #22
0
 public string DelPurchase(int purchaseId)
 {
     try
     {
         _gestionDb = new GcdbEntities();
         var query = from t in _gestionDb.Purchases
                     where t.PurchaseID == purchaseId
                     select t;
         if (!query.Any()) return "Essai plus tards!";
         _gestionDb.Purchases.Remove(query.First());
         _gestionDb.SaveChanges();
         return "Supprimé avec succés";
     }
     catch (Exception exe)
     {
         return exe.ToString();
     }
 }
Пример #23
0
 public string DeleteStockStore(StockStore getStockStore)
 {
     try
        {
        var gestionDb = new GcdbEntities();
        var query = from t in gestionDb.StockStores
                    where t.StockStoreID == getStockStore.StockStoreID
                    select t;
        if (!query.Any()) return "Erreur";
        gestionDb.StockStores.Remove(query.First());
        gestionDb.SaveChanges();
        return "Supprimé avec succés";
        }
        catch (Exception)
        {
        return "Erreur";
        }
 }
        public String DesactivateProvider(Provider provider)
        {
            try
            {
                _gestionDb = new GcdbEntities();
                var query = from t in _gestionDb.Providers
                    where t.SupplierID == provider.SupplierID
                    select t;
                if (!query.Any()) return "Erreur";
                query.First().Status = 1;
                _gestionDb.SaveChanges();
                return "Fournisseur désactiver avec succés";
            }
            catch (Exception e)
            {

                return "Erreur";
            }
        }
Пример #25
0
        public String AddUser(Password pass)
        {
            try
            {

               _gestionDb = new GcdbEntities();
            bool v = IsUserExist(pass);
            if (IsUserExist(pass))
                return "Utilisateur existe déjà";

            _gestionDb.Passwords.Add(pass);
            _gestionDb.SaveChanges();

            }
            catch (Exception ex)
            {

                return ex.Message;
            }
            return "Utilisateur ajouter avec succes";
        }
Пример #26
0
        public string AddNewProductToStock(Product product,
           float prixAchat, int qteAchter, float prixVenteGros,float prixVenteDetail,float prixVenteComptoire, float totalPriceHt,
           string stockageId, string productSnumber, string productState,
           string stockObs, DateTime insertionDate, string refrenceNum)
        {
            try
               {
               var gestionDb = new GcdbEntities();

               var newsStockStore = new StockStore
               {
                   ProductID = product.ProductID,
                   PurchasePrice = prixAchat,
                   UnitsOnOrder = qteAchter,
                   VentePriceGros = prixVenteGros,
                   VentePriceDetail = prixVenteDetail,
                   VentePriceComptoire = prixVenteComptoire,
                   TotalPriceAchat = totalPriceHt,
                   Status = 0,
                   TvaValue = 0,
                   Discount = 0,
                   ProductState = productState,
                   Serialnumber = productSnumber,
                   Observation = stockObs,
                   InsertionDate = insertionDate,
                   RefrenceNum = refrenceNum,
                   StockageID = stockageId
               };

               gestionDb.StockStores.Add(newsStockStore);
               gestionDb.SaveChanges();
               return "Ajouté avec succés";

               }
               catch (Exception)
               {
               return "Erreur";
               }
        }
Пример #27
0
        public string UpdateProduct(Product produit, string categoryName, string subCategoryName,
            string productName, string productMeasure, string productType, 
            string productReferenceIntenrne, int qteMin, int qteMax, string productDesignation, 
            string productRemarks)
        {
            try
            {
                int getCategoryId = GetSubCategoryId(categoryName, subCategoryName);
                _gestionDb = new GcdbEntities();
                var query = from t in _gestionDb.Products
                            where t.ProductID == produit.ProductID
                            select t;
                if (!query.Any()) return "Produit n'existe pas!";

                query.First().SubCategoryID = getCategoryId;

                query.First().ProductName = productName;
                query.First().MeasureUnit = productMeasure;
                query.First().ProductMaxQte = qteMax;
                query.First().ProductMinQte = qteMin;
                query.First().ReferenceInterne = productReferenceIntenrne;
                query.First().Designation = productDesignation;
                query.First().Remarks = productRemarks;
                query.First().productType = productType;
                _gestionDb.SaveChanges();
                return "Mise à jour avec succés";
            }
            catch (Exception)
            {
                return "Errur";
            }
        }
Пример #28
0
 public void ResetUnitsOnOrder()
 {
     try
     {
         _gestionDb = new GcdbEntities();
         var listProduit = _gestionDb.Products;
         if (listProduit.Any())
         {
             foreach (Product produit in listProduit)
             {
                 produit.UnitsOnOrder = 0;
             }
         }
         _gestionDb.SaveChanges();
     }
     catch (Exception)
     {
        //
     }
 }
Пример #29
0
        public String MajProduct(Product p)
        {
            _gestionDb = new GcdbEntities();

            if (!IsProductExist(p)) return "Produit n'existante pas";

            Product prod = _gestionDb.Products.Where(produit => produit.ProductName.Equals(p.ProductName)).ToList().First();
               // prod = p;
              // to updated
            _gestionDb.SaveChanges();

            return "Produit modifier avec succes";
        }
Пример #30
0
        public String DelUser(Password pass)
        {
            _gestionDb = new GcdbEntities();
            if (!IsUserExist(pass)) return "Utilisateur n'existante pas";
            var user = _gestionDb.Passwords.Where(pw => pw.Login.StartsWith(pass.Login));
            int i = user.Count();
            if (user.Any())
            {
                foreach (Password usr in user)
                {
                    _gestionDb.Passwords.Remove(usr);
                }
            }
            _gestionDb.SaveChanges();

            return "Utilisateur supprimer avec succes";
        }