public int Save(SupplierBrand SupplierBrand) { bool _isNew = true; SupplierBrand _dbEntry; if (SupplierBrand.SupplierBrandID == 0) { _dbEntry = Query(SupplierBrand.SupplierID, SupplierBrand.BrandID); if (_dbEntry == null) { _context.SupplierBrands.Add(SupplierBrand); } else { return(_dbEntry.SupplierBrandID); } } else { _dbEntry = _context.SupplierBrands.Find(SupplierBrand.SupplierBrandID); if (_dbEntry != null) { _dbEntry.SupplierID = SupplierBrand.SupplierID; _dbEntry.BrandID = SupplierBrand.BrandID; } else { SupplierBrand.SupplierBrandID = 0; _context.SupplierBrands.Add(SupplierBrand); } } _context.SaveChanges(); return(SupplierBrand.SupplierBrandID); }
public static SelectList BrandList() { Session ds = new SessionFactory().OpenSession(); IList<SupplierBrand> d = ds.Find<SupplierBrand>(); var item = new SupplierBrand {Id = 0, Brand = "无"}; d.Add(item); return new SelectList(d, "Id", "Brand"); }
public SupplierBrand Query(int SupplierID, int BrandID) { SupplierBrand _data = _context.SupplierBrands .Where(s => s.BrandID == BrandID) .Where(s => s.SupplierID == SupplierID) .Where(s => s.Enabled == true).FirstOrDefault(); return(_data); }
public void Delete(int SupplierBrandID) { SupplierBrand _dbEntry = _context.SupplierBrands.Find(SupplierBrandID); if (_dbEntry != null) { _dbEntry.Enabled = false; _context.SaveChanges(); } }
public void Delete(int SupplierID, int BrandID) { SupplierBrand _dbEntry = _context.SupplierBrands.Where(s => s.SupplierID == SupplierID) .Where(s => s.BrandID == BrandID) .Where(s => s.Enabled == true).FirstOrDefault(); if (_dbEntry != null) { _dbEntry.Enabled = false; _context.SaveChanges(); } }
public void LoadSupplierBrand(string brandname, int pstateid, int active) { SupplierBrand s; SQSSupplierBrand.Clear(); client = new SQSAdminServiceClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(CommonVariables.WcfEndpoint); DataSet ds = client.SQSAdmin_StudioM_GetSupplierBrand(brandname, pstateid, active); client.Close(); foreach (DataRow dr in ds.Tables[0].Rows) { s = new SupplierBrand(); s.SupplierBrandID = int.Parse(dr["id_studiom_supplierbrand"].ToString()); s.SupplierBrandName = dr["supplierbrandname"].ToString(); s.Active = bool.Parse(dr["active"].ToString()); s.BrandStateID = int.Parse(dr["fkidstate"].ToString()); s.BrandStateName = dr["stateAbbreviation"].ToString(); SQSSupplierBrand.Add(s); } }