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 Product GetProduct(int Id) { erp_dataEntities2 db = new erp_dataEntities2(); Product P = db.Products.Where(x => x.Id == Id).FirstOrDefault(); return(P); }
public static void Remove(Product P) { erp_dataEntities2 db = new erp_dataEntities2(); db.Products.Remove(P); 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(); }
public static List <VME> GetProductBusiness(DateTime fromdate, DateTime todate, string reference) { List <VME> BusinessList = new List <VME>(); erp_dataEntities2 db = new erp_dataEntities2(); var list = (from n in db.Invoices join c in db.InvoiceItems on n.Id equals c.IdInvoice join cl in db.Clients on n.IdClient equals cl.Id where (n.CreationDate >= fromdate) where (n.CreationDate < todate) where c.Code == reference group c by cl.Title into g select new { quantity = g.Sum(c => c.quantity), Client_Title = g.Key }).ToList(); foreach (var item in list) { Client client = UsersManager.GetClientByTitle(item.Client_Title); VME vme = new VM.VME() { quantity = item.quantity, ClientTitle = item.Client_Title, code = reference, color = client.Color }; BusinessList.Add(vme); } return(BusinessList); }
public static void AddClient(Client client) { erp_dataEntities2 db = new erp_dataEntities2(); db.Clients.Add(client); db.SaveChanges(); }
public static List <string> VerifyAvailability(string Title, int quantity) { erp_dataEntities2 db = new erp_dataEntities2(); List <string> ListError = new List <string> (); Product P = db.Products.Where(x => x.Title == Title).FirstOrDefault(); if (P != null) { #region verify quantity if (quantity > 0 && P.Amount < quantity) { if (!ListError.Contains(ErrorManager.Quantity_Product_NOT_AVAILABLE)) { ListError.Add(ErrorManager.Quantity_Product_NOT_AVAILABLE); } } if (P.Amount <= 0) { ListError.Add(ErrorManager.Quantity_Product_NOT_AVAILABLE); } #endregion } else { ListError.Add(ErrorManager.PRODUCT_NOT_FOUND); } #region verify unavailabitity period #endregion return(ListError); }
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 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 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(); }
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(); }
public static bool ExistingProduct(Product P) { bool IsExist = false; erp_dataEntities2 db = new erp_dataEntities2(); IsExist = db.Products.Where(x => x.Title == P.Title || x.Code == P.Code).ToList().Count() > 0; return(IsExist); }
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(); }
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 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(); }
public static int getCommandNumber() { erp_dataEntities2 db = new erp_dataEntities2(); DateTime date = DateTime.Now; date = date.AddDays(-1); return(db.Invoices.Where(x => x.CreationDate > date && x.type == 2).ToList().Count); }
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(); }
public static List <VM.VMFD> getListVMFD(int number) { erp_dataEntities2 db = new erp_dataEntities2(); List <VMFD> list = new List <VMFD>(); var AA = (from n in db.Invoices join c in db.Clients on n.IdClient equals c.Id select new { Number = n.Id, CreationDate = n.CreationDate, TotalPrice = n.TotalPrice, Client_Title = c.Title, status = n.status, PaymentType = n.PaymentType, type = n.type, ExpirationDate = n.ExpirationDate }).OrderByDescending(x => x.CreationDate).ToList(); for (int i = 0; i < AA.Count - 1; i++) { VMFD vmfd = new VMFD() { Id = AA[i].Number.ToString(), CreationDate = AA[i].CreationDate, TotalPrice = AA[i].TotalPrice + " DT", Client_Title = AA[i].Client_Title, status = AA[i].status, PaymentType = AA[i].PaymentType, type = AA[i].type, ExpirationDate = AA[i].ExpirationDate }; switch (number) { case 1: if (vmfd.type == 0) { list.Add(vmfd); } break; case 2: if (vmfd.type == 1) { list.Add(vmfd); } break; case 3: list.Add(vmfd); break; } } return(list); }
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; }
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(); } }
public static int Getinvoice_Identity() { int intResult = 0; erp_dataEntities2 db = new erp_dataEntities2(); List <Invoice> list = db.Invoices.OrderByDescending(x => x.Id).ToList(); if (list.Count == 0) { intResult = 1; } else { intResult = list[0].Id + 1; } return(intResult); }
public static List <VME> GetList_Products(DateTime date, string Ref) { erp_dataEntities2 db = new erp_dataEntities2(); List <Invoice> liste = db.Invoices./*Where(x => x.CreationDate >= DateTime.Now.AddDays(-10)).*/ ToList(); var AA = (from n in db.Invoices join c in db.InvoiceItems on n.Id equals c.IdInvoice where c.Code == Ref select new { code = c.Code, CreationDate = n.CreationDate, quantity = c.quantity }).Take(10).ToList(); List <VME> list = new List <VME>(); List <string> ss = new List <string>(); for (int i = 0; i < AA.Count - 1; i++) { int sum = 0; for (int j = i; j < AA.Count; j++) { if (AA[i].CreationDate.ToShortDateString() == AA[j].CreationDate.ToShortDateString()) { sum += AA[i].quantity; } if (!ss.Contains(AA[i].CreationDate.ToShortDateString())) { ss.Add(AA[i].CreationDate.ToShortDateString()); VME vme = new VME() { code = AA[i].code, date = AA[i].CreationDate, quantity = sum }; list.Add(vme); } } } return(list); }
public static VMProduct GetVMProduct(Product P) { if (P.IdCategory != null && P.IdSupplier != null) { erp_dataEntities2 db = new erp_dataEntities2(); VMProduct VMP = new VMProduct(); decimal decId = Convert.ToDecimal(P.IdCategory); VMP.Category = db.Categories.Where(x => x.Id == decId).FirstOrDefault().Title; VMP.Supplier = db.Suppliers.Where(x => x.Id == P.IdSupplier).FirstOrDefault().Title; VMP.LastUpdateDate = P.LastUpdateDate; VMP.Price = P.Price; VMP.Title = P.Title; VMP.Code = P.Code; VMP.Id = P.Id; VMP.Amount = P.Amount; return(VMP); } return(null); }
public static List <VMInvoiceItem> AddProductToInvoice(string Title, int Amount, List <VMInvoiceItem> List) { erp_dataEntities2 db = new erp_dataEntities2(); Product P = db.Products.Where(x => x.Title == Title).FirstOrDefault(); VMInvoiceItem I = new VMInvoiceItem() { Reference = P.Code, Title = P.Title, UnitPrice = P.Price, TotalPrice = Amount * P.Price, TVA = 17, Quantity = Amount }; if (List.Where(x => x.Reference == I.Reference).FirstOrDefault() == null) { List.Add(I); } return(List); }
public static List <Invoice> GetInvoicesList(int Number) { erp_dataEntities2 db = new erp_dataEntities2(); switch (Number) { case 1: return(db.Invoices.Where(x => x.type == 1).OrderByDescending(x => x.CreationDate).ToList()); break; case 2: return(db.Invoices.Where(x => x.type == 0).OrderByDescending(x => x.CreationDate).ToList()); break; case 3: return(db.Invoices.OrderByDescending(x => x.CreationDate).ToList()); break; } return(null); }
public static List <VMProduct> GetListVMProducts(List <Product> list) { erp_dataEntities2 db = new erp_dataEntities2(); List <Product> CurrentList = new List <Product>(); List <VMProduct> ListVM = new List <VMProduct>(); if (list != null) { CurrentList = list; } else { CurrentList = db.Products.ToList(); } foreach (Product P in CurrentList) { if (P.IdCategory != null && P.IdSupplier != null) { VMProduct VMP = new VMProduct(); decimal decId = Convert.ToDecimal(P.IdCategory); VMP.Category = db.Categories.Where(x => x.Id == decId).FirstOrDefault().Title; VMP.Supplier = db.Suppliers.Where(x => x.Id == P.IdSupplier).FirstOrDefault().Title; VMP.LastUpdateDate = P.LastUpdateDate; VMP.Price = P.Price; VMP.Title = P.Title; VMP.Code = P.Code; VMP.Id = P.Id; VMP.Amount = P.Amount; ListVM.Add(VMP); } } return(ListVM); }
public static List <VME> GetBusinessNumber(string strDate) { DateTime date = Convert.ToDateTime(strDate); List <VME> BusinessList = new List <VME>(); for (int i = 1; i < 12; i++) { DateTime dateIn = date.AddDays(30 * (i - 1)); DateTime dateout = date.AddDays(30 * (i)); erp_dataEntities2 db = new erp_dataEntities2(); var BN = (from n in db.Invoices where (n.CreationDate >= dateIn) where (n.CreationDate < dateout) select new { BusinessNumber = n.TotalPrice }).Sum(x => x.BusinessNumber); decimal decBusinessNumber = 0; if (BN != null) { decBusinessNumber = Convert.ToDecimal(BN); } VME vme = new VM.VME() { BusinessNumber = decBusinessNumber }; BusinessList.Add(vme); } return(BusinessList); }
public static List <InvoiceItem> GetListInvoiceItems(int Id) { erp_dataEntities2 db = new erp_dataEntities2(); return(db.InvoiceItems.Where(x => x.IdInvoice == Id).ToList()); }
public static Invoice GetInvoice(int Id) { erp_dataEntities2 db = new erp_dataEntities2(); return(db.Invoices.Where(x => x.Id == Id).FirstOrDefault()); }