public static void AddClient(Client client)
        {
            erp_dataEntities2 db = new erp_dataEntities2();

            db.Clients.Add(client);
            db.SaveChanges();
        }
        public static void AddInvoiceItems(List <VMInvoiceItem> ListItems, int RefInvoice, bool IsInvoice)
        {
            erp_dataEntities2 db = new erp_dataEntities2();

            foreach (VMInvoiceItem item in ListItems)
            {
                InvoiceItem IvItem = new InvoiceItem()
                {
                    Code         = item.Reference,
                    IdInvoice    = RefInvoice,
                    quantity     = item.Quantity,
                    TotalPrice   = Convert.ToDecimal(item.TotalPrice),
                    totalPriceHT = Convert.ToDecimal((item.UnitPrice * item.Quantity) * item.Quantity),
                    totalTVA     = Convert.ToDecimal((item.TVA * item.Quantity)),
                    UnitPriceHT  = Convert.ToDecimal(item.UnitPrice * item.Quantity)
                };

                if (IsInvoice)
                {
                    Product P = db.Products.Where(x => x.Code == item.Reference).FirstOrDefault();
                    P.Amount = P.Amount - item.Quantity;
                    ProductsManager.Update(P);
                }
                db.InvoiceItems.Add(IvItem);
                db.SaveChanges();
            }
        }
        public static void UpdateSupplier(Supplier S)
        {
            erp_dataEntities2 db = new erp_dataEntities2();

            db.Entry(S).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
        public static void AddSupplier(Supplier supplier)
        {
            erp_dataEntities2 db = new erp_dataEntities2();

            db.Suppliers.Add(supplier);
            db.SaveChanges();
        }
        public static void UpdateClient(Client C)
        {
            erp_dataEntities2 db = new erp_dataEntities2();

            db.Entry(C).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
        public static void UpdateAdministrator(User us)
        {
            erp_dataEntities2 db = new erp_dataEntities2();

            db.Entry(us).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Exemple #7
0
        public static void Remove(Product P)
        {
            erp_dataEntities2 db = new erp_dataEntities2();

            db.Products.Remove(P);
            db.SaveChanges();
        }
        public static void RemoveSupplier(int Id)
        {
            erp_dataEntities2 db       = new erp_dataEntities2();
            Supplier          supplier = db.Suppliers.Where(x => x.Id == Id).FirstOrDefault();

            db.Suppliers.Remove(supplier);
            db.SaveChanges();
        }
Exemple #9
0
        public static void Update(Product P)
        {
            P.LastUpdateDate = DateTime.Now;
            erp_dataEntities2 db = new erp_dataEntities2();

            db.Entry(P).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Exemple #10
0
        public static void Remove(int Id)
        {
            erp_dataEntities2 db = new erp_dataEntities2();
            Product           P  = db.Products.Where(x => x.Id == Id).FirstOrDefault();

            db.Products.Remove(P);
            db.SaveChanges();
        }
Exemple #11
0
        public static void UpdateSupplier_state(int Id, int state)
        {
            erp_dataEntities2 db = new erp_dataEntities2();
            Supplier          S  = db.Suppliers.Where(x => x.Id == Id).FirstOrDefault();

            S.State           = state;
            db.Entry(S).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Exemple #12
0
        public static void UpdateClient_state(int Id, int state)
        {
            erp_dataEntities2 db = new erp_dataEntities2();
            Client            C  = db.Clients.Where(x => x.Id == Id).FirstOrDefault();

            C.state           = state;
            db.Entry(C).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Exemple #13
0
        public static void AddProduct(Product P)
        {
            P.LastUpdateDate = DateTime.Now;

            erp_dataEntities2 db = new erp_dataEntities2();

            db.Products.Add(P);
            db.SaveChanges();
        }
        public static void AddInvoice(Invoice invoice, out int RefInvoice)
        {
            RefInvoice = 0;
            erp_dataEntities2 db = new erp_dataEntities2();

            db.Invoices.Add(invoice);
            db.SaveChanges();

            RefInvoice = invoice.Id;
        }
Exemple #15
0
        public static void Remove(int Id)
        {
            erp_dataEntities2 db = new erp_dataEntities2();
            Client            C  = db.Clients.Where(x => x.Id == Id).FirstOrDefault();

            if (C != null)
            {
                db.Clients.Remove(C);
                db.SaveChanges();
            }
        }