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";
     }
 }
        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";
            }
        }
 internal string GetMeasureById(int? measureId)
 {
     _gestionDb = new GcdbEntities();
     var query = from t in _gestionDb.ProductMeasures
                 where t.ProMeasureID == measureId
         select t;
     return query.Any() ? query.First().ProMeasureUnit : "";
 }
 public List<string> GetMeasureList()
 {
     _gestionDb = new GcdbEntities();
     var query = from t in _gestionDb.ProductMeasures
                 orderby t.ProMeasureUnit ascending
                 select t.ProMeasureUnit;
     return query.Any() ? query.ToList() : null;
 }
        public String DesactivateEmployee(Employee emp)
        {
            _gestionDb = new GcdbEntities();

            emp.Status = 1;
            MajEmployee(emp);

            return "Employee désactiver avec succes";
        }
        public String DesactivatePurchase(Purchase purchase)
        {
            _gestionDb = new GcdbEntities();

            purchase.Status = 1;
            MajPurchase(purchase);

            return "Achat désactiver 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 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";
        }
        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";
        }
        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 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";
        }
 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 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 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";
        }
示例#17
0
        public static bool IsTvaExist(double tva)
        {
            GcdbEntities gestionDb = new GcdbEntities();
            double tvva = tva;
            var requete = from t in gestionDb.TVAs
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                          where t.TauxTVA == tvva
                          select t;

            return requete.Any();
        }
 public String DesactivateCustomer(Customer cust)
 {
     _gestionDb = new GcdbEntities();
     var query = from t in _gestionDb.Customers
         where t.CustomerID == cust.CustomerID
         select t;
     if (!query.Any()) return "Erreur";
     query.First().Status = 1;
     _gestionDb.SaveChanges();
     return "Client désactivé avec succes";
 }
        public void AddMeasure(string name)
        {
            _gestionDb = new GcdbEntities();
            var theMeasure = new ProductMeasure
            {

                ProMeasureUnit = name
            };
            _gestionDb.ProductMeasures.Add(theMeasure);
            _gestionDb.SaveChanges();
        }
        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";
        }
        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";
        }
        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 Order GetOrderById(int id)
        {
            try
            {
                _gestionDb = new GcdbEntities();
                return _gestionDb.Orders.Single(o => o.OrderID == id);
            }
            catch (Exception)
            {

                return null;
            }
        }
        public int GetLastOrder(Order ordre)
        {
            try
            {
                _gestionDb = new GcdbEntities();
                return _gestionDb.Orders.ToList().Last().OrderID;
            }
            catch (Exception)
            {

                return -1;
            }
        }
        public List<Order> GetOrder()
        {
            try
            {
                 _gestionDb = new GcdbEntities();

                return _gestionDb.Orders.Where(c => c.Status == 0).ToList();
            }
            catch (Exception)
            {
                return null;
            }
        }
        public int GetCountOrder()
        {
            try
            {
                _gestionDb = new GcdbEntities();

                return _gestionDb.Orders.ToList().Count;
            }
            catch (Exception)
            {
                return 0;
            }
        }
        public Facture GetFactureByOrdre(Order ordre)
        {
            try
            {
                _gestionDb = new GcdbEntities();

                return _gestionDb.Factures.First(fact => fact.OrdresID == ordre.OrderID);
            }
            catch (Exception)
            {
                return null;
            }
        }
        public List<OrderDetail> GetOrderDetails()
        {
            try
            {
                 _gestionDb = new GcdbEntities();

                return _gestionDb.OrderDetails.ToList();
            }
            catch (Exception)
            {
                return null;
            }
        }
        public List<OrderDetail> GetOrderDetailsByOrder(Order ordre)
        {
            try
            {
                _gestionDb = new GcdbEntities();
                return _gestionDb.OrderDetails.Where(od => (od.OrderID == ordre.OrderID)).ToList();
            }
            catch (Exception)
            {

                return null;
            }
        }
        public OrderDetail GetOrderDetailsById(int IDOrder, int IDProduct)
        {
            try
            {
                _gestionDb = new GcdbEntities();
                return _gestionDb.OrderDetails.Single(od => (od.OrderID == IDOrder)&&(od.ProductID == IDProduct) );
            }
            catch (Exception)
            {

                return null;
            }
        }