private void Entity_Closed(object sender, EventArgs e) { if (this.Service.PCRoomManager != null) { this.Service.PCRoomManager.RemoveUser(this); } if (this.valid) { if (this.Service.NxIDToEntityDic.ContainsKey(this.NexonID)) { this.Service.NxIDToEntityDic.Remove(this.NexonID); } if (this.Service.SessionDic.ContainsKey(this.SessionNo)) { this.Service.SessionDic.Remove(this.SessionNo); } this.Service.Logout(this.SessionNo, this.NexonID, this.CharacterID, this.RemoteAddress, this.CanTry); this.ReportCafeAuthLogout(); } try { EntityDataContext entityDataContext = new EntityDataContext(); entityDataContext.AcquireService(new long?((sender as IEntity).ID), this.Service.Category, new int?(-1), new int?(this.Service.ID)); } catch (Exception ex) { Log <CafeAuth> .Logger.ErrorFormat("Entity_Closed [EntityID : {0}] [ServiceID : {1}] [Category : {2}] - {3} ", new object[] { (sender as IEntity).ID, this.Service.ID, this.Service.Category, ex }); } }
public static FileViewModel GetMainDetails(int?FileId) { using (EntityDataContext context = new EntityDataContext()) { FileViewModel entity = new FileViewModel(); try { entity = (from file in context.SYS_tblFile join folder in context.SYS_tblFolder on file.FolderId equals folder.FolderId where file.FileId == FileId select new FileViewModel() { FileId = file.FileId, FileTitle = file.FileTitle, FileName = file.FileName, FileDescription = file.FileDescription, FileContent = file.FileContent, Extension = file.Extension, ContentType = file.ContentType, FolderId = file.FolderId, FileUrl = folder.FolderPath + "/" + file.FileName, Size = file.Size, Width = file.Width, Height = file.Height, FolderKey = folder.FolderKey, FolderPath = folder.FolderPath }).FirstOrDefault(); } catch (Exception ex) { ex.ToString(); } return(entity); } }
private static void CreateData(ExcelWorksheet worksheet, ref int rowIndex, List <ProductModel> listProductTypeModel) { EntityDataContext _context = new EntityDataContext(); foreach (ProductModel p in listProductTypeModel) { worksheet.Cells[rowIndex, 1].Value = rowIndex - 4; worksheet.Cells[rowIndex, 2].Value = p.ProductId; worksheet.Cells[rowIndex, 3].Value = p.ProductCode; worksheet.Cells[rowIndex, 4].Value = p.ProductName; worksheet.Cells[rowIndex, 5].Value = p.ProductTypeId; worksheet.Cells[rowIndex, 6].Value = p.CategoryId; worksheet.Cells[rowIndex, 7].Value = p.OriginOfProductId; worksheet.Cells[rowIndex, 8].Value = p.PolicyInStockId; worksheet.Cells[rowIndex, 9].Value = p.PolicyOutOfStockId; worksheet.Cells[rowIndex, 10].Value = p.LocationOfProductId; worksheet.Cells[rowIndex, 11].Value = p.ProductStatusId; worksheet.Cells[rowIndex, 12].Value = p.ShippingWeight; worksheet.Cells[rowIndex, 13].Value = p.UnitId; worksheet.Cells[rowIndex, 14].Value = p.ImportPrice; worksheet.Cells[rowIndex, 15].Value = p.CurrencyId; worksheet.Cells[rowIndex, 16].Value = p.ExchangeRate; worksheet.Cells[rowIndex, 17].Value = p.ShippingFee; worksheet.Cells[rowIndex, 18].Value = p.COGS; worksheet.Cells[rowIndex, 19].Value = _context.ProductPriceModel.Where(pp => pp.ProductId == p.ProductId && pp.CustomerLevelId == 1).Select(c => c.Price).FirstOrDefault(); worksheet.Cells[rowIndex, 20].Value = _context.ProductPriceModel.Where(pp => pp.ProductId == p.ProductId && pp.CustomerLevelId == 2).Select(c => c.Price).FirstOrDefault(); worksheet.Cells[rowIndex, 21].Value = _context.ProductPriceModel.Where(pp => pp.ProductId == p.ProductId && pp.CustomerLevelId == 3).Select(c => c.Price).FirstOrDefault(); worksheet.Cells[rowIndex, 22].Value = p.BeginInventoryQty; worksheet.Cells[rowIndex, 23].Value = p.Actived; rowIndex++; } }
public IEnumerable <Product> FilterPrice(int?min, int?max) { EntityDataContext _context = new EntityDataContext(); var products = _context.Products.Where(p => p.Price >= min && p.Price <= max).ToList(); return(products); }
public IEnumerable <ProductsViewModel> GetCategoryWithBrand(string categoryCode, string supplierCode) { if (categoryCode == null || supplierCode == null) { List <ProductsViewModel> list = null; return(list); } using (EntityDataContext _context = new EntityDataContext()) { var sup = _context.Suppliers.Where(p => p.SupplierName.ToLower() == supplierCode).ToList(); var supItem = sup[0]; var list = (from p in _context.Products join c in _context.Categories on p.CategoryID equals c.CategoryID where c.CategoryCode == categoryCode && p.SupplierID == supItem.SupplierID select new ProductsViewModel { ProductID = p.ProductID, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage, CategoryName = c.CategoryName, CategoryID = p.CategoryID, CompanyID = p.CompanyID, SupplierID = p.SupplierID, CategoryCode = categoryCode }).ToList(); return(list); } }
public IEnumerable <SuppliersViewModel> GetSuppliers(string categoryCode) { using (EntityDataContext _context = new EntityDataContext()) { var category = _context.Categories.Where(n => n.CategoryCode == categoryCode).ToList(); var categoryID = category[0].CategoryId; var products = _context.Products.Where(p => p.CategoryId == categoryID).ToList(); var supplierIds = products.Select(n => n.SupplierId).Distinct().ToList(); var suppliersTemp = _context.Suppliers.Where(m => supplierIds.Contains(m.SupplierId)).ToList(); List <SuppliersViewModel> suppliers = new List <SuppliersViewModel>(); foreach (var supplier in suppliersTemp) { var totalProduct = _context.Products.Where(n => n.SupplierId == supplier.SupplierId).Count(); var temp = (from p in suppliersTemp where p.SupplierId == supplier.SupplierId select new SuppliersViewModel { SupplierName = p.SupplierName, SupplierID = p.SupplierId, CategoryCode = categoryCode, QuantityProduct = totalProduct }).ToList(); suppliers.AddRange(temp); } return(suppliers); } }
public async Task <IActionResult> GetProductByID(int id) { EntityDataContext _context = new EntityDataContext(); var product = _context.Products.Where(p => p.ProductId == id).ToList(); if (product.Count == 0) { return(NotFound()); } else { var companyID = product[0].CompanyId; var company = _context.Companies.Where(c => c.CompanyId == companyID).ToList(); var logo = company[0].CompanyImage; var list = _context.Products.AsNoTracking().Join(_context.Suppliers, p => p.SupplierId, s => s.SupplierId, (p, s) => new ProductsViewModel() { ProductID = p.ProductId, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage, CategoryID = p.CategoryId, SupplierID = p.SupplierId, CompanyID = p.CompanyId, SupplierName = s.SupplierName, CompanyImage = logo }).Where(p => p.ProductID == id).ToList(); return(new ObjectResult(list)); } }
/// <summary> /// Loads the object with the specified id from the context. /// Please note, that it's expected that the database connection is already established when calling this method. /// </summary> /// <typeparam name="T">The type of the <see cref="IIdentifiable"/> object.</typeparam> /// <param name="id">The identifier of the object which should be loaded.</param> /// <param name="context">The context.</param> /// <returns>The loaded object, if available; Otherwise, null.</returns> public T LoadObject <T>(Guid id, DbContext context) where T : IIdentifiable { IEntityType type; using (var completeContext = new EntityDataContext()) { type = completeContext.Model.FindEntityType(typeof(T)); } var queryString = this.queryBuilder.BuildJsonQueryForEntity(type); queryString += " where result.\"Id\" = @id;"; using (var command = context.Database.GetDbConnection().CreateCommand()) { command.CommandText = queryString; var idParameter = command.CreateParameter(); idParameter.ParameterName = "id"; idParameter.Value = id; command.Parameters.Add(idParameter); using (var reader = command.ExecuteReader()) { if (reader.HasRows && reader.Read()) { return(this.deserializer.Deserialize <T>(reader.GetTextReader(2), this.referenceResolver)); } return(default(T)); } } }
public void SetupDatabaseAndTestLoadingData() { using (var installationContext = new EntityDataContext()) { installationContext.Database.EnsureDeleted(); installationContext.Database.Migrate(); } var manager = new RepositoryManager(); manager.RegisterRepositories(); // Loading game configuration using (var context = manager.CreateNewConfigurationContext()) using (manager.UseContext(context)) { var gameConfiguraton = manager.GetRepository <DataModel.Configuration.GameConfiguration>().GetAll().FirstOrDefault(); Assert.That(gameConfiguraton, Is.Not.Null); // Testing loading of an account using (var accountContext = manager.CreateNewAccountContext(gameConfiguraton)) using (manager.UseContext(accountContext)) { var account1 = manager.GetRepository <DataModel.Entities.Account, IAccountRepository <DataModel.Entities.Account> >() .GetAccountByLoginName("test1", "test1"); Assert.That(account1, Is.Not.Null); Assert.That(account1.LoginName, Is.EqualTo("test1")); } } }
protected override IEntity MakeEntity(long id, string category) { IEntity entity = base.MakeEntity(id, category); entity.Tag = new GRCClient(this, entity); entity.Used += delegate(object sender, EventArgs <IEntityAdapter> e) { if (entity.UseCount == 0) { entity.Close(); } }; entity.Using += delegate(object sender, EventArgs <IEntityAdapter> e) { IEntityAdapter value = e.Value; if (entity.Tag == null) { return; } if (value.RemoteCategory == "FrontendServiceCore.FrontendService") { GRCClient grcclient = entity.Tag as GRCClient; if (grcclient.FrontendConn != null) { grcclient.FrontendConn.Close(); } grcclient.FrontendConn = this.Connect(entity, new Location(value.RemoteID, value.RemoteCategory)); grcclient.FrontendConn.Closed += delegate(object _, EventArgs <IEntityProxy> __) { entity.Close(); }; grcclient.FrontendConn.OperationQueueOversized += delegate(object _, EventArgs <IEntityProxy> __) { entity.Close(true); }; } }; entity.Closed += delegate(object sender, EventArgs e) { try { EntityDataContext entityDataContext = new EntityDataContext(); entityDataContext.AcquireService(new long?((sender as IEntity).ID), base.Category, new int?(-1), new int?(base.ID)); } catch (Exception ex) { Log <GRCService> .Logger.ErrorFormat("Entity_Closed [EntityID : {0}] [ServiceID : {1}] [Category : {2}] - {3} ", new object[] { (sender as IEntity).ID, base.ID, base.Category, ex }); } }; Scheduler.Schedule(base.Thread, Job.Create(new Action((entity.Tag as GRCClient).MakeRequest)), this.NextMilliseconds()); return(entity); }
public IEnumerable <ProductsViewModel> GetSameProduct(int productID) { using (EntityDataContext _context = new EntityDataContext()) { var product = (_context.Products.Where(p => p.ProductID == productID).Select(p => new ProductsViewModel() { ProductID = p.ProductID, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage, CategoryID = p.CategoryID, SupplierID = p.SupplierID, CompanyID = p.CompanyID })).ToList(); string productName = product[0].ProductName; string[] words = productName.Split(' '); List <ProductsViewModel> productList = new List <ProductsViewModel>(); for (int i = 0; i < words.Length; i++) { var temp = words[i]; if (i == 0) { var products = _context.Products.Join(_context.Companies, p => p.CompanyID, c => c.CompanyID, (p, c) => new ProductsViewModel() { ProductID = p.ProductID, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage, CategoryID = p.CategoryID, SupplierID = p.SupplierID, CompanyID = p.CompanyID, CompanyImage = c.CompanyImage }).Where(p => p.ProductName.Contains(temp)).ToList(); productList.AddRange(products); } else { for (int j = 0; j < productList.Count; j++) { if (productList[j].ProductName.Contains(temp) == false || productList[j].ProductID == productID) { productList.RemoveAt(j); j = -1; } } } } return(productList); } }
public override int CompareAndSwapServiceID(long id, string category, int beforeID) { if (category != base.Category) { return(-1); } int result; using (EntityDataContext entityDataContext = new EntityDataContext()) { result = entityDataContext.AcquireService(new long?(id), base.Category, new int?(base.ID), new int?(beforeID)); } return(result); }
// GET api/values public IEnumerable <ProductsViewModel> Get() { using (EntityDataContext _context = new EntityDataContext()) { return(_context.Products.Select(p => new ProductsViewModel() { ProductID = p.ProductID, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage }).ToList()); } }
public int FindServiceID(long id, string category) { if (category != base.Category) { return(-1); } int result; using (EntityDataContext entityDataContext = new EntityDataContext()) { result = entityDataContext.AcquireService(new long?(id), base.Category, new int?(-1), new int?(-1)); } return(result); }
public IEnumerable <ProductsViewModel> Search(string productName) { using (EntityDataContext _context = new EntityDataContext()) { return(_context.Products.Where(p => p.ProductName.Contains(productName)).Select(p => new ProductsViewModel() { ProductID = p.ProductID, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage, CategoryID = p.CategoryID, SupplierID = p.SupplierID, CompanyID = p.CompanyID }).ToList()); } }
private void Entity_Closed(object sender, EventArgs e) { try { EntityDataContext entityDataContext = new EntityDataContext(); entityDataContext.AcquireService(new long?((sender as IEntity).ID), base.Category, new int?(-1), new int?(base.ID)); } catch (Exception ex) { Log <GuildService> .Logger.ErrorFormat("Entity_Closed [EntityID : {0}] [ServiceID : {1}] [Category : {2}] - {3} ", new object[] { (sender as IEntity).ID, base.ID, base.Category, ex }); } }
public IEnumerable <ProductsViewModel> GetCategory(string categoryCode) { using (EntityDataContext _context = new EntityDataContext()) { var list = (from p in _context.Products join c in _context.Categories on p.CategoryID equals c.CategoryID where c.CategoryCode == categoryCode select new ProductsViewModel { ProductID = p.ProductID, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage, CategoryName = c.CategoryName, CategoryCode = c.CategoryCode }).ToList(); return(list); } }
public IEnumerable <ProductsViewModel> TestPagination(string categoryCode, int num) { using (EntityDataContext _context = new EntityDataContext()) { var startIndex = (num - 1) * 24; var list = (from p in _context.Products join c in _context.Categories on p.CategoryId equals c.CategoryId where c.CategoryCode == categoryCode select new ProductsViewModel { ProductID = p.ProductId, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage, CategoryName = c.CategoryName, CategoryCode = c.CategoryCode }).Skip(startIndex).Take(24).ToList(); return(list); } }
public IEnumerable <ProductsViewModel> GetProductByID(int id) { using (EntityDataContext _context = new EntityDataContext()) { var product = _context.Products.Where(p => p.ProductID == id).ToList(); var companyID = product[0].CompanyID; var company = _context.Companies.Where(c => c.CompanyID == companyID).ToList(); var logo = company[0].CompanyImage; return(_context.Products.Join(_context.Suppliers, p => p.SupplierID, s => s.SupplierID, (p, s) => new ProductsViewModel() { ProductID = p.ProductID, ProductName = p.ProductName, HyperLink = p.HyperLink, Price = p.Price, LinkOfProductImage = p.LinkOfProductImage, CategoryID = p.CategoryID, SupplierID = p.SupplierID, CompanyID = p.CompanyID, SupplierName = s.SupplierName, CompanyImage = logo }).Where(p => p.ProductID == id).ToList()); } }
public BrandModel() { data = new EntityDataContext(); }
public CustomerRepository(EntityDataContext ct) { _context = ct; }
public AccountRepository(EntityDataContext ct) { _context = ct; }
public void UpdateProduct(HttpPostedFileBase excelfile, int?AccountId) { #region // Duyệt danh sách insert EntityDataContext _context = new EntityDataContext(); string ErrorEmpty = ""; string ErrorIsNumber = ""; string Error = ""; bool check = true; int QuantityProduct = 0; try { using (var package = new ExcelPackage(excelfile.InputStream)) { using (TransactionScope ts = new TransactionScope()) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; int col = 1; for (int row = 7; worksheet.Cells[row, col].Value != null; row++) { #region //Gán giá trị tạm int ProductId = 0; decimal ImportPrice = 0; decimal ShippingFee = 0; decimal ExchangeRate = 0; decimal pprice1 = 0; decimal pprice2 = 0; decimal pprice3 = 0; decimal pprice4 = 0; #endregion #region // Kiểm tra giá trị cột //Mã sản phẩm if (worksheet.Cells[row, 2].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Mã sản phẩm' ,"; } else if (int.TryParse(worksheet.Cells[row, 2].Value.ToString(), out ProductId) == false) { check = false; ErrorIsNumber += " Dòng " + row + " Cột 'Mã sản phẩm' ,"; } //Mã Sản Phẩm Cửa hàn if (worksheet.Cells[row, 3].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Mã Sản Phẩm Cửa hàng' ,"; } //Tên Sản Phẩm if (worksheet.Cells[row, 5].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Tên Sản Phẩm' ,"; } //Giá nhập if (worksheet.Cells[row, 6].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Giá nhập' ,"; } else if (decimal.TryParse(worksheet.Cells[row, 6].Value.ToString(), out ImportPrice) == false) { check = false; ErrorIsNumber += " Dòng " + row + " Cột 'Giá nhập' ,"; } //Tỷ giá if (worksheet.Cells[row, 7].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Tỷ giá' ,"; } else if (decimal.TryParse(worksheet.Cells[row, 7].Value.ToString(), out ExchangeRate) == false) { check = false; ErrorIsNumber += " Dòng " + row + " Cột 'Tỷ giá' ,"; } //Phí vận chuyển if (worksheet.Cells[row, 8].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Phí vận chuyển' ,"; } else if (decimal.TryParse(worksheet.Cells[row, 8].Value.ToString(), out ShippingFee) == false) { check = false; ErrorIsNumber += " Dòng " + row + " Cột 'Phí vận chuyển' ,"; } //Vip if (worksheet.Cells[row, 9].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Vip' ,"; } else if (decimal.TryParse(worksheet.Cells[row, 9].Value.ToString(), out pprice1) == false) { check = false; ErrorIsNumber += " Dòng " + row + " Cột 'Vip' ,"; } //Vip-Bạc if (worksheet.Cells[row, 10].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Vip-Bạc' ,"; } else if (decimal.TryParse(worksheet.Cells[row, 10].Value.ToString(), out pprice2) == false) { check = false; ErrorIsNumber += " Dòng " + row + " Cột 'Vip-Bạc' ,"; } //Vip-Vàng if (worksheet.Cells[row, 11].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Vip-Vàng' ,"; } else if (decimal.TryParse(worksheet.Cells[row, 11].Value.ToString(), out pprice3) == false) { check = false; ErrorIsNumber += " Dòng " + row + " Cột 'Vip-Vàng' ,"; } //Vip-Bạch kim if (worksheet.Cells[row, 12].Text == "") { check = false; ErrorEmpty += " Dòng " + row + " Cột 'Vip-Bạch kim' ,"; } else if (decimal.TryParse(worksheet.Cells[row, 12].Value.ToString(), out pprice4) == false) { check = false; ErrorIsNumber += " Dòng " + row + " Cột 'Vip-Bạch kim' ,"; } #endregion if (check) { #region //Cập nhật Product ProductModel p = _context.ProductModel.Where(m => m.ProductId == ProductId).FirstOrDefault(); p.ProductStoreCode = worksheet.Cells[row, 3].Value.ToString(); if (worksheet.Cells[row, 4].Text != "") { p.ProductCode = worksheet.Cells[row, 4].Value.ToString(); } p.ProductName = worksheet.Cells[row, 5].Value.ToString(); p.ImportPrice = ImportPrice; p.ShippingFee = ShippingFee; p.COGS = p.ImportPrice * ExchangeRate + p.ShippingFee; #endregion #region // Cập nhật giá VIP //Product Price 1 ProductPriceModel price1 = _context.ProductPriceModel.Where(pp => pp.ProductId == ProductId && pp.CustomerLevelId == 1).FirstOrDefault(); price1.Price = pprice1; //Product Price 2 ProductPriceModel price2 = _context.ProductPriceModel.Where(pp => pp.ProductId == ProductId && pp.CustomerLevelId == 2).FirstOrDefault(); price2.Price = pprice2; //Product Price 3 ProductPriceModel price3 = _context.ProductPriceModel.Where(pp => pp.ProductId == ProductId && pp.CustomerLevelId == 3).FirstOrDefault(); price3.Price = pprice3; //Product Price 3 ProductPriceModel price4 = _context.ProductPriceModel.Where(pp => pp.ProductId == ProductId && pp.CustomerLevelId == 4).FirstOrDefault(); price4.Price = pprice4; #endregion #region // Update Database _context.Entry(price1).State = System.Data.Entity.EntityState.Modified; _context.Entry(price2).State = System.Data.Entity.EntityState.Modified; _context.Entry(price3).State = System.Data.Entity.EntityState.Modified; _context.Entry(price4).State = System.Data.Entity.EntityState.Modified; _context.Entry(p).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); #endregion } QuantityProduct++; } ts.Complete(); } } } catch (EntityException ex) { Error = "Xảy ra lỗi trong quá trình cập nhật !" + ex; } #region Note NotificationModel n = new NotificationModel(); if (check == true && Error == "") { n.Note = "Đã cập nhật thành công giá của " + QuantityProduct + " sản phẩm !"; } else { n.Note = "Cập nhật không thành công !"; if (Error != "") { n.Note += Error; } if (ErrorEmpty != "") { n.Note += " Bị rỗng :" + ErrorEmpty; } if (ErrorIsNumber != "") { n.Note += " Không là số :" + ErrorEmpty; } } n.AccountId = AccountId; n.CreateDate = DateTime.Now; n.Actived = true; _context.Entry(n).State = System.Data.Entity.EntityState.Added; _context.SaveChanges(); #endregion _context.Dispose(); #endregion }
public CRMNextDateReminderRepository(EntityDataContext ct) { _context = ct; }
private static void CreateData(ExcelWorksheet worksheet, ref int rowIndex, List <ProductInfoViewModel> listProduct) { EntityDataContext db = new EntityDataContext(); int?CategoryId = -1; int Index = 1; listProduct.OrderBy(p => p.CategoryId); foreach (ProductInfoViewModel p in listProduct) { if (p.CategoryId != CategoryId) { #region Tên danh mục sản phẩm for (int i = 1; i <= 7; i++) { var cell2 = worksheet.Cells[rowIndex, i]; cell2.Style.Border.Bottom.Style = cell2.Style.Border.Top.Style = cell2.Style.Border.Left.Style = cell2.Style.Border.Right.Style = ExcelBorderStyle.Thin; } worksheet.Cells[rowIndex, 2, rowIndex, 4].Value = p.CategoryName; worksheet.Cells[rowIndex, 2, rowIndex, 4].Merge = true; worksheet.Cells[rowIndex, 2, rowIndex, 4].Style.Font.Bold = true; #endregion #region Sản phẩm đầu danh mục // Tô màu tồn thực tế var cell = worksheet.Cells[rowIndex + 1, 7]; var fill = cell.Style.Fill; fill.PatternType = ExcelFillStyle.Solid; fill.BackgroundColor.SetColor(Color.Yellow); for (int i = 1; i <= 7; i++) { var cell2 = worksheet.Cells[rowIndex + 1, i]; cell2.Style.Border.Bottom.Style = cell2.Style.Border.Top.Style = cell2.Style.Border.Left.Style = cell2.Style.Border.Right.Style = ExcelBorderStyle.Thin; } Index = 1; worksheet.Cells[rowIndex + 1, 1].Value = Index; worksheet.Cells[rowIndex + 1, 2].Value = p.ProductId; worksheet.Cells[rowIndex + 1, 3].Value = p.ProductCode; worksheet.Cells[rowIndex + 1, 4].Value = p.ProductName; worksheet.Cells[rowIndex + 1, 5].Value = p.Specifications; worksheet.Cells[rowIndex + 1, 6].Value = p.Inventory; Index++; #endregion rowIndex = rowIndex + 2; CategoryId = p.CategoryId; } else { #region Sản phẩm tiếp theo // Tô màu tồn thực tế var cell = worksheet.Cells[rowIndex, 7]; var fill = cell.Style.Fill; fill.PatternType = ExcelFillStyle.Solid; fill.BackgroundColor.SetColor(Color.Yellow); for (int i = 1; i <= 7; i++) { var cell2 = worksheet.Cells[rowIndex, i]; cell2.Style.Border.Bottom.Style = cell2.Style.Border.Top.Style = cell2.Style.Border.Left.Style = cell2.Style.Border.Right.Style = ExcelBorderStyle.Thin; } worksheet.Cells[rowIndex, 1].Value = Index; worksheet.Cells[rowIndex, 2].Value = p.ProductId; worksheet.Cells[rowIndex, 3].Value = p.ProductCode; worksheet.Cells[rowIndex, 4].Value = p.ProductName; worksheet.Cells[rowIndex, 5].Value = p.Specifications; worksheet.Cells[rowIndex, 6].Value = p.Inventory; Index++; #endregion rowIndex++; } } }
public ImportMasterRepository(EntityDataContext ct) { _context = ct; }
public ImageModel() { data = new SmartSale.Models.EntityDataContext(); }
public CategoryModel() { data = new EntityDataContext(); }
public CategoryDAO() { _context = new EntityDataContext(); }
public ProductRepository(EntityDataContext db) { this._context = db; }