public Customer GetCustomerByCustomerCode(string customerCode)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         return ctx.Customer.FirstOrDefault(P => P.CustomerCode == customerCode);
     }
 }
 public Supplier GetSupplierById(int id)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         return ctx.Supplier.FirstOrDefault(P => P.Id == id);
     }
 }
 public Pattern GetPatternByPatternCode(string patternCode)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         return ctx.Pattern.FirstOrDefault(P => P.PatternCode == patternCode);
     }
 }
 public Material GetMaterialById(int id)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         return ctx.Material.FirstOrDefault(P => P.Id == id);
     }
 }
 public Pattern GetPatternById(int id)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         return ctx.Pattern.FirstOrDefault(P => P.Id == id);
     }
 }
 public Supplier GetSupplierBySupplierCode(string supplierCode)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         return ctx.Supplier.FirstOrDefault(P => P.SupplierCode == supplierCode);
     }
 }
 public Material GetMaterialByMaterialCode(string materialCode)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         return ctx.Material.FirstOrDefault(P => P.MaterialCode == materialCode);
     }
 }
Ejemplo n.º 8
0
 public void LoadProductGroupName(int groupId)
 {
     using (InventorySystemMaintenanceEntities ctx = new InventorySystemMaintenanceEntities())
     {
         if (groupId != 0)
         {
             ProductGroupName = ctx.ProductGroup.FirstOrDefault(P => P.Id == groupId).Name;
         }
     }
 }
 public List<Pattern> GetPatterns()
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         var q = from x in ctx.Pattern
                 select x;
         q = q.OrderBy(P => P.PatternCode);
         return q.ToList();
     }
 }
 public List<Supplier> GetSuppliers()
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         var q = from x in ctx.Supplier
                 select x;
         q = q.OrderBy(P => P.Name);
         return q.ToList();
     }
 }
 public List<Material> GetMaterials()
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         var q = from x in ctx.Material
                 select x;
         q = q.OrderBy(P => P.Name);
         return q.ToList();
     }
 }
Ejemplo n.º 12
0
 public void LoadSupplier(int supplierId)
 {
     using (InventorySystemMaintenanceEntities ctx = new InventorySystemMaintenanceEntities())
     {
         if (supplierId != 0)
         {
             SupplierName = ctx.Supplier.FirstOrDefault(P => P.Id == supplierId).Name;
         }
     }
 }
Ejemplo n.º 13
0
 public void LoadCustomer(int customerId)
 {
     using (InventorySystemMaintenanceEntities ctx = new InventorySystemMaintenanceEntities())
     {
         if (customerId!= 0)
         {
             CustomerName = ctx.Customer.FirstOrDefault(P => P.Id == customerId).Name;
         }
     }
 }
Ejemplo n.º 14
0
 public List<Pattern> GetFilteredPatterns(string patternCode)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         IQueryable<Pattern> query = ctx.Pattern.AsQueryable();
         if (!String.IsNullOrEmpty(patternCode))
         {
             query = query.Where(P => P.PatternCode.Contains(patternCode));
         }
         return query.OrderBy(P => P.Id).ToList();
     }
 }
 public void Delete(int? id)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         if (id != null)
         {
             var item = ctx.Material.FirstOrDefault(P => P.Id == id);
             ctx.DeleteObject(item);
             ctx.SaveChanges();
         }
     }
 }
 public void Delete(int? id)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         if (id != null)
         {
             var item = ctx.Supplier.FirstOrDefault(P => P.Id == id);
             ctx.Entry(item).State = System.Data.EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
 }
 public Material Insert(string materialCode, string name, string description
     , decimal? pricePerUnit, string attachment, DateTime? dateCreated
     , DateTime? dateModified, string createdBy, string modifiedBy)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         Material item = new Material();
         if (!String.IsNullOrEmpty(materialCode))
         {
             item.MaterialCode = materialCode;
         }
         if (!String.IsNullOrEmpty(name))
         {
             item.Name = name;
         }
         if (!String.IsNullOrEmpty(description))
         {
             item.Description = description;
         }
         if (pricePerUnit != null)
         {
             item.PricePerUnit = pricePerUnit;
         }
         if (!String.IsNullOrEmpty(attachment))
         {
             item.Attachment = attachment;
         }
         if (dateCreated != null)
         {
             item.DateCreated = dateCreated;
         }
         if (dateModified != null)
         {
             item.DateModified = dateModified;
         }
         if (!String.IsNullOrEmpty(createdBy))
         {
             item.CreatedBy = createdBy;
         }
         if (!String.IsNullOrEmpty(modifiedBy))
         {
             item.ModifiedBy = modifiedBy;
         }
         ctx.AddToMaterial(item);
         ctx.SaveChanges();
         return item;
     }
 }
 public List<Material> GetFilteredMaterials(string code, string name)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         IQueryable<Material> query = ctx.Material.AsQueryable();
         if (!String.IsNullOrEmpty(code))
         {
             query = query.Where(P => P.MaterialCode.Contains(code));
         }
         if (!String.IsNullOrEmpty(name))
         {
             query = query.Where(P => P.Name.Contains(name));
         }
         return query.OrderBy(P => P.Name).ToList();
     }
 }
Ejemplo n.º 19
0
        public List<Product> GetFilteredProducts(string productCode, string productName, int productGroup, int customer, int supplier)
        {
            using (var ctx = new InventorySystemMaintenanceEntities())
            {
                IQueryable<Product> query = ctx.Product.AsQueryable();
                if (!String.IsNullOrEmpty(productCode))
                {
                    query = query.Where(P => P.ProductCode.Contains(productCode));
                }
                if (!String.IsNullOrEmpty(productName))
                {
                    query = query.Where(P => P.Name.Contains(productName));
                }
                if (productGroup!= 0)
                {
                    query = query.Where(P => P.ProductGroupId == productGroup);
                }
                if (customer != 0)
                {
                    query = query.Where(P => P.CustomerId == customer);
                }
                if (supplier != 0)
                {
                    query = query.Where(P => P.SupplierId == 0);
                }
                foreach (Product product in query)
                {
                    if (product.CustomerId.HasValue)
                    {
                        product.LoadCustomer(product.CustomerId.Value);
                    }

                    if (product.SupplierId.HasValue)
                    {
                        product.LoadSupplier(product.SupplierId.Value);
                    }

                    if (product.ProductGroupId.HasValue)
                    {
                        product.LoadProductGroupName(product.ProductGroupId.Value);
                    }
                }
                return query.OrderBy(P => P.Name).ToList();
            }
        }
 public List<Supplier> GetFilteredSuppliers(string supplierCode, string name, string email)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         IQueryable<Supplier> query = ctx.Supplier.AsQueryable();
         if (!String.IsNullOrEmpty(supplierCode))
         {
             query = query.Where(P => P.SupplierCode.Contains(supplierCode));
         }
         if (!String.IsNullOrEmpty(name))
         {
             query = query.Where(P => P.Name.Contains(name));
         }
         if (!String.IsNullOrEmpty(email))
         {
             query = query.Where(P => P.Email.Contains(email));
         }
         return query.OrderBy(P => P.Name).ToList();
     }
 }
 public Customer Update(int id, string customerCode, string name, string company
     , string phoneNo, string fax, string email, string address, string postcode
     , string state, string country, string website, DateTime? dateCreated
     , DateTime? dateModified, string createdBy, string modifiedBy, string remarks)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         Customer item = ctx.Customer.FirstOrDefault(P => P.Id == id);
         if (!String.IsNullOrEmpty(customerCode))
         {
             item.CustomerCode = customerCode;
         }
         if (!String.IsNullOrEmpty(name))
         {
             item.Name = name;
         }
         if (!String.IsNullOrEmpty(company))
         {
             item.Company = company;
         }
         if (!String.IsNullOrEmpty(phoneNo))
         {
             item.PhoneNo = phoneNo;
         }
         if (!String.IsNullOrEmpty(fax))
         {
             item.Fax = fax;
         }
         if (!String.IsNullOrEmpty(email))
         {
             item.Email = email;
         }
         if (!String.IsNullOrEmpty(address))
         {
             item.Address = address;
         }
         if (!String.IsNullOrEmpty(postcode))
         {
             item.Postcode = postcode;
         }
         if (!String.IsNullOrEmpty(state))
         {
             item.State = state;
         }
         if (!String.IsNullOrEmpty(country))
         {
             item.Country = country;
         }
         if (!String.IsNullOrEmpty(website))
         {
             item.Website = website;
         }
         if (dateCreated != null)
         {
             item.DateCreated = dateCreated;
         }
         if (dateModified != null)
         {
             item.DateModified = dateModified;
         }
         if (!String.IsNullOrEmpty(createdBy))
         {
             item.CreatedBy = createdBy;
         }
         if (!String.IsNullOrEmpty(modifiedBy))
         {
             item.ModifiedBy = modifiedBy;
         }
         if (!String.IsNullOrEmpty(remarks))
         {
             item.Remarks = remarks;
         }
         ctx.SaveChanges();
         return item;
     }
 }
Ejemplo n.º 22
0
 public List<Product> GetProducts()
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         var q = from x in ctx.Product
                 select x;
         q = q.OrderBy(P => P.Name);
         return q.ToList();
     }
 }
Ejemplo n.º 23
0
 public Product Update(int id, string productCode, int? productGroupId, int? customerId,
     int? supplierId, string name, string description, decimal? weight, string image,
     decimal? outerDiameter, decimal? innerDiameter, decimal? height, decimal? width,
     decimal? length, DateTime? dateCreated, DateTime? dateModified, string createdBy,
     string modifiedBy, string remarks)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         Product item = ctx.Product.FirstOrDefault(P => P.Id == id);
         if (!String.IsNullOrEmpty(productCode))
         {
             item.ProductCode = productCode;
         }
         if (CheckNull(productGroupId))
         {
             item.ProductGroupId = productGroupId;
         }
         if (CheckNull(customerId))
         {
             item.CustomerId = customerId;
         }
         if (CheckNull(supplierId))
         {
             item.SupplierId = supplierId;
         }
         if (!String.IsNullOrEmpty(name))
         {
             item.Name = name;
         }
         if (!String.IsNullOrEmpty(description))
         {
             item.Description = description;
         }
         if (CheckNull(weight))
         {
             item.Weight = weight;
         }
         if (!String.IsNullOrEmpty(image))
         {
             item.Image = image;
         }
         if (CheckNull(outerDiameter))
         {
             item.OuterDiameter = outerDiameter;
         }
         if (CheckNull(innerDiameter))
         {
             item.InnerDiameter = innerDiameter;
         }
         if (CheckNull(height))
         {
             item.Height = height;
         }
         if (CheckNull(width))
         {
             item.Width = width;
         }
         if (CheckNull(length))
         {
             item.Length = length;
         }
         if (CheckNull(dateCreated))
         {
             item.DateCreated = dateCreated;
         }
         if (CheckNull(dateModified))
         {
             item.DateModified = dateModified;
         }
         if (!String.IsNullOrEmpty(createdBy))
         {
             item.CreatedBy = createdBy;
         }
         if (!String.IsNullOrEmpty(modifiedBy))
         {
             item.ModifiedBy = modifiedBy;
         }
         if (!String.IsNullOrEmpty(remarks))
         {
             item.Remarks = remarks;
         }
         ctx.SaveChanges();
         return item;
     }
 }
Ejemplo n.º 24
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_context != null)
         {
             _context.Dispose();
             _context = null;
         }
     }
 }
        public void UpdateAttachment(int? id,string attachment)
        {
            using (var ctx = new InventorySystemMaintenanceEntities())
            {
                if (id != null)
                {
                    var item = ctx.Material.FirstOrDefault(P => P.Id == id.Value);
                    item.Attachment = attachment;
                    ctx.SaveChanges();
                }

            }
        }
 public Supplier Insert(string supplierCode, string name, string company
     , string phoneNo, string fax, string email, string address, string postcode
     , string state, string country, string website, DateTime? dateCreated
     , DateTime? dateModified, string createdBy, string modifiedBy, string remarks)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         Supplier item = new Supplier();
         if (!String.IsNullOrEmpty(supplierCode))
         {
             item.SupplierCode = supplierCode;
         }
         if (!String.IsNullOrEmpty(name))
         {
             item.Name = name;
         }
         if (!String.IsNullOrEmpty(company))
         {
             item.Company = company;
         }
         if (!String.IsNullOrEmpty(phoneNo))
         {
             item.PhoneNo = phoneNo;
         }
         if (!String.IsNullOrEmpty(fax))
         {
             item.Fax = fax;
         }
         if (!String.IsNullOrEmpty(email))
         {
             item.Email = email;
         }
         if (!String.IsNullOrEmpty(address))
         {
             item.Address = address;
         }
         if (!String.IsNullOrEmpty(postcode))
         {
             item.Postcode = postcode;
         }
         if (!String.IsNullOrEmpty(state))
         {
             item.State = state;
         }
         if (!String.IsNullOrEmpty(country))
         {
             item.Country = country;
         }
         if (!String.IsNullOrEmpty(website))
         {
             item.Website = website;
         }
         if (dateCreated != null)
         {
             item.DateCreated = dateCreated;
         }
         if (dateModified != null)
         {
             item.DateModified = dateModified;
         }
         if (!String.IsNullOrEmpty(createdBy))
         {
             item.CreatedBy = createdBy;
         }
         if (!String.IsNullOrEmpty(modifiedBy))
         {
             item.ModifiedBy = modifiedBy;
         }
         if (!String.IsNullOrEmpty(remarks))
         {
             item.Remarks = remarks;
         }
         ctx.Entry(item).State = System.Data.EntityState.Added;
         ctx.SaveChanges();
         return item;
     }
 }
Ejemplo n.º 27
0
 public Product GetProductById(int id)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         return ctx.Product.FirstOrDefault(P => P.Id == id);
     }
 }
Ejemplo n.º 28
0
 public Product GetProductByProductCode(string productCode)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         if (!String.IsNullOrEmpty(productCode))
         {
             return ctx.Product.FirstOrDefault(P => P.ProductCode == productCode);
         }
         return null;
     }
 }
Ejemplo n.º 29
0
 public Pattern Insert(int? supplierId, string patternCode, string patternMaker,
     decimal? price, decimal? outerDiameter, decimal? innerDiameter, decimal? height,
     decimal? width, decimal? length, string modificationRemarks, DateTime? dateCreated,
     DateTime? dateModified, string createdBy, string modifiedBy, string remarks)
 {
     using (var ctx = new InventorySystemMaintenanceEntities())
     {
         Pattern item = new Pattern();
         if (supplierId != null)
         {
             item.SupplierId = supplierId;
         }
         if (!String.IsNullOrEmpty(patternCode))
         {
             item.PatternCode = patternCode;
         }
         if (!String.IsNullOrEmpty(patternMaker))
         {
             item.PatternMaker = patternMaker;
         }
         if (outerDiameter != null)
         {
             item.OuterDiameter = outerDiameter;
         }
         if (innerDiameter != null)
         {
             item.InnerDiameter = innerDiameter;
         }
         if (height != null)
         {
             item.Height = height;
         }
         if (width != null)
         {
             item.Width = width;
         }
         if (length != null)
         {
             item.Length = length;
         }
         if (!String.IsNullOrEmpty(modificationRemarks))
         {
             item.ModificationRemarks = modificationRemarks;
         }
         if (dateCreated != null)
         {
             item.DateCreated = dateCreated;
         }
         if (dateModified != null)
         {
             item.DateModified = dateModified;
         }
         if (!String.IsNullOrEmpty(createdBy))
         {
             item.CreatedBy = createdBy;
         }
         if (!String.IsNullOrEmpty(modifiedBy))
         {
             item.ModifiedBy = modifiedBy;
         }
         if (!String.IsNullOrEmpty(remarks))
         {
             item.Remarks = remarks;
         }
         ctx.AddToPattern(item);
         ctx.SaveChanges();
         return item;
     }
 }