public IHttpActionResult GetPosts([FromUri] FlutterPostFilterModel filter, [FromUri] PagingParameterModel paging) { if (filter == null) { filter = new FlutterPostFilterModel(); } if (paging == null) { paging = new PagingParameterModel(); } var pagination = new PaginationMetadataModel() { currentPage = paging.pageNumber, pageSize = paging.pageSize }; var posts = _service.getPosts(filter, ref pagination); // Setting Header HttpContext.Current.Response.Headers.Add("Access-Control-Expose-Headers", "X-Paging-Headers"); HttpContext.Current.Response.Headers.Add("X-Paging-Headers", JsonConvert.SerializeObject(pagination)); return(Ok <List <FlutterPostCardModel> >(posts)); }
public IHttpActionResult GetProductBySearchSort(string search, [FromUri] SearchProductParameterModel parameter) { if (String.IsNullOrEmpty(search)) { throw new Exception("Bạn đang search rỗng"); } var pagination = new PaginationMetadataModel() { currentPage = parameter.pageNumber, pageSize = parameter.pageSize }; var filter = new SearchProductFilterModel() { search = search, sort = parameter.sort }; var products = _service.getProducts(filter, ref pagination); if (products == null || products.Count == 0) { return(NotFound()); } // Setting Header HttpContext.Current.Response.Headers.Add("Access-Control-Expose-Headers", "X-Paging-Headers"); HttpContext.Current.Response.Headers.Add("X-Paging-Headers", JsonConvert.SerializeObject(pagination)); // Returing List of product Collections return(Ok <List <ProductCardModel> >(products)); }
public IHttpActionResult GetProductByCategory(string slug, [FromUri] TagPageParameterModel parameter) { var pagination = new PaginationMetadataModel() { currentPage = parameter.pageNumber, pageSize = parameter.pageSize }; var filter = new TagPageFilterModel() { tagSlug = slug, priceMin = parameter.priceMin, priceMax = parameter.priceMax, sort = parameter.sort }; var products = _service.getProducts(filter, ref pagination); if (products == null || products.Count == 0) { return(NotFound()); } // Setting Header HttpContext.Current.Response.Headers.Add("Access-Control-Expose-Headers", "X-Paging-Headers"); HttpContext.Current.Response.Headers.Add("X-Paging-Headers", JsonConvert.SerializeObject(pagination)); // Returing List of product Collections return(Ok <List <ProductCardModel> >(products)); }
public IHttpActionResult GetNotifications([FromUri] PagingParameterModel paging, string kind = "") { try { if (paging == null) { paging = new PagingParameterModel(); } var phone = _token.getPhoneByToken(this); var filter = new FlutterNotificationFilterModel() { kind = kind, categorySlug = String.Empty, phone = phone }; var pagination = new PaginationMetadataModel() { currentPage = paging.pageNumber, pageSize = paging.pageSize }; var notifications = _service.getNotifications(filter, ref pagination); // Setting Header HttpContext.Current.Response.Headers.Add("Access-Control-Expose-Headers", "X-Paging-Headers"); HttpContext.Current.Response.Headers.Add("X-Paging-Headers", JsonConvert.SerializeObject(pagination)); return(Ok <List <FlutterNotificationCardModel> >(notifications)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private IHttpActionResult GetProducts(string slug, string[] slugList, PagingParameterModel pagingParameterModel) { var pagination = new PaginationMetadataModel() { currentPage = pagingParameterModel.pageNumber, pageSize = pagingParameterModel.pageSize }; var filter = new HomePageFilterModel(); if (String.IsNullOrEmpty(slug) && slugList != null && slugList.Length > 0) { filter.categorySlug = String.Empty; filter.categorySlugList = slugList.ToList(); } else { filter.categorySlug = slug; filter.categorySlugList = new List <string>(); } var products = _service.getProducts(filter, ref pagination); if (products == null) { return(NotFound()); } // Setting Header HttpContext.Current.Response.Headers.Add("Access-Control-Expose-Headers", "X-Paging-Headers"); HttpContext.Current.Response.Headers.Add("X-Paging-Headers", JsonConvert.SerializeObject(pagination)); // Returing List of product Collections return(Ok <List <ProductCardModel> >(products)); }
/// <summary> /// Lấy tất cả sản phẩm theo từ khóa /// </summary> /// <param name="filter"></param> /// <param name="pagination"></param> /// <returns></returns> public List <ProductCardModel> getProducts(SearchProductFilterModel filter, ref PaginationMetadataModel pagination) { var productFilter = new ProductFilterModel() { productSearch = filter.search, productSort = filter.sort }; return(_product.getProducts(productFilter, ref pagination)); }
/// <summary> /// Lấy product theo bộ lọc /// </summary> /// <param name="filter"></param> /// <param name="pagination"></param> /// <returns></returns> public List <ProductCardModel> getProducts(HomePageFilterModel filter, ref PaginationMetadataModel pagination) { var productFilter = new ProductFilterModel() { categorySlug = filter.categorySlug, categorySlugList = filter.categorySlugList, productSort = filter.sort }; return(_product.getProducts(productFilter, ref pagination)); }
/// <summary> /// Lấy tất cả sản phẩm theo filter /// </summary> /// <param name="filter"></param> /// <param name="pagination"></param> /// <returns></returns> public List <ProductCardModel> getProducts(TagPageFilterModel filter, ref PaginationMetadataModel pagination) { var productFilter = new ProductFilterModel() { tagSlug = filter.tagSlug, priceMin = filter.priceMin, priceMax = filter.priceMax, productSort = filter.sort }; return(_product.getProducts(productFilter, ref pagination)); }
public List <FlutterPostCardModel> getPosts(FlutterPostFilterModel filter, ref PaginationMetadataModel pagination) { using (var con = new inventorymanagementEntities()) { var posts = con.PostPublics.Where(x => x.IsPolicy == filter.isPolicy); if (!String.IsNullOrEmpty(filter.categorySlug)) { var categories = _postCategory.getPostCategoryChild(filter.categorySlug); if (categories == null || categories.Count() == 0) { return(null); } var categoriesID = categories.Select(x => x.id).ToList(); posts = posts.Where(p => categoriesID.Contains(p.CategoryID)); } var data = posts .OrderByDescending(o => o.ModifiedDate) .Select(x => new FlutterPostCardModel() { action = x.Action, name = x.Title, actionValue = x.Action == FlutterPageNavigation.ViewMore ? (x.IsPolicy ? "policy/" : "post/") + x.ActionValue : x.ActionValue, image = x.Thumbnail, message = x.Summary, createdDate = x.ModifiedDate }) .ToList(); // Lấy tổng số record sản phẩm pagination.totalCount = data.Count(); // Calculating Totalpage by Dividing (No of Records / Pagesize) pagination.totalPages = (int)Math.Ceiling(pagination.totalCount / (double)pagination.pageSize); var result = data .Skip((pagination.currentPage - 1) * pagination.pageSize) .Take(pagination.pageSize) .ToList(); // if CurrentPage is greater than 1 means it has previousPage pagination.previousPage = pagination.currentPage > 1 ? "Yes" : "No"; // if TotalPages is greater than CurrentPage means it has nextPage pagination.nextPage = pagination.currentPage < pagination.totalPages ? "Yes" : "No"; return(result); } }
/// <summary> /// Lấy tất cả sản phẩm theo bộ lọc /// </summary> /// <param name="filter"></param> /// <param name="pagination"></param> /// <returns></returns> public List <ProductCardModel> getProducts(CategoryPageFilterModel filter, ref PaginationMetadataModel pagination) { var productFilter = new ProductFilterModel() { categorySlug = filter.categorySlug, productBadge = filter.productBadge, productSort = filter.sort, priceMin = filter.priceMin, priceMax = filter.priceMax }; return(_product.getProducts(productFilter, ref pagination)); }
// Lấy lịch sử các lần kiểm tra sản phẩm của nhân viên public static List <StaffHistoryModel> getStaffHistories(string staff, ref PaginationMetadataModel pagination) { using (var con = new inventorymanagementEntities()) { var histories = new List <StaffHistoryModel>(); var data = con.CheckWarehouseDetails .Where(x => x.ModifiedBy == staff) .Join( con.CheckWarehouses, b => b.CheckWarehouseID, h => h.ID, (b, h) => new { header = h, body = b } ) .Select(x => new StaffHistoryModel() { checkedName = x.header.Name, sku = x.body.ProductSKU, quantity = x.body.QuantityNew.HasValue ? x.body.QuantityNew.Value : 0, checkedDate = x.body.ModifiedDate.Value }) .OrderByDescending(o => o.checkedDate); #region Thực hiện phân trang // Lấy tổng số record sản phẩm pagination.totalCount = data.Count(); // Calculating Totalpage by Dividing (No of Records / Pagesize) pagination.totalPages = (int)Math.Ceiling(pagination.totalCount / (double)pagination.pageSize); var result = data .Skip((pagination.currentPage - 1) * pagination.pageSize) .Take(pagination.pageSize) .ToList(); #endregion if (result != null && result.Count() > 0) { histories.AddRange(result); } return(histories); } }
public void LoadData() { string TextSearch = ""; int Page = 1; double Price = 0; if (Request.QueryString["textsearch"] != null) { TextSearch = Request.QueryString["textsearch"].Trim(); } if (Request.QueryString["price"] != null) { Price = Convert.ToDouble(Request.QueryString["price"]); } if (Request.QueryString["Page"] != null) { Page = Request.QueryString["Page"].ToInt(); } // Create order fileter var filter = new ProductFilterModel() { category = 44, stockStatus = 1, quantity = "greaterthan", quantityFrom = 3, search = TextSearch, price = Price }; // Create pagination var page = new PaginationMetadataModel() { currentPage = Page, pageSize = 20 }; List <ProductSQL> a = new List <ProductSQL>(); a = ProductController.GetAllSql(filter, ref page); pagingall(a, page); }
public IHttpActionResult GetProductRelatedBySlug(string slug, [FromUri] PagingParameterModel paging) { if (paging == null) { paging = new PagingParameterModel(); } var pagination = new PaginationMetadataModel() { currentPage = paging.pageNumber, pageSize = paging.pageSize }; var productrelateds = _service.getProductRelatedBySlug(slug, ref pagination); // Setting Header HttpContext.Current.Response.Headers.Add("Access-Control-Expose-Headers", "X-Paging-Headers"); HttpContext.Current.Response.Headers.Add("X-Paging-Headers", JsonConvert.SerializeObject(pagination)); // Returing List of relate product Collections return(Ok <List <ProductRelatedModel> >(productrelateds)); }
public void LoadData() { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { DateTime DateConfig = new DateTime(2019, 12, 15); var config = ConfigController.GetByTop1(); if (config.ViewAllOrders == 1) { DateConfig = new DateTime(2018, 6, 22); } // Filter Order Date DateTime OrderFromDate = DateConfig; DateTime OrderToDate = DateTime.Now; if (!String.IsNullOrEmpty(Request.QueryString["orderfromdate"])) { OrderFromDate = Convert.ToDateTime(Request.QueryString["orderfromdate"]); } if (!String.IsNullOrEmpty(Request.QueryString["ordertodate"])) { OrderToDate = Convert.ToDateTime(Request.QueryString["ordertodate"]).AddDays(1).AddMinutes(-1); } rOrderFromDate.SelectedDate = OrderFromDate; rOrderFromDate.MinDate = DateConfig; rOrderFromDate.MaxDate = DateTime.Now; rOrderToDate.SelectedDate = OrderToDate; rOrderToDate.MinDate = DateConfig; rOrderToDate.MaxDate = DateTime.Now; int TransferStatus = 0; var ExcuteStatus = new List <int>() { 1, 2 }; int BankReceive = 0; string TextSearch = ""; string CreatedBy = ""; int Page = 1; if (Request.QueryString["textsearch"] != null) { TextSearch = Request.QueryString["textsearch"].Trim(); } if (Request.QueryString["transferstatus"] != null) { TransferStatus = Request.QueryString["transferstatus"].ToInt(0); } if (Request.QueryString["excutestatus"] != null) { ExcuteStatus.Clear(); ExcuteStatus.Add(Request.QueryString["excutestatus"].ToInt(0)); } if (Request.QueryString["createdby"] != null) { CreatedBy = Request.QueryString["createdby"]; } if (Request.QueryString["bankreceive"] != null) { BankReceive = Request.QueryString["bankreceive"].ToInt(0); } if (Request.QueryString["Page"] != null) { Page = Request.QueryString["Page"].ToInt(); } txtSearchOrder.Text = TextSearch; ddlTransferStatus.SelectedValue = TransferStatus.ToString(); ddlExcuteStatus.SelectedValue = ExcuteStatus.Count() > 1 ? "0" : ExcuteStatus.FirstOrDefault().ToString(); ddlBankReceive.SelectedValue = BankReceive.ToString(); ddlCreatedBy.SelectedValue = CreatedBy.ToString(); // Create order fileter var filter = new OrderFilterModel() { searchType = (int)SearchType.Order, search = TextSearch, excuteStatus = ExcuteStatus, transferStatus = TransferStatus, paymentType = (int)PaymentType.Bank, orderCreatedBy = CreatedBy, orderFromDate = OrderFromDate, orderToDate = OrderToDate, bankReceive = BankReceive }; // Create pagination var page = new PaginationMetadataModel() { currentPage = Page }; List <OrderList> rs = new List <OrderList>(); rs = OrderController.Filter(filter, ref page); pagingall(rs, page); ltrNumberOfOrder.Text = page.totalCount.ToString(); } }
public List <ProductCardModel> getProducts(ProductFilterModel filter, ref PaginationMetadataModel pagination) { using (var con = new SQLServerContext()) { var source = con.tbl_Product .Select(x => new { categoryID = x.CategoryID.HasValue ? x.CategoryID.Value : 0, productID = x.ID, sku = x.ProductSKU, title = x.ProductTitle, unSignedTitle = x.UnSignedTitle, slug = x.Slug, materials = x.Materials, preOrder = x.PreOrder, availability = false, avatar = x.ProductImage, regularPrice = x.Regular_Price.HasValue ? x.Regular_Price.Value : 0, oldPrice = x.Old_Price.HasValue ? x.Old_Price.Value : 0, retailPrice = x.Retail_Price.HasValue ? x.Retail_Price.Value : 0, content = x.ProductContent, webPublish = x.WebPublish.HasValue ? x.WebPublish.Value : false, webUpdate = x.WebUpdate, }); #region Lọc sản phẩm #region Lọc sản phẩm theo text search if (!String.IsNullOrEmpty(filter.productSearch)) { source = source .Where(x => ( ( x.sku.Trim().Length >= filter.productSearch.Trim().Length&& x.sku.Trim().ToLower().StartsWith(filter.productSearch.Trim().ToLower()) ) || ( x.sku.Trim().Length < filter.productSearch.Trim().Length&& filter.productSearch.Trim().ToLower().StartsWith(x.sku.Trim().ToLower()) ) ) || x.title.Trim().ToLower().Contains(filter.productSearch.Trim().ToLower()) || x.unSignedTitle.Trim().ToLower().Contains(filter.productSearch.Trim().ToLower()) ); } else { // Trường hợp không phải là search thì kiểm tra điều web public source = source.Where(x => x.webPublish == true); } #endregion #region Lọc sản phẩm theo tag slug if (!String.IsNullOrEmpty(filter.tagSlug)) { var tags = con.Tag.Where(x => x.Slug == filter.tagSlug.Trim().ToLower()); var prodTags = con.ProductTag .Join( tags, pt => pt.TagID, t => t.ID, (pt, t) => pt ); source = source .Join( prodTags, p => p.productID, t => t.ProductID, (p, t) => p ); } #endregion #region Lấy theo preOrder (hang-co-san | hang-order) if (!String.IsNullOrEmpty(filter.productBadge)) { switch (filter.productBadge) { case "hang-co-san": source = source.Where(x => x.preOrder == false); break; case "hang-order": source = source.Where(x => x.preOrder == true); break; case "hang-sale": source = source.Where(x => x.oldPrice > 0); break; default: break; } } #endregion #region Lấy theo wholesale price if (filter.priceMin > 0) { source = source.Where(x => x.regularPrice >= filter.priceMin); } if (filter.priceMax > 0) { source = source.Where(x => x.regularPrice <= filter.priceMax); } #endregion #region Lấy theo category slug if (!String.IsNullOrEmpty(filter.categorySlug)) { var categories = _category.getCategoryChild(filter.categorySlug); if (categories == null || categories.Count == 0) { return(null); } var categoryIDs = categories.Select(x => x.id).OrderByDescending(o => o).ToList(); source = source.Where(x => categoryIDs.Contains(x.categoryID)); } #endregion #region Lấy theo category slug if (filter.categorySlugList != null && filter.categorySlugList.Count > 0) { var categories = new List <ProductCategoryModel>(); foreach (var categorySlug in filter.categorySlugList) { var categoryChilds = _category.getCategoryChild(categorySlug); if (categoryChilds == null || categoryChilds.Count == 0) { continue; } categories.AddRange(categoryChilds); } if (categories == null || categories.Count == 0) { return(null); } var categoryIDs = categories.Select(x => x.id).Distinct().OrderByDescending(o => o).ToList(); source = source.Where(x => categoryIDs.Contains(x.categoryID)); } #endregion #region Lấy thông tin sản phẩm và stock var stockFilter = con.tbl_StockManager .Join( source, s => s.ParentID, d => d.productID, (s, d) => s ) .ToList(); var stocks = _stock.getQuantities(stockFilter); #endregion #region Lấy sản phẩm đạt yêu cầu var data = source .ToList() .GroupJoin( stocks, pro => pro.productID, info => info.productID, (pro, info) => new { pro, info } ) .SelectMany( x => x.info.DefaultIfEmpty(), (parent, child) => new { product = parent.pro, stock = child } ) .Select(x => new { x.product, x.stock }); // Trường hợp không phải là search thì kiểm tra điều kiện stock if (String.IsNullOrEmpty(filter.productSearch)) { data = data.Where(x => x.product.preOrder || x.stock == null || ( x.stock != null && x.stock.quantity >= (x.product.categoryID == 44 ? 1 : 3) ) ); } #endregion #endregion #region Thực hiện sắp xếp sản phẩm if (filter.productSort == (int)ProductSortKind.PriceAsc) { data = data.OrderBy(o => o.product.regularPrice); } else if (filter.productSort == (int)ProductSortKind.PriceDesc) { data = data.OrderByDescending(o => o.product.regularPrice); } else if (filter.productSort == (int)ProductSortKind.ModelNew) { data = data.OrderByDescending(o => o.product.productID); } else if (filter.productSort == (int)ProductSortKind.ProductNew) { data = data.OrderByDescending(o => o.product.webUpdate); } else { data = data.OrderByDescending(o => o.product.webUpdate); } #endregion #region Thực hiện phân trang // Lấy tổng số record sản phẩm pagination.totalCount = data.Count(); // Calculating Totalpage by Dividing (No of Records / Pagesize) pagination.totalPages = (int)Math.Ceiling(pagination.totalCount / (double)pagination.pageSize); // Returns List of product after applying Paging var result = data .Select(x => new ProductCardModel() { productID = x.product.productID, sku = x.product.sku, name = x.product.title, slug = x.product.slug, materials = x.product.materials, badge = x.stock == null ? ProductBadge.warehousing : (x.product.oldPrice > 0 ? ProductBadge.sale : (x.product.preOrder ? ProductBadge.order : (x.stock.availability ? ProductBadge.stockIn : ProductBadge.stockOut))), availability = x.stock != null ? x.stock.availability : x.product.availability, thumbnails = Thumbnail.getALL(x.product.avatar), regularPrice = x.product.regularPrice, oldPrice = x.product.oldPrice, retailPrice = x.product.retailPrice, content = x.product.content }) .Skip((pagination.currentPage - 1) * pagination.pageSize) .Take(pagination.pageSize) .ToList(); // if CurrentPage is greater than 1 means it has previousPage pagination.previousPage = pagination.currentPage > 1 ? "Yes" : "No"; // if TotalPages is greater than CurrentPage means it has nextPage pagination.nextPage = pagination.currentPage < pagination.totalPages ? "Yes" : "No"; #endregion #region Lấy thông tin variable var colors = getColors(result.Select(x => x.productID).ToList()); var sizes = getSizes(result.Select(x => x.productID).ToList()); foreach (var prod in result) { prod.colors = colors.Where(x => x.productID == prod.productID).ToList(); prod.sizes = sizes.Where(x => x.productID == prod.productID).ToList(); } #endregion return(result); } }
public void pagingall(List <ProductSQL> acs, PaginationMetadataModel page) { var config = ConfigController.GetByTop1(); string cssClass = "col-xs-6"; StringBuilder html = new StringBuilder(); html.Append("<div class='row'>"); if (acs.Count > 0) { PageCount = page.totalPages; Int32 Page = page.currentPage; var index = 0; foreach (var item in acs) { html.Append("<div class='col-md-3 item-" + index + " product-item'>"); html.Append("<div class='row'>"); html.Append(" <div class='col-xs-12'>"); html.Append(" <p><a href='/xem-nuoc-hoa?id=" + item.ID + "'><img src='" + Thumbnail.getURL(item.ProductImage, Thumbnail.Size.Large) + "'></a></p>"); html.Append(" <h3 class='product-name'><a href='/xem-nuoc-hoa?id=" + item.ID + "'>" + item.ProductSKU + " - " + item.ProductTitle + "</a></h3>"); html.Append(" <h3><span class='product-price'>Giá sỉ: " + string.Format("{0:N0}", item.RegularPrice) + "</span> - <span class='product-price price-retail'>Giá lẻ: " + string.Format("{0:N0}", item.RetailPrice) + "</span></h3>"); if (!string.IsNullOrEmpty(item.Materials)) { html.Append(" <p>" + item.Materials + "</p>"); } html.Append(" </div>"); html.Append("</div>"); html.Append("<div class='row'>"); html.Append(" <div class='col-xs-12'>"); html.Append(" <div class='" + cssClass + "'>"); html.Append(" <div class='row'>"); html.Append(" <a href='javascript:;' class='btn primary-btn copy-btn h45-btn' onclick='copyProductInfo(" + item.ID + ");'><i class='fa fa-files-o' aria-hidden='true'></i> Copy mô tả</a>"); html.Append(" </div>"); html.Append(" </div>"); html.Append(" <div class='" + cssClass + "'>"); html.Append(" <div class='row'>"); html.Append(" <a href ='javascript:;' class='btn primary-btn h45-btn' onclick='getAllProductImage(`" + item.ProductSKU + "`);'><i class='fa fa-cloud-download' aria-hidden='true'></i> Tải hình</a>"); html.Append(" </div>"); html.Append(" </div>"); html.Append(" </div>"); html.Append("</div>"); html.Append("</div>"); if ((index + 1) % 4 == 0) { html.Append("<div class='clear'></div>"); } index++; } } else { html.Append("<div class='col-md-12'>Không tìm thấy sản phẩm...</div>"); } html.Append("</div>"); ltrList.Text = html.ToString(); }
public void pagingall(List <OrderList> acs, PaginationMetadataModel page) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); StringBuilder html = new StringBuilder(); html.Append("<thead>"); html.Append("<tr>"); html.Append(" <th>Mã</th>"); html.Append(" <th class='col-customer'>Khách hàng</th>"); html.Append(" <th>Mua</th>"); html.Append(" <th>Xử lý đơn</th>"); html.Append(" <th>Ngân hàng</th>"); html.Append(" <th>Trạng thái</th>"); html.Append(" <th>Tổng đơn</th>"); html.Append(" <th>Đã nhận</th>"); html.Append(" <th>Ngày nhận tiền</th>"); html.Append(" <th>Hoàn tất đơn</th>"); if (acc.RoleID == 0) { html.Append(" <th>Nhân viên</th>"); } html.Append(" <th></th>"); html.Append("</tr>"); html.Append("</thead>"); html.Append("<tbody>"); if (acs.Count > 0) { PageCount = page.totalPages; Int32 Page = page.currentPage; foreach (var item in acs) { // Insert transfer bank info for tr tag var TrTag = new StringBuilder(); TrTag.AppendLine("<tr "); TrTag.AppendLine(String.Format("data-orderid='{0}' ", item.ID)); TrTag.AppendLine(String.Format("data-cusID='{0}' ", item.CustomerID)); TrTag.AppendLine(String.Format("data-cusbankid='{0:#}' ", item.CusBankID)); TrTag.AppendLine(String.Format("data-cusbankname='{0}' ", item.CusBankName)); TrTag.AppendLine(String.Format("data-accbankid='{0:#}' ", item.AccBankID)); TrTag.AppendLine(String.Format("data-accbankname='{0}' ", item.AccBankName)); TrTag.AppendLine(String.Format("data-statusid='{0:#}' ", item.TransferStatus)); TrTag.AppendLine(String.Format("data-statusname='{0}' ", item.StatusName)); TrTag.AppendLine(String.Format("data-price='{0:#}' ", Convert.ToDouble(item.TotalPrice - item.TotalRefund))); TrTag.AppendLine(String.Format("data-moneyreceived='{0:#}' ", item.MoneyReceive != 0 ? item.MoneyReceive : Convert.ToDecimal(item.TotalPrice - item.TotalRefund))); TrTag.AppendLine(String.Format("data-doneat='{0:dd/MM/yyyy HH:mm}' ", item.DoneAt)); TrTag.AppendLine(String.Format("data-transfernote='{0}' ", item.TransferNote)); TrTag.AppendLine("/>"); html.Append(TrTag.ToString()); html.Append(" <td data-title='Mã đơn'><a href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.ID + "</a></td>"); if (!string.IsNullOrEmpty(item.Nick)) { html.Append(" <td data-title='Khách hàng' class='customer-td'><a class=\"col-customer-name-link\" href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.Nick.ToTitleCase() + "</a><br><span class=\"name-bottom-nick\">(" + item.CustomerName.ToTitleCase() + ")</span></td>"); } else { html.Append(" <td data-title='Khách hàng' class='customer-td'><a class=\"col-customer-name-link\" href=\"/thong-tin-don-hang?id=" + item.ID + "\">" + item.CustomerName.ToTitleCase() + "</a></td>"); } html.Append(" <td data-title='Đã mua'>" + item.Quantity + "</td>"); html.Append(" <td data-title='Xử lý đơn'>" + PJUtils.OrderExcuteStatus(Convert.ToInt32(item.ExcuteStatus)) + "</td>"); html.Append(" <td data-title='Ngân hàng' id='accBankName'>" + item.AccBankName + "</td>"); if (item.TransferStatus == 1) { html.Append(" <td id='statusName' data-title='Trạng thái'><span class='bg-green'>" + item.StatusName + "</span></td>"); } else { html.Append(" <td id='statusName' data-title='Trạng thái'><span class='bg-red'>" + (string.IsNullOrEmpty(item.StatusName) ? "Chưa nhận tiền" : item.StatusName) + "</span></td>"); } html.Append(" <td data-title='Tổng tiền'><strong>" + String.Format("{0:#,###}", Convert.ToDouble(item.TotalPrice - item.TotalRefund)) + "</strong></td>"); if (item.TransferStatus == 1) { html.Append(" <td data-title='Đã nhận' id='moneyReceive'><strong>" + String.Format("{0:#,###}", item.MoneyReceive) + "</strong></td>"); html.Append(" <td data-title='Ngày nhận tiền' id='doneAt'>" + String.Format("{0:dd/MM HH:mm}", item.DoneAt) + "</td>"); } else { html.Append(" <td data-title='Đã nhận' id='moneyReceive'></td>"); html.Append(" <td data-title='Ngày nhận tiền' id='doneAt'></td>"); } string datedone = ""; if (item.ExcuteStatus == 2) { datedone = string.Format("{0:dd/MM}", item.DateDone); } html.Append(" <td data-title='Ngày hoàn tất đơn'>" + datedone + "</td>"); if (acc.RoleID == 0) { html.Append(" <td data-title='Nhân viên tạo đơn'>" + item.CreatedBy + "</td>"); } html.Append(" <td data-title='Thao tác' class='update-button'>"); html.Append(" <button type='button' class='btn primary-btn h45-btn' data-toggle='modal' data-target='#TransferBankModal' data-backdrop='static' data-keyboard='false' title='Cập nhật thông tin chuyển khoản'><span class='glyphicon glyphicon-edit'></span></button>"); html.Append(" </td>"); html.Append("</tr>"); // thông tin thêm html.Append("<tr class='tr-more-info'>"); html.Append("<td colspan='1'></td>"); html.Append("<td colspan='12'>"); if (item.TotalRefund != 0) { html.Append("<span class='order-info'><strong>Trừ hàng trả:</strong> " + string.Format("{0:N0}", item.TotalRefund) + " (<a href='xem-don-hang-doi-tra?id=" + item.RefundsGoodsID + "' target='_blank'>Xem đơn " + item.RefundsGoodsID + "</a>)</span>"); } if (item.TotalDiscount > 0) { html.Append("<span class='order-info'><strong>Chiết khấu:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.TotalDiscount)) + "</span>"); } if (item.OtherFeeValue != 0) { html.Append("<span class='order-info'><strong>Phí khác:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.OtherFeeValue)) + " (<a href='#feeInfoModal' data-toggle='modal' data-backdrop='static' onclick='openFeeInfoModal(" + item.ID + ")'>" + item.OtherFeeName.Trim() + "</a>)</span>"); } if (item.FeeShipping > 0) { html.Append("<span class='order-info'><strong>Phí vận chuyển:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.FeeShipping)) + "</span>"); } if (!string.IsNullOrEmpty(item.ShippingCode)) { string moreInfo = ""; if (item.ShippingType == 3) { moreInfo = " (<a href='https://proship.vn/quan-ly-van-don/?isInvoiceFilter=1&generalInfo=" + item.ShippingCode + "' target='_blank'>Xem</a>)"; } if (item.ShippingType == 2) { moreInfo = " (Chuyển " + ((item.PostalDeliveryType == 1) ? "thường" : "nhanh") + ")"; } html.Append("<span class='order-info'><strong>Mã vận đơn:</strong> " + item.ShippingCode + moreInfo + "</span>"); } if (item.ShippingType == 4) { if (item.TransportCompanyID != 0) { var transport = TransportCompanyController.GetTransportCompanyForOrderList(Convert.ToInt32(item.TransportCompanyID)); var transportsub = TransportCompanyController.GetReceivePlaceForOrderList(Convert.ToInt32(item.TransportCompanyID), Convert.ToInt32(item.TransportCompanySubID)); html.Append("<span class='order-info'><strong>Gửi xe: </strong> " + transport.CompanyName.ToTitleCase() + " (" + transportsub.ShipTo.ToTitleCase() + ")</span>"); } } if (!string.IsNullOrEmpty(item.OrderNote)) { html.Append("<span class='order-info'><strong>Ghi chú:</strong> " + item.OrderNote + "</span>"); } html.Append("</td>"); html.Append("</tr>"); } } else { if (acc.RoleID == 0) { html.Append("<tr><td colspan=\"13\">Không tìm thấy đơn hàng...</td></tr>"); } else { html.Append("<tr><td colspan=\"12\">Không tìm thấy đơn hàng...</td></tr>"); } } html.Append("</tbody>"); ltrList.Text = html.ToString(); }
public void LoadData() { int id = Request.QueryString["id"].ToInt(0); if (id > 0) { var p = ProductController.GetByID(id); if (p == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/sp", Page); } else { this.Title = String.Format("{0} - {1}", p.ProductTitle.ToTitleCase(), p.ProductSKU); ViewState["ID"] = id; ViewState["cateID"] = p.CategoryID; ViewState["SKU"] = p.ProductSKU; ltrProductName.Text = p.ProductSKU + " - " + p.ProductTitle; // Create order fileter var filter = new ProductFilterModel() { search = p.ProductSKU }; // Create pagination var page = new PaginationMetadataModel(); var a = ProductController.GetAllSql(filter, ref page); if (page.totalCount > 0) { foreach (var item in a) { string StockStatus = ""; if (item.StockStatus == 1) { StockStatus = "Còn hàng"; } else { StockStatus = "Hết hàng"; } ltrProductStock.Text = "<p><strong>✱ Kho</strong>: " + StockStatus + " (" + item.TotalProductInstockQuantityLeft.ToString() + " cái)</p>"; } } else { ltrProductStock.Text = "<p><strong>✱ Kho</strong>: Đang nhập hàng</p>"; } ltrRegularPrice.Text = "<p><strong>📌 Giá sỉ</strong>: " + (p.Regular_Price / 1000).ToString() + "k</p>"; ltrRetailPrice.Text = "<p><strong>📌 Giá lẻ</strong>: " + ((p.Retail_Price + 20000) / 1000).ToString() + "k</p>"; if (!string.IsNullOrEmpty(p.Materials)) { ltrMaterials.Text = "<p><strong>🔖 Chất liệu</strong>: " + p.Materials + "</p>"; } if (!string.IsNullOrEmpty(p.ProductContent)) { string content = Regex.Replace(p.ProductContent, @"<img\s[^>]*>(?:\s*?</img>)?", "").ToString(); ltrContent.Text = "<p><strong>🔖 Mô tả</strong>: " + content + "</p>"; } if (p.ProductImage != null) { ProductThumbnail.Text = "<p><img src='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Large) + "'><a href='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>"; } var image = ProductImageController.GetByProductID(id); if (image != null) { foreach (var img in image) { if (img.ProductImage != p.ProductImage) { imageGallery.Text += "<p><img src='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Large) + "'><a href='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></p>"; } } } var v = ProductVariableController.SearchProductID(id, ""); string css = "col-xs-6"; if (v.Count > 0) { css = "col-xs-4"; } StringBuilder htmlButton = new StringBuilder(); htmlButton.Append("<div class='" + css + "'>"); htmlButton.Append(" <div class='row'>"); htmlButton.Append(" <p><a href='javascript:;' class='btn primary-btn copy-btn h45-btn' onclick='copyProduct(`" + p.ID + "`);'><i class='fa fa-files-o' aria-hidden='true'></i> Copy</a></p>"); htmlButton.Append(" </div>"); htmlButton.Append("</div>"); if (v.Count > 0) { htmlButton.Append("<div class='" + css + "'>"); htmlButton.Append(" <div class='row'>"); htmlButton.Append(" <p><a href='#variableTable' class='btn download-btn h45-btn'><i class='fa fa-list-ul' aria-hidden='true'></i> Biến thể</a></p>"); htmlButton.Append(" </div>"); htmlButton.Append("</div>"); ltrVariableList.Text = "<h3><i class='fa fa-list-ul' aria-hidden='true'></i> Danh sách biến thể</h3>"; pagingall(v); } htmlButton.Append("<div class='" + css + "'>"); htmlButton.Append(" <div class='row'>"); htmlButton.Append(" <a href='javascript:;' class='btn primary-btn h45-btn' onclick='getAllProductImage(`" + p.ProductSKU + "`);'><i class='fa fa-cloud-download' aria-hidden='true'></i> Tải hình</a>"); htmlButton.Append(" </div>"); htmlButton.Append("</div>"); ltrButton.Text = htmlButton.ToString(); } } }
public void LoadData() { string username = HttpContext.Current.Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); int id = Request.QueryString["id"].ToInt(0); string sku = Request.QueryString["sku"]; var p = new tbl_Product(); if (id > 0) { p = ProductController.GetByID(id); } else if (id == 0) { int variableid = Request.QueryString["variableid"].ToInt(0); if (variableid != 0) { p = ProductController.GetByVariableID(variableid); } else { if (sku != "") { p = ProductController.GetBySKU(sku); if (p == null) { p = ProductController.GetByVariableSKU(sku); } } } } if (p == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/tat-ca-san-pham", Page); } else { this.Title = String.Format("{0} - Sản phẩm", p.ProductSKU.ToTitleCase()); ViewState["ID"] = id; ViewState["cateID"] = p.CategoryID; ViewState["SKU"] = p.ProductSKU; ltrEdit1.Text = ""; if (acc.RoleID == 0 || acc.RoleID == 1 || acc.Username == "nhom_zalo502") { ltrEdit1.Text += "<a href='/thong-tin-san-pham?id=" + p.ID + "' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-pencil-square-o' aria-hidden='true'></i> Chỉnh sửa</a>"; ltrEdit1.Text += "<a href='/tao-san-pham' class='btn primary-btn fw-btn not-fullwidth print-invoice-merged'><i class='fa fa-file-text-o' aria-hidden='true'></i> Thêm mới</a>"; if (p.ShowHomePage == 1) { ltrEdit1.Text += "<a href='javascript:;' onclick='showProductSyncModal(`" + p.ProductSKU + "`, " + p.ID + ", " + p.CategoryID + ");' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-upload' aria-hidden='true'></i> Đồng bộ</a>"; } } ltrEdit1.Text += "<a href='javascript:;' onclick='copyProductInfo(" + p.ID + ")' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-files-o'></i> Copy thông tin</a>"; ltrEdit1.Text += "<a href='javascript:;' onclick='getAllProductImage(`" + p.ProductSKU + "`);' class='btn primary-btn not-fullwidth print-invoice-merged'><i class='fa fa-cloud-download'></i> Tải tất cả hình ảnh</a>"; if (acc.RoleID == 0 || acc.Username == "nhom_zalo502") { ltrEdit1.Text += "<a href='javascript:;' onclick='deleteProduct(" + p.ID + ");' class='btn primary-btn not-fullwidth print-invoice-merged btn-red'><i class='fa fa-times'></i> Xóa sản phẩm</a>"; ltrEdit1.Text += "<a href='javascript:;' data-toggle='modal' data-target='#modalUpdateProductSKU' data-backdrop='static' data-keyboard='false' class='btn primary-btn not-fullwidth print-invoice-merged btn-blue'><i class='fa fa-times'></i> Sửa mã sản phẩm</a>"; } ltrEdit2.Text = ltrEdit1.Text; lbProductTitle.Text = p.ProductTitle; pContent.Text = p.ProductContent; lblSKU.Text = p.ProductSKU; txtOldSKU.Text = p.ProductSKU; // Create order fileter var filter = new ProductFilterModel() { search = p.ProductSKU }; // Create pagination var page = new PaginationMetadataModel(); var a = ProductController.GetAllSql(filter, ref page); if (page.totalCount > 0) { foreach (var item in a) { lbProductStock.Text = item.TotalProductInstockQuantityLeft.ToString(); ddlStockStatus.SelectedValue = item.StockStatus.ToString(); } } else { lbProductStock.Text = "0"; } lbOldPrice.Text = string.Format("{0:N0}", p.Old_Price); lbRegularPrice.Text = string.Format("{0:N0}", p.Regular_Price); ltrCostOfGood.Text = ""; if (acc.RoleID == 0) { ltrCostOfGood.Text += "<div class='form-row'>"; ltrCostOfGood.Text += " <div class='row-left'>"; ltrCostOfGood.Text += " Giá vốn"; ltrCostOfGood.Text += " </div>"; ltrCostOfGood.Text += " <div class='row-right'>"; ltrCostOfGood.Text += " <span class='form-control'>" + string.Format("{0:N0}", p.CostOfGood) + "</span>"; ltrCostOfGood.Text += " </div>"; ltrCostOfGood.Text += "</div>"; } lbRetailPrice.Text = string.Format("{0:N0}", p.Retail_Price); ddlSupplier.SelectedValue = p.SupplierID.ToString(); ddlCategory.SelectedValue = p.CategoryID.ToString(); lbMaterials.Text = p.Materials; lbColor.Text = p.Color; // Hàng order ddlPreOrder.SelectedValue = p.PreOrder ? "1" : "0"; // thư viện ảnh var image = ProductImageController.GetByProductID(id); imageGallery.Text = "<ul class='image-gallery'>"; imageGallery.Text += "<li><img src='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Normal) + "'><a href='" + Thumbnail.getURL(p.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>"; if (image != null) { foreach (var img in image) { if (img.ProductImage != p.ProductImage) { imageGallery.Text += "<li><img src='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Normal) + "'><a href='" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Source) + "' download class='btn download-btn download-image h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></li>"; } } } imageGallery.Text += "</ul>"; hdfTable.Value = p.ProductStyle.ToString(); // Init Tag var tagIDList = ProductTagController.get(p.ID, 0) .Select(x => x.name) .ToList(); hdfTags.Value = String.Join(",", tagIDList); List <tbl_ProductVariable> b = new List <tbl_ProductVariable>(); b = ProductVariableController.SearchProductID(p.ID, ""); if (b != null) { pagingall(b, Convert.ToInt32(acc.RoleID)); } } }
public void pagingall(List <DeliveryPostOffice> acs, PaginationMetadataModel page) { StringBuilder html = new StringBuilder(); html.AppendLine("<thead>"); html.AppendLine("<tr>"); html.AppendLine(" <th>Mã</th>"); html.AppendLine(" <th class='col-customer'>Khách hàng</th>"); html.AppendLine(" <th>Điện Thoại</th>"); html.AppendLine(" <th>Trạng thái</th>"); html.AppendLine(" <th>Ngày gửi</th>"); html.AppendLine(" <th>Ngày phát</th>"); html.AppendLine(" <th>COD <br/>(Bưu Điện)</th>"); html.AppendLine(" <th>COD <br/>(Hệ thống)</th>"); html.AppendLine(" <th>Phí <br/>(Bưu Điện)</th>"); html.AppendLine(" <th>Phí <br/>(Hệ thống)</th>"); html.AppendLine(" <th>Nhân viên</th>"); html.AppendLine(" <th></th>"); html.AppendLine("</tr>"); html.AppendLine("</thead>"); html.AppendLine("<tbody>"); if (acs.Count > 0) { PageCount = page.totalPages; Int32 Page = page.currentPage; foreach (var item in acs) { // Insert transfer bank info for tr tag var TrTag = new StringBuilder(); TrTag.AppendLine("<tr "); TrTag.AppendLine(String.Format("data-id='{0}' ", item.ID)); TrTag.AppendLine(String.Format("data-orderid='{0}' ", item.OrderID)); TrTag.AppendLine("/>"); html.AppendLine(TrTag.ToString()); html.AppendLine(" <td data-title='Mã hóa đơn'>"); html.AppendLine(" <a target='_blank' href='/thong-tin-don-hang?id=" + item.OrderID + "'>" + String.Format("{0:#}", item.OrderID) + "</a>"); html.AppendLine(" </td>"); html.AppendLine(" <td data-title='Khách hàng' class='customer-td'>"); html.AppendLine(" <a target='_blank' class='col-customer-name-link' href='/thong-tin-don-hang?id=" + item.OrderID + "'>" + item.Customer.ToTitleCase() + "</a>"); html.AppendLine(" </td>"); html.AppendLine(" <td data-title='Điện Thoại'><a target='_blank' href='/danh-sach-don-hang?&searchtype=1&textsearch=" + item.Phone + "&shippingtype=2'>" + item.Phone + "</a></td>"); html.AppendLine(" <td data-title='Trạng thái'>"); if (item.DeliveryStatus == "Hủy") { html.AppendLine(" <span class='bg-red'>Hủy</span>"); } else { html.AppendLine(" " + item.DeliveryStatus); } html.AppendLine(" </td>"); html.AppendLine(" <td data-title='Ngày gửi'>" + String.Format("{0:dd/MM/yyyy}", item.StartDate) + "</td>"); html.AppendLine(" <td data-title='Ngày phát'>" + String.Format("{0:dd/MM/yyyy}", item.ExpectDate) + "</td>"); html.AppendLine(" <td data-title='COD (Bưu điện)'><strong>" + String.Format("{0:#,###}", item.COD) + "</strong></td>"); html.AppendLine(" <td data-title='COD (Hệ thống)'><strong>" + String.Format("{0:#,###}", item.OrderCOD) + "</strong></td>"); html.AppendLine(" <td data-title='Phí (Bưu điện)'><strong>" + String.Format("{0:#,###}", item.Fee) + "</strong></td>"); html.AppendLine(" <td data-title='Phí (Hệ thống)'><strong>" + String.Format("{0:#,###}", item.OrderFee) + "</strong></td>"); html.AppendLine(" <td data-title='Nhân viên tạo đơn'>" + item.Staff + "</td>"); html.AppendLine(" <td data-title='Thao tác' class='handle-button'>"); if (item.Review != (int)DeliveryPostOfficeReview.Approve) { html.AppendLine(" <button type='button'"); html.AppendLine(" class='btn primary-btn h45-btn'"); html.AppendLine(" title='Duyệt đơn hàng'"); html.AppendLine(" style='background-color: #73a724'"); html.AppendLine(String.Format(" onclick='approve({0}, {1}, true)'", item.ID, item.OrderID)); html.AppendLine(" >"); html.AppendLine(" <span class='glyphicon glyphicon-check'></span>"); html.AppendLine(" </button>"); } if (!(item.OrderStatus == (int)OrderStatus.Spam || item.Review == (int)DeliveryPostOfficeReview.Approve)) { html.AppendLine(" <button type='button'"); html.AppendLine(" class='btn primary-btn h45-btn'"); html.AppendLine(" title='Bỏ qua đơn hàng'"); html.AppendLine(" style='background-color: #FF675B'"); html.AppendLine(String.Format(" onclick='cancel({0})'", item.ID)); html.AppendLine(" >"); html.AppendLine(" <span class='glyphicon glyphicon-trash'></span>"); html.AppendLine(" </button>"); } html.AppendLine(" </td>"); html.AppendLine("</tr>"); // thông tin thêm html.AppendLine("<tr class='tr-more-info'>"); html.AppendLine(" <td colspan='1' data-title='Thông tin mã vẫn đơn'>"); html.AppendLine(" <span class='bg-blue'><strong>" + item.NumberID + "</strong></span>"); html.AppendLine(" </td>"); html.AppendLine(" <td colspan='11' data-title='Thông tin thêm địa chỉ khách hàng'>"); if (!string.IsNullOrEmpty(item.Address)) { html.AppendLine("<span class='order-info'><strong>Địa chỉ:</strong> " + item.Address + "</span>"); } html.AppendLine("</td>"); html.AppendLine("</tr>"); } } else { html.AppendLine("<tr><td colspan='12'>Không tìm thấy đơn hàng...</td></tr>"); } html.AppendLine("</tbody>"); ltrList.Text = html.ToString(); }
public static List <RegisterProductList> Filter(RegisterProductFilterModel filter, ref PaginationMetadataModel page) { using (var con = new inventorymanagementEntities()) { var data = con.RegisterProducts.Where(x => 1 == 1); var staff = con.tbl_Account.Where(x => 1 == 1); #region Thực hiện trích xuất dữ liệu theo bộ lọc // Filter theo ký tự search if (!String.IsNullOrEmpty(filter.search)) { data = data.Where(x => x.Title.Contains(filter.search) || x.Customer.Contains(filter.search) || x.SKU.Contains(filter.search) ); } // Filter theo category if (filter.category > 0) { var parentCatogory = con.tbl_Category.Where(x => x.ID == filter.category).FirstOrDefault(); var catogoryFilter = CategoryController.getCategoryChild(parentCatogory).Select(x => x.ID).ToList(); var product = con.tbl_Product .Where(x => catogoryFilter.Contains( x.CategoryID.HasValue ? x.CategoryID.Value : 0 ) ); data = data .Join( product, d => d.ProductID, p => p.ID, (d, p) => d ); } // Filter theo trang thái if (filter.status != 0) { data = data.Where(x => x.Status == filter.status); } // Filter theo người khở tạo if (!String.IsNullOrEmpty(filter.createdBy)) { staff = staff.Where(x => x.Username == filter.createdBy); data = data .Join( staff, d => d.CreatedBy, s => s.ID, (d, s) => d ); } // Filter Order Created Date if (filter.fromDate.HasValue && filter.toDate.HasValue) { data = data.Where(x => x.CreatedDate >= filter.fromDate.Value && x.CreatedDate <= filter.toDate.Value ); } // Filter color if (!String.IsNullOrEmpty(filter.color)) { data = data.Where(x => x.Color.Contains(filter.color)); } // Filter color if (!String.IsNullOrEmpty(filter.size)) { data = data.Where(x => x.Size.Contains(filter.size)); } // Filter theo đã chọn if (filter.selected) { var session = SessionController.getRegisterProductSession(filter.account) .Select(x => x.id) .ToList(); data = data.Where(x => session.Contains(x.ID)); } #endregion #region Tính toán phân trang // Calculate pagination page.totalCount = data.Count(); page.totalPages = (int)Math.Ceiling(page.totalCount / (double)page.pageSize); data = data .OrderByDescending(x => x.ID) .Skip((page.currentPage - 1) * page.pageSize) .Take(page.pageSize); #endregion var result = data .Join( staff, d => d.CreatedBy, s => s.ID, (d, s) => new { register = d, staff = s } ) .OrderByDescending(o => o.register.ID) .ToList(); return(result .Select(x => { var statusName = ""; switch (x.register.Status) { case (int)RegisterProductStatus.Approve: statusName = "Đã duyệt"; break; case (int)RegisterProductStatus.Ordering: statusName = "Đã đặt hàng"; break; case (int)RegisterProductStatus.Done: statusName = "Hàng về"; break; default: statusName = "Chưa duyệt"; break; } return new RegisterProductList() { check = false, id = x.register.ID, customer = x.register.Customer, productID = x.register.ProductID, variableID = x.register.VariableID, sku = x.register.SKU, productStyle = x.register.ProductStyle, status = x.register.Status, statusName = statusName, title = x.register.Title, image = x.register.Image, color = x.register.Color, size = x.register.Size, numberchild = x.register.NumberChild, quantity = x.register.Quantity, expectedDate = x.register.ExpectedDate, note1 = x.register.Note1, note2 = x.register.Note2, staffID = x.register.CreatedBy, staffName = x.staff.Username, createdDate = x.register.CreatedDate }; }) .ToList()); } }
public void pagingall(List <OrderList> acs, PaginationMetadataModel page) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); StringBuilder html = new StringBuilder(); html.AppendLine("<thead>"); html.AppendLine("<tr>"); html.AppendLine(" <th>Mã</th>"); html.AppendLine(" <th></th>"); html.AppendLine(" <th class='col-customer'>Khách hàng</th>"); html.AppendLine(" <th>Mua</th>"); html.AppendLine(" <th>Xử lý</th>"); html.AppendLine(" <th>Thanh toán</th>"); html.AppendLine(" <th>Kiểu thanh toán</th>"); html.AppendLine(" <th>Giao hàng</th>"); html.AppendLine(" <th>Tổng tiền</th>"); if (acc.RoleID == 0) { html.AppendLine(" <th>Nhân viên</th>"); } html.AppendLine(" <th>Ngày tạo</th>"); html.AppendLine(" <th>Hoàn tất</th>"); html.AppendLine(" <th></th>"); html.AppendLine("</tr>"); html.AppendLine("</thead>"); html.AppendLine("<tbody>"); if (acs.Count > 0) { PageCount = page.totalPages; Int32 Page = page.currentPage; foreach (var item in acs) { html.AppendLine("<tr>"); html.AppendLine(" <td data-title='Mã đơn'><a target='_blank' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.ID + "</a></td>"); html.AppendLine(" <td data-title='Loại đơn'>" + PJUtils.OrderTypeStatus(Convert.ToInt32(item.OrderType)) + "</td>"); if (!string.IsNullOrEmpty(item.Nick)) { html.AppendLine(" <td data-title='Khách hàng' class='customer-td'><a class='col-customer-name-link' target='_blank' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.Nick.ToTitleCase() + "</a><br><span class='name-bottom-nick'>(" + item.CustomerName.ToTitleCase() + ")</span></td>"); } else { html.AppendLine(" <td data-title='Khách hàng' class='customer-td'><a class='col-customer-name-link' target='_blank' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.CustomerName.ToTitleCase() + "</a></td>"); } html.AppendLine(" <td data-title='Đã mua'>" + item.Quantity + "</td>"); if (acc.RoleID == 0 && item.ExcuteStatus == 2) { html.AppendLine(" <td data-title='Xử lý'><span class='bg-green' style='cursor: pointer' onclick='onClick_spFinishStatusOrder(this, " + item.ID + ")'>Đã hoàn tất</span></td>"); } else { html.AppendLine(" <td data-title='Xử lý'>" + PJUtils.OrderExcuteStatus(Convert.ToInt32(item.ExcuteStatus)) + "</td>"); } html.AppendLine(" <td data-title='Thanh toán'>" + PJUtils.OrderPaymentStatus(Convert.ToInt32(item.PaymentStatus)) + "</td>"); #region Phương thức thanh toán html.AppendLine(" <td data-title='Kiểu thanh toán' class='payment-type'>"); html.AppendLine(PJUtils.PaymentType(Convert.ToInt32(item.PaymentType))); // Đã nhận tiền chuyển khoản if (item.PaymentType == 2) { if (item.TransferStatus.HasValue && item.TransferStatus.Value == 1) { html.AppendLine(" <br/><div class='new-status-btn'><span class='bg-green'>Đã nhận tiền</span></div>"); } else { if (acc.RoleID == 0) { html.AppendLine(" <br/><a class='new-status-btn' target='_blank' href='/danh-sach-chuyen-khoan?&textsearch=" + item.ID + "'><span class='bg-black'>Cập nhật</span></a>"); } } } html.AppendLine(" </td>"); #endregion #region Giao hàng html.AppendLine(" <td data-title='Giao hàng' class='shipping-type'>"); html.AppendLine(PJUtils.ShippingType(Convert.ToInt32(item.ShippingType))); // Đã giao hàng if (item.DeliveryStatus.HasValue && item.DeliveryStatus.Value == 1) { html.AppendLine(" <br/><div class='new-status-btn'><span class='bg-green'>Đã giao</span></div>"); } html.AppendLine(" </td>"); #endregion // Tổng tiền if (acc.RoleID == 0) { html.AppendLine(" <td data-title='Tổng tiền'>"); html.AppendLine(String.Format(" <strong>{0:N0}</strong>", item.TotalPrice - item.TotalRefund)); html.AppendLine(String.Format(" <br/><span class='{0}'><strong>{1:N0}</strong></span>", item.TotalProfit > 0 ? "bg-green" : "bg-red", item.TotalProfit)); html.AppendLine(" </td>"); } else { html.AppendLine(String.Format(" <td data-title='Tổng tiền'><strong>{0:N0}</strong></td>", item.TotalPrice - item.TotalRefund)); } if (acc.RoleID == 0) { html.AppendLine(" <td data-title='Nhân viên'>" + item.CreatedBy + "</td>"); } string date = string.Format("<strong>{0:dd/MM}</strong><br>{0:HH:mm}", item.CreatedDate); html.AppendLine(" <td data-title='Ngày tạo'>" + date + "</td>"); string datedone = ""; if (item.ExcuteStatus == 2) { datedone = string.Format("<strong>{0:dd/MM}</strong><br>{0:HH:mm}", item.DateDone); } html.AppendLine(" <td data-title='Hoàn tất'>" + datedone + "</td>"); html.AppendLine(" <td data-title='Thao tác' class='update-button'>"); html.AppendLine(" <a href='/print-invoice?id=" + item.ID + "' title='In hóa đơn' target='_blank' class='btn primary-btn h45-btn'><i class='fa fa-print' aria-hidden='true'></i></a>"); html.AppendLine(" <a href='/print-shipping-note?id=" + item.ID + "' title='In phiếu gửi hàng' target='_blank' class='btn primary-btn btn-red h45-btn'><i class='fa fa-file-text-o' aria-hidden='true'></i></a>"); html.AppendLine(" <a href='/chi-tiet-khach-hang?id=" + item.CustomerID + "' title='Thông tin khách hàng " + item.CustomerName + "' target='_blank' class='btn primary-btn btn-black h45-btn'><i class='fa fa-user-circle' aria-hidden='true'></i></a>"); if (item.DeliveryStatus.HasValue && item.DeliveryStatus.Value == 1 && !string.IsNullOrEmpty(item.InvoiceImage)) { html.AppendLine(" <a href='javascript:;' onclick='openImageInvoice($(this))' data-link='" + item.InvoiceImage + "' title='Biên nhận gửi hàng' class='btn primary-btn btn-blue h45-btn'><i class='fa fa-file-text-o' aria-hidden='true'></i></a>"); } html.AppendLine(" <a href='javascript:;' onclick='copyInvoiceURL(" + item.ID + ", " + item.CustomerID + ")' title='Copy link hóa đơn' class='btn primary-btn btn-violet h45-btn'><i class='glyphicon glyphicon-list-alt' aria-hidden='true'></i></a>"); html.AppendLine(" </td>"); html.AppendLine("</tr>"); // thông tin thêm html.AppendLine("<tr class='tr-more-info'>"); html.AppendLine("<td colspan='2'></td>"); html.AppendLine("<td colspan='11'>"); if (item.TotalRefund != 0) { html.AppendLine("<span class='order-info'><strong>Đổi trả:</strong> -" + string.Format("{0:N0}", item.TotalRefund) + " (<a href='xem-don-hang-doi-tra?id=" + item.RefundsGoodsID + "' target='_blank'>Đơn " + item.RefundsGoodsID + "</a>)</span>"); } if (item.TotalDiscount > 0) { html.AppendLine("<span class='order-info'><strong>Chiết khấu:</strong> -" + string.Format("{0:N0}", Convert.ToDouble(item.TotalDiscount)) + "</span>"); } if (item.OtherFeeValue != 0) { html.AppendLine("<span class='order-info'><strong>Phí khác:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.OtherFeeValue)) + " (<a href='#feeInfoModal' data-toggle='modal' data-backdrop='static' onclick='onClick_aFeeInfoModal(" + item.ID + ")'>" + item.OtherFeeName.Trim() + "</a>)</span>"); } if (item.ShippingType == 4) { if (item.TransportCompanyID != 0) { var transport = TransportCompanyController.GetTransportCompanyForOrderList(Convert.ToInt32(item.TransportCompanyID)); var transportsub = TransportCompanyController.GetReceivePlaceForOrderList(Convert.ToInt32(item.TransportCompanyID), Convert.ToInt32(item.TransportCompanySubID)); html.AppendLine("<span class='order-info'><strong>Gửi xe: </strong> " + transport.CompanyName.ToTitleCase() + " (" + transportsub.ShipTo.ToTitleCase() + ")</span>"); } } if (!string.IsNullOrEmpty(item.ShippingCode)) { string moreInfo = ""; if (item.ShippingType == 3 && !String.IsNullOrEmpty(item.ShippingCode)) { moreInfo = " (<a href='https://proship.vn/quan-ly-van-don/?isInvoiceFilter=1&generalInfo=" + item.ShippingCode + "' target='_blank'>Xem</a>)"; } if (item.ShippingType == 2) { moreInfo = " (Chuyển " + ((item.PostalDeliveryType == 1) ? "thường" : "nhanh") + ")"; } if (item.ShippingType == 6 && !String.IsNullOrEmpty(item.ShippingCode)) { moreInfo = " (<a href='https://khachhang.giaohangtietkiem.vn/khachhang?code=" + item.ShippingCode + "' target='_blank'>Xem</a>)"; } html.AppendLine("<span class='order-info'><strong>Vận đơn:</strong> " + item.ShippingCode + moreInfo + "</span>"); } if (item.FeeShipping > 0) { html.AppendLine("<span class='order-info'><strong>Ship:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.FeeShipping)) + "</span>"); } if ((item.ShippingType == 4 || item.ShippingType == 5) && !string.IsNullOrEmpty(item.ShipperName)) { html.AppendLine("<span class='order-info'><strong>Shipper:</strong> " + item.ShipperName + "</span>"); } if (!string.IsNullOrEmpty(item.CouponCode)) { html.AppendLine(String.Format("<span class='order-info'><strong>Coupon ({0}):</strong> -{1:N0}</span>", item.CouponCode.Trim().ToUpper(), item.CouponValue)); } if (!string.IsNullOrEmpty(item.OrderNote)) { html.AppendLine("<span class='order-info'><strong>Ghi chú:</strong> " + item.OrderNote + "</span>"); } html.AppendLine("</td>"); html.AppendLine("</tr>"); } } else { if (acc.RoleID == 0) { html.AppendLine("<tr><td colspan='13'>Không tìm thấy đơn hàng...</td></tr>"); } else { html.AppendLine("<tr><td colspan='12'>Không tìm thấy đơn hàng...</td></tr>"); } } html.AppendLine("</tbody>"); ltrList.Text = html.ToString(); }
public void LoadData() { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { DateTime DateConfig = new DateTime(2019, 12, 15); var config = ConfigController.GetByTop1(); if (config.ViewAllOrders == 1) { DateConfig = new DateTime(2018, 6, 22); } DateTime OrderFromDate = DateConfig; DateTime OrderToDate = DateTime.Now; if (!String.IsNullOrEmpty(Request.QueryString["orderfromdate"])) { OrderFromDate = Convert.ToDateTime(Request.QueryString["orderfromdate"]); } if (!String.IsNullOrEmpty(Request.QueryString["ordertodate"])) { OrderToDate = Convert.ToDateTime(Request.QueryString["ordertodate"]).AddDays(1).AddMinutes(-1); } rOrderFromDate.SelectedDate = OrderFromDate; rOrderFromDate.MinDate = DateConfig; rOrderFromDate.MaxDate = DateTime.Now; rOrderToDate.SelectedDate = OrderToDate; rOrderToDate.MinDate = DateConfig; rOrderToDate.MaxDate = DateTime.Now; string TextSearch = String.Empty; int orderStatus = 0; string deliveryStatus = String.Empty; int review = 0; int feeStatus = 0; int Page = 1; if (Request.QueryString["textsearch"] != null) { TextSearch = Request.QueryString["textsearch"].Trim(); } if (Request.QueryString["orderstatus"] != null) { orderStatus = Request.QueryString["orderstatus"].ToInt(0); } if (Request.QueryString["deliverystatus"] != null) { deliveryStatus = Request.QueryString["deliverystatus"]; } if (Request.QueryString["review"] != null) { review = Request.QueryString["review"].ToInt(0); } if (Request.QueryString["feestatus"] != null) { feeStatus = Request.QueryString["feestatus"].ToInt(0); } if (Request.QueryString["Page"] != null) { Page = Request.QueryString["Page"].ToInt(); } txtSearchOrder.Text = TextSearch; ddlOrderStatus.SelectedValue = orderStatus.ToString(); ddlDeliveryStatus.SelectedValue = deliveryStatus.ToString(); ddlReview.SelectedValue = review.ToString(); ddlFeeStatus.SelectedValue = feeStatus.ToString(); // Create delivery post office fileter var filter = new DeliveryPostOfficeFilterModel() { search = TextSearch, orderStatus = orderStatus, deliveryStatus = deliveryStatus, review = review, feeStatus = feeStatus, orderFromDate = OrderFromDate, orderToDate = OrderToDate }; // Create pagination var page = new PaginationMetadataModel() { currentPage = Page }; decimal lossMoney = 0; List <DeliveryPostOffice> rs = new List <DeliveryPostOffice>(); rs = DeliveryPostOfficeController.Filter(filter, ref page, ref lossMoney); pagingall(rs, page); ltrNumberOfOrder.Text = String.Format("{0} số đơn bưu điện - Số tiền phí lệch: {1:#,###} VND", page.totalCount.ToString(), lossMoney); } }
public void LoadData() { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { // ẩn sản phẩm theo thời gian DateTime year = new DateTime(2019, 12, 15); var config = ConfigController.GetByTop1(); if (config.ViewAllOrders == 1) { year = new DateTime(2018, 6, 22); } if (config.ViewAllReports == 0) { year = DateTime.Now.AddMonths(-2); } DateTime DateConfig = year; DateTime OrderFromDate = DateConfig; DateTime OrderToDate = DateTime.Now; if (!String.IsNullOrEmpty(Request.QueryString["orderfromdate"])) { OrderFromDate = Convert.ToDateTime(Request.QueryString["orderfromdate"]); } if (!String.IsNullOrEmpty(Request.QueryString["ordertodate"])) { OrderToDate = Convert.ToDateTime(Request.QueryString["ordertodate"]).AddDays(1).AddMinutes(-1); } rOrderFromDate.SelectedDate = OrderFromDate; rOrderFromDate.MinDate = DateConfig; rOrderFromDate.MaxDate = DateTime.Now; rOrderToDate.SelectedDate = OrderToDate; rOrderToDate.MinDate = DateConfig; rOrderToDate.MaxDate = DateTime.Now; int OrderType = 0; int PaymentStatus = 0; var ExcuteStatus = new List <int>() { 1, 2, 3 }; int PaymentType = 0; var ShippingType = new List <int>(); string Discount = ""; string OtherFee = ""; string OrderNote = ""; string TextSearch = ""; string CreatedBy = ""; int TransportCompany = 0; int ShipperID = 0; int Page = 1; // add filter quantity string Quantity = ""; int QuantityFrom = 0; int QuantityTo = 0; // add filter seach type int SearchType = 0; // Trạng thái mã giảm giá int CouponStatus = 0; if (Request.QueryString["textsearch"] != null) { TextSearch = Request.QueryString["textsearch"].Trim(); } if (Request.QueryString["searchtype"] != null) { SearchType = Request.QueryString["searchtype"].ToInt(0); } if (Request.QueryString["ordertype"] != null) { OrderType = Request.QueryString["ordertype"].ToInt(0); } if (Request.QueryString["paymentstatus"] != null) { PaymentStatus = Request.QueryString["paymentstatus"].ToInt(0); } if (Request.QueryString["excutestatus"] != null) { ExcuteStatus.Clear(); ExcuteStatus.Add(Request.QueryString["excutestatus"].ToInt(0)); } if (Request.QueryString["paymenttype"] != null) { PaymentType = Request.QueryString["paymenttype"].ToInt(0); } if (Request.QueryString["shippingtype"] != null) { ShippingType.Add(Request.QueryString["shippingtype"].ToInt(0)); } if (Request.QueryString["discount"] != null) { Discount = Request.QueryString["discount"].ToString(); } if (Request.QueryString["otherfee"] != null) { OtherFee = Request.QueryString["otherfee"].ToString(); } if (Request.QueryString["ordernote"] != null) { OrderNote = Request.QueryString["ordernote"].ToString(); } if (Request.QueryString["createdby"] != null) { CreatedBy = Request.QueryString["createdby"]; } if (Request.QueryString["transportcompany"] != null) { TransportCompany = Request.QueryString["transportcompany"].ToInt(0); } if (Request.QueryString["shipperid"] != null) { ShipperID = Request.QueryString["shipperid"].ToInt(0); } if (Request.QueryString["Page"] != null) { Page = Request.QueryString["Page"].ToInt(); } // add filter quantity if (Request.QueryString["quantityfilter"] != null) { Quantity = Request.QueryString["quantityfilter"]; if (Quantity == "greaterthan") { QuantityFrom = Request.QueryString["quantity"].ToInt(); } else if (Quantity == "lessthan") { QuantityTo = Request.QueryString["quantity"].ToInt(); } else if (Quantity == "between") { QuantityFrom = Request.QueryString["quantitymin"].ToInt(); QuantityTo = Request.QueryString["quantitymax"].ToInt(); } } // Drop download có / không mã giảm giá if (Request.QueryString["couponstatus"] != null) { CouponStatus = Request.QueryString["couponstatus"].ToInt(0); } txtSearchOrder.Text = TextSearch; ddlSearchType.SelectedValue = SearchType.ToString(); ddlOrderType.SelectedValue = OrderType.ToString(); ddlExcuteStatus.SelectedValue = ExcuteStatus.Count() > 1 ? "0" : ExcuteStatus.FirstOrDefault().ToString(); ddlPaymentStatus.SelectedValue = PaymentStatus.ToString(); ddlPaymentType.SelectedValue = PaymentType.ToString(); ddlShippingType.SelectedValue = ShippingType.Count() > 0 ? ShippingType.FirstOrDefault().ToString() : "0"; ddlDiscount.SelectedValue = Discount; ddlOtherFee.SelectedValue = OtherFee; ddlOrderNote.SelectedValue = OrderNote; ddlCreatedBy.SelectedValue = CreatedBy; ddlTransportCompany.SelectedValue = TransportCompany.ToString(); ddlShipperFilter.SelectedValue = ShipperID.ToString(); // add filter quantity ddlQuantityFilter.SelectedValue = Quantity; if (Quantity == "greaterthan") { txtQuantity.Text = QuantityFrom.ToString(); txtQuantityMin.Text = "0"; txtQuantityMax.Text = "0"; } else if (Quantity == "lessthan") { txtQuantity.Text = QuantityTo.ToString(); txtQuantityMin.Text = "0"; txtQuantityMax.Text = "0"; } else if (Quantity == "between") { txtQuantity.Text = "0"; txtQuantityMin.Text = QuantityFrom.ToString(); txtQuantityMax.Text = QuantityTo.ToString(); } // Drop download có / không mã giảm giá ddlCouponStatus.SelectedValue = CouponStatus.ToString(); if (acc.RoleID != 0) { CreatedBy = acc.Username; ddlCreatedBy.Enabled = false; } // Create order fileter var filter = new OrderFilterModel() { search = TextSearch, searchType = SearchType, orderType = OrderType, excuteStatus = ExcuteStatus, paymentStatus = PaymentStatus, paymentType = PaymentType, shippingType = ShippingType, discount = Discount, otherFee = OtherFee, quantity = Quantity, quantityFrom = QuantityFrom, quantityTo = QuantityTo, orderCreatedBy = CreatedBy, orderFromDate = OrderFromDate, orderToDate = OrderToDate, transportCompany = TransportCompany, shipper = ShipperID, orderNote = OrderNote, couponStatus = CouponStatus }; // Create pagination var page = new PaginationMetadataModel() { currentPage = Page }; List <OrderList> rs = new List <OrderList>(); rs = OrderController.Filter(filter, ref page); pagingall(rs, page); ltrNumberOfOrder.Text = page.totalCount.ToString(); } }
public void LoadData() { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { DateTime DateConfig = new DateTime(2019, 12, 15); var config = ConfigController.GetByTop1(); if (config.ViewAllOrders == 1) { DateConfig = new DateTime(2018, 6, 22); } DateTime fromDate = DateTime.Today; DateTime toDate = DateTime.Now; if (!String.IsNullOrEmpty(Request.QueryString["fromdate"])) { fromDate = Convert.ToDateTime(Request.QueryString["fromdate"]); } if (!String.IsNullOrEmpty(Request.QueryString["todate"])) { toDate = Convert.ToDateTime(Request.QueryString["todate"]).AddDays(1).AddMinutes(-1); } rFromDate.SelectedDate = fromDate; rFromDate.MinDate = DateConfig; rFromDate.MaxDate = DateTime.Now; rToDate.SelectedDate = toDate; rToDate.MinDate = DateConfig; rToDate.MaxDate = DateTime.Now; string TextSearch = ""; string CreatedDate = "today"; int CategoryID = 0; string strColor = String.Empty; string strSize = String.Empty; int Page = 1; if (Request.QueryString["textsearch"] != null) { TextSearch = Request.QueryString["textsearch"].Trim(); } if (Request.QueryString["categoryid"] != null) { CategoryID = Request.QueryString["categoryid"].ToInt(); } if (Request.QueryString["createddate"] != null) { CreatedDate = Request.QueryString["createddate"]; } // Add filter valiable value if (Request.QueryString["color"] != null) { strColor = Request.QueryString["color"].Trim(); } if (Request.QueryString["size"] != null) { strSize = Request.QueryString["size"].Trim(); } if (Request.QueryString["Page"] != null) { Page = Request.QueryString["Page"].ToInt(); } txtSearchProduct.Text = TextSearch; ddlCategory.SelectedValue = CategoryID.ToString(); // Add filter valiable value ddlColor.SelectedValue = strColor; ddlSize.SelectedValue = strSize; // Create order fileter var filter = new ProductFilterModel() { search = TextSearch, category = CategoryID, fromDate = fromDate, toDate = toDate, color = strColor, size = strSize }; // Create pagination var page = new PaginationMetadataModel() { currentPage = Page }; int totalQuantityInput = 0; List <GoodsReceiptReport> a = new List <GoodsReceiptReport>(); a = StockManagerController.getGoodsReceiptReport(filter, ref page, ref totalQuantityInput); pagingall(filter, a, page); ltrNumberOfProduct.Text = String.Format("{0} sản phẩm - {1:#,###} cái", page.totalCount.ToString(), totalQuantityInput); } }
public void LoadData() { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { DateTime DateConfig = new DateTime(2019, 12, 15); var config = ConfigController.GetByTop1(); if (config.ViewAllOrders == 1) { DateConfig = new DateTime(2018, 6, 22); } DateTime OrderFromDate = DateConfig; DateTime OrderToDate = DateTime.Now; if (!String.IsNullOrEmpty(Request.QueryString["orderfromdate"])) { OrderFromDate = Convert.ToDateTime(Request.QueryString["orderfromdate"]); } if (!String.IsNullOrEmpty(Request.QueryString["ordertodate"])) { OrderToDate = Convert.ToDateTime(Request.QueryString["ordertodate"]).AddDays(1).AddMinutes(-1); } rOrderFromDate.SelectedDate = OrderFromDate; rOrderFromDate.MinDate = DateConfig; rOrderFromDate.MaxDate = DateTime.Now; rOrderToDate.SelectedDate = OrderToDate; rOrderToDate.MinDate = DateConfig; rOrderToDate.MaxDate = DateTime.Now; string TextSearch = ""; int TransportCompany = 0; var ShippingType = new List <int>() { 4, 5 }; int PaymentType = 0; int ShipperID = 0; int InvoiceStatus = 0; int DeliveryStatus = 0; string CreatedBy = ""; var isDeliverySession = false; int DeliveryTimes = 0; int Page = 1; if (Request.QueryString["textsearch"] != null) { TextSearch = Request.QueryString["textsearch"].Trim(); } if (Request.QueryString["transportcompany"] != null) { TransportCompany = Request.QueryString["transportcompany"].ToInt(0); } if (Request.QueryString["shippingtype"] != null) { ShippingType.Clear(); ShippingType.Add(Request.QueryString["shippingtype"].ToInt(0)); } if (Request.QueryString["paymenttype"] != null) { PaymentType = Request.QueryString["paymenttype"].ToInt(0); } if (Request.QueryString["shipperid"] != null) { ShipperID = Request.QueryString["shipperid"].ToInt(0); } if (Request.QueryString["invoicestatus"] != null) { InvoiceStatus = Request.QueryString["invoicestatus"].ToInt(0); } if (Request.QueryString["deliverystatus"] != null) { DeliveryStatus = Request.QueryString["deliverystatus"].ToInt(0); } if (Request.QueryString["createdby"] != null) { CreatedBy = Request.QueryString["createdby"]; } if (Request.QueryString["isdeliverysession"] != null) { isDeliverySession = true; } if (Request.QueryString["deliverytimes"] != null) { DeliveryTimes = Request.QueryString["deliverytimes"].ToInt(0); } if (Request.QueryString["Page"] != null) { Page = Request.QueryString["Page"].ToInt(); } txtSearchOrder.Text = TextSearch; ddlTransportCompany.SelectedValue = TransportCompany.ToString(); ddlShippingType.SelectedValue = ShippingType.Count() > 1 ? "0" : ShippingType.FirstOrDefault().ToString(); ddlPaymentType.SelectedValue = PaymentType.ToString(); ddlShipperFilter.SelectedValue = ShipperID.ToString(); ddlInvoiceStatus.SelectedValue = InvoiceStatus.ToString(); ddlDeliveryStatusFilter.SelectedValue = DeliveryStatus.ToString(); ddlCreatedBy.SelectedValue = CreatedBy.ToString(); ddlDeliveryTimes.SelectedValue = DeliveryTimes.ToString(); // Create order fileter var filter = new OrderFilterModel() { searchType = (int)SearchType.Order, search = TextSearch, excuteStatus = new List <int>() { (int)ExcuteStatus.Done }, paymentType = PaymentType, shippingType = ShippingType, orderCreatedBy = CreatedBy, // CreatedBy //orderDate = CreatedDate, // CreatedDate orderFromDate = OrderFromDate, orderToDate = OrderToDate, transportCompany = TransportCompany, // TransportCompany shipper = ShipperID, //deliveryStart = DeliveryStartAt, // DeliveryStartAt deliveryTimes = DeliveryTimes, // DeliveryTimes deliveryStatus = DeliveryStatus, invoiceStatus = InvoiceStatus, selected = isDeliverySession, account = acc }; // Create pagination var page = new PaginationMetadataModel() { currentPage = Page }; List <OrderList> rs = new List <OrderList>(); rs = OrderController.Filter(filter, ref page); var deliverySession = SessionController.getDeliverySession(acc); hdfSession.Value = JsonConvert.SerializeObject(deliverySession); // Đánh dấu check cho các order đã được check rs = rs.GroupJoin( deliverySession, ord => ord.ID, del => del.OrderID, (ord, del) => new { ord, del } ) .SelectMany( x => x.del.DefaultIfEmpty(), (parent, child) => { if (child != null) { parent.ord.CheckDelivery = true; } else { parent.ord.CheckDelivery = false; } return(parent); } ) .Select(x => x.ord) .Distinct() .ToList(); pagingall(rs, page); ltrNumberOfOrder.Text = page.totalCount.ToString(); if (acc.RoleID == 0) { ltrBtnDoneDelivery.Text = "<a id='doneDelivery' href='javascript:;' class='btn primary-btn fw-btn width-100' onclick='changeDoneDelivery()'><i class='fa fa-check' aria-hidden='true'></i> Cập nhật đã giao</a>"; } } }
/// <summary> /// Lấy tổng hợp các thông báo /// </summary> /// <param name="filter"></param> /// <param name="pagination"></param> /// <returns></returns> public List <FlutterNotificationCardModel> getNotifications(FlutterNotificationFilterModel filter, ref PaginationMetadataModel pagination) { if (String.IsNullOrEmpty(filter.kind)) { #region Tổng hợp các thông báo using (var con = new inventorymanagementEntities()) { var notifications = con.Notifications.Where(x => 1 == 1); if (!String.IsNullOrEmpty(filter.phone)) { notifications = notifications.Where(x => (x.Kind == NotificationKind.Promotion && (x.Phone == null || x.Phone == filter.phone)) || (x.Kind == NotificationKind.Notification && x.Phone == filter.phone) || x.Kind == NotificationKind.News ); } // Lấy tổng số record sản phẩm pagination.totalCount = notifications.Count(); // Calculating Totalpage by Dividing (No of Records / Pagesize) pagination.totalPages = (int)Math.Ceiling(pagination.totalCount / (double)pagination.pageSize); var data = notifications .OrderByDescending(o => o.ModifiedDate) .Skip((pagination.currentPage - 1) * pagination.pageSize) .Take(pagination.pageSize); // if CurrentPage is greater than 1 means it has previousPage pagination.previousPage = pagination.currentPage > 1 ? "Yes" : "No"; // if TotalPages is greater than CurrentPage means it has nextPage pagination.nextPage = pagination.currentPage < pagination.totalPages ? "Yes" : "No"; #region Lấy thông báo khuyến mãi var notifyPromotions = data.Where(x => x.Kind == NotificationKind.Promotion) .Join( con.NotifyPromotions, d => d.NotifyID, p => p.ID, (d, p) => new { kind = d.Kind, notifyID = p.ID, action = p.Action, name = p.Title, actionValue = p.Action == FlutterPageNavigation.ViewMore ? "notification/promotion/" + p.ActionValue : p.ActionValue, image = p.Thumbnail, message = p.Summary, createdDate = p.CreatedDate } ) .ToList(); #endregion #region Lấy thông báo hoạt động của user var notifyUsers = data.Where(x => x.Kind == NotificationKind.Notification) .Join( con.NotifyUsers, d => d.NotifyID, p => p.ID, (d, p) => new { kind = d.Kind, notifyID = p.ID, action = p.Action, name = p.Title, actionValue = p.Action == FlutterPageNavigation.ViewMore ? "notification/user/" + p.ActionValue : p.ActionValue, image = p.Thumbnail, message = p.Summary, createdDate = p.CreatedDate } ) .ToList(); #endregion #region Lấy thông báo tin tức var notifyNews = data.Where(x => x.Kind == NotificationKind.News) .Join( con.NotifyNews, d => d.NotifyID, p => p.ID, (d, p) => new { kind = d.Kind, notifyID = p.ID, action = p.Action, name = p.Title, actionValue = p.Action == FlutterPageNavigation.ViewMore ? "notification/news/" + p.ActionValue : p.ActionValue, image = p.Thumbnail, message = p.Summary, createdDate = p.CreatedDate } ) .ToList(); #endregion #region Lấy thông tin của tất cả thông báo var result = data.ToList() .GroupJoin( notifyPromotions, d => new { kind = d.Kind, notifyID = d.NotifyID }, p => new { kind = p.kind, notifyID = p.notifyID }, (d, p) => new { notify = d, promotion = p } ) .SelectMany( x => x.promotion.DefaultIfEmpty(), (parent, child) => new { notify = parent.notify, promotion = child } ) .GroupJoin( notifyUsers, temp => new { kind = temp.notify.Kind, notifyID = temp.notify.NotifyID }, u => new { kind = u.kind, notifyID = u.notifyID }, (temp, u) => new { notify = temp.notify, promotion = temp.promotion, user = u } ) .SelectMany( x => x.user.DefaultIfEmpty(), (parent, child) => new { notify = parent.notify, promotion = parent.promotion, user = child } ) .GroupJoin( notifyNews, temp => new { kind = temp.notify.Kind, notifyID = temp.notify.NotifyID }, n => new { kind = n.kind, notifyID = n.notifyID }, (temp, n) => new { notify = temp.notify, promotion = temp.promotion, user = temp.user, news = n } ) .SelectMany( x => x.news.DefaultIfEmpty(), (parent, child) => new { notify = parent.notify, promotion = parent.promotion, user = parent.user, news = child } ) .Select(x => { var kind = x.notify.Kind; if (x.notify.Kind == NotificationKind.Promotion && x.promotion != null) { return(new FlutterNotificationCardModel() { kind = x.promotion.kind, action = x.promotion.action, name = x.promotion.name, actionValue = x.promotion.actionValue, image = x.promotion.image, message = x.promotion.message, createdDate = x.promotion.createdDate }); } if (x.notify.Kind == NotificationKind.Notification && x.user != null) { return(new FlutterNotificationCardModel() { kind = x.user.kind, action = x.user.action, name = x.user.name, actionValue = x.user.actionValue, image = x.user.image, message = x.user.message, createdDate = x.user.createdDate }); } if (x.notify.Kind == NotificationKind.News && x.news != null) { return(new FlutterNotificationCardModel() { kind = x.news.kind, action = x.news.action, name = x.news.name, actionValue = x.news.actionValue, image = x.news.image, message = x.news.message, createdDate = x.news.createdDate }); } return(new FlutterNotificationCardModel() { kind = x.notify.Kind, action = String.Empty, name = String.Empty, actionValue = String.Empty, image = String.Empty, message = String.Empty, createdDate = DateTime.Now }); }) .ToList(); #endregion return(result); } #endregion } else if (filter.kind == NotificationKind.Promotion) { return(getNotifyPromotionList(filter, ref pagination)); } else if (filter.kind == NotificationKind.Notification) { return(getNotifyUserList(filter, ref pagination)); } else if (filter.kind == NotificationKind.News) { return(getNotifyNewsList(filter, ref pagination)); } else { return(null); } }
public void pagingall(List <OrderList> acs, PaginationMetadataModel page) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); StringBuilder html = new StringBuilder(); html.Append("<thead>"); html.Append("<tr>"); html.Append(" <th><input id='checkPrintAll' type='checkbox' onchange='changeCheckPrintAll($(this).prop(`checked`))'/></th>"); html.Append(" <th>Mã</th>"); html.Append(" <th class='col-customer'>Khách hàng</th>"); html.Append(" <th>Mua</th>"); html.Append(" <th>Kiểu giao</th>"); html.Append(" <th>Thanh toán</th>"); html.Append(" <th>Shipper</th>"); html.Append(" <th>Trạng thái</th>"); html.Append(" <th>Tổng tiền</th>"); html.Append(" <th>COD</th>"); html.Append(" <th>Ship</th>"); html.Append(" <th>Ngày giao</th>"); html.Append(" <th>Đợt</th>"); html.Append(" <th>Ngày hoàn tất</th>"); if (acc.RoleID == 0 || acc.Username == "nhom_zalo406" || acc.Username == "hotline" || acc.Username == "nhom_zalo502") { html.Append(" <th>Nhân viên</th>"); } html.Append(" <th></th>"); html.Append("</tr>"); html.Append("</thead>"); html.Append("<tbody>"); if (acs.Count > 0) { PageCount = page.totalPages; Int32 Page = page.currentPage; foreach (var item in acs) { // Insert transfer bank info for tr tag var TrTag = new StringBuilder(); TrTag.AppendLine("<tr "); TrTag.AppendLine(String.Format("data-orderid='{0}' ", item.ID)); TrTag.AppendLine(String.Format("data-paymenttype='{0}' ", item.PaymentType)); TrTag.AppendLine(String.Format("data-shippingtype='{0}' ", item.ShippingType)); TrTag.AppendLine(String.Format("data-deliverystatus='{0}' ", item.DeliveryStatus)); TrTag.AppendLine(String.Format("data-invoiceimage='{0}' ", item.InvoiceImage)); TrTag.AppendLine(String.Format("data-coloford='{0:#,###}' ", item.CollectionOfOrder.HasValue ? item.CollectionOfOrder : Convert.ToDecimal(item.TotalPrice - item.TotalRefund))); TrTag.AppendLine(String.Format("data-shipperid='{0}' ", item.ShipperID)); TrTag.AppendLine(String.Format("data-cosofdev='{0:#,###}' ", item.CostOfDelivery.HasValue ? item.CostOfDelivery : Convert.ToDecimal(item.FeeShipping))); TrTag.AppendLine(String.Format("data-deliverydate='{0:dd/MM/yyyy HH:mm}' ", item.DeliveryDate)); TrTag.AppendLine(String.Format("data-shippernote='{0}' ", item.ShipNote)); TrTag.AppendLine(String.Format("data-transfercompany='{0}' ", item.TransportCompanyID)); TrTag.AppendLine(String.Format("data-deliverytimes='{0}' ", item.DeliveryTimes)); TrTag.AppendLine("/>"); html.Append(TrTag.ToString()); // Hình thức giáo hàng là chuyển xe // và gói hàng chưa được giao hoặc đang giao if (item.CheckDelivery.HasValue && item.CheckDelivery.Value) { html.Append(" <td><input type='checkbox' onchange='changeCheckPrint($(this))' checked/></td>"); } else { html.Append(" <td><input type='checkbox' onchange='changeCheckPrint($(this))'/></td>"); } html.Append(" <td><a href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.ID + "</a></td>"); if (!string.IsNullOrEmpty(item.Nick)) { html.Append(" <td data-title='Khách hàng' class='customer-td'><a class='col-customer-name-link' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.CustomerName.ToTitleCase() + "</a><br><span class='name-bottom-nick'>Nick: " + item.Nick.ToTitleCase() + "</span></td>"); } else { html.Append(" <td data-title='Khách hàng' class='customer-td'><a class='col-customer-name-link' href='/thong-tin-don-hang?id=" + item.ID + "'>" + item.CustomerName.ToTitleCase() + "</a></td>"); } html.Append(" <td data-title='Đã mua'>" + item.Quantity + "</td>"); html.Append(" <td data-title='Kiểu giao'>" + PJUtils.ShippingType(Convert.ToInt32(item.ShippingType)) + "</td>"); html.Append(" <td data-title='Kiểu thanh toán'>" + PJUtils.PaymentType(Convert.ToInt32(item.PaymentType)) + "</td>"); html.Append(" <td data-title='Shipper' id='shiperName'>" + item.ShipperName + "</td>"); html.Append(" <td data-title='Trạng thái' id='deliveryStatus'>" + PJUtils.DeliveryStatus(Convert.ToInt32(item.DeliveryStatus)) + "</td>"); // Tổng đơn hàng html.Append(" <td data-title='Tổng đơn'><strong>" + String.Format("{0:#,###}", Convert.ToDouble(item.TotalPrice - item.TotalRefund)) + "</strong></td>"); // Số tiền đã thu chỉ hiện khi thanh toán kiểu thu hộ và đơn hàng đã giao hoặc đang giao if (item.PaymentType == 3 && (item.DeliveryStatus == 1 || item.DeliveryStatus == 3)) { html.Append(" <td data-title='COD' id='colOfOrd'><strong>" + String.Format("{0:#,###}", item.CollectionOfOrder) + "</strong></td>"); } else { html.Append(" <td data-title='COD' id='colOfOrd'></td>"); } // Phí giao hàng khi nhân viên giao if (item.ShippingType == 5 && (item.DeliveryStatus == 1 || item.DeliveryStatus == 3) && item.CostOfDelivery != 0) { html.Append(" <td data-title='Ship' id='cosOfDel'><strong>" + String.Format("{0:#,###}", item.CostOfDelivery) + "</strong></td>"); } else { html.Append(" <td data-title='Ship' id='cosOfDel'></td>"); } // Ngày giao if (item.DeliveryStatus == 1) { html.Append(" <td data-title='Ngày giao' id='delDate'>" + String.Format("{0:dd/MM HH:mm}", item.DeliveryDate) + "</td>"); } else { html.Append(" <td data-title='Ngày giao' id='delDate'></td>"); } // Đợt giao if (item.DeliveryTimes > 0) { html.Append(" <td data-title='Đợt giao' id='deliveryTimes'>Đợt " + item.DeliveryTimes.ToString() + "</td>"); } else { html.Append(" <td data-title='Đợt giao' id='deliveryTimes'></td>"); } // Ngày hoàn tất đơn string datedone = ""; if (item.ExcuteStatus == 2) { datedone = string.Format("{0:dd/MM}", item.DateDone); } html.Append(" <td data-title='Ngày hoàn tất'>" + datedone + "</td>"); html.Append(" <td data-title='Nhân viên tạo đơn'>" + item.CreatedBy + "</td>"); html.Append(" <td data-title='Thao tác' class='update-button' id='updateButton'>"); if (acc.RoleID == 0) { html.Append(" <button type='button' class='btn primary-btn h45-btn' data-toggle='modal' data-target='#TransferBankModal' data-backdrop='static' data-keyboard='false' title='Cập nhật thông tin chuyển khoản'><span class='glyphicon glyphicon-edit'></span></button>"); } if (item.DeliveryStatus == 1 && !string.IsNullOrEmpty(item.InvoiceImage)) { html.Append(" <a id='downloadInvoiceImage' href='javascript:;' onclick='openImageInvoice($(this))' data-link='" + item.InvoiceImage + "' title='Biên nhận gửi hàng' class='btn primary-btn btn-blue h45-btn'><i class='fa fa-file-text-o' aria-hidden='true'></i></a>"); } html.Append(" </td>"); html.Append("</tr>"); // thông tin thêm html.Append("<tr class='tr-more-info'>"); html.Append(" <td colspan='2' data-title='Thông tin thêm'></td>"); html.Append(" <td colspan='14'>"); if (item.ShippingType == 4) { if (item.TransportCompanyID != 0) { var transport = TransportCompanyController.GetTransportCompanyForOrderList(Convert.ToInt32(item.TransportCompanyID)); var transportsub = TransportCompanyController.GetReceivePlaceForOrderList(Convert.ToInt32(item.TransportCompanyID), Convert.ToInt32(item.TransportCompanySubID)); html.Append("<span class='order-info'><strong>Gửi xe: </strong> " + transport.CompanyName.ToTitleCase() + " (" + transportsub.ShipTo.ToTitleCase() + ")</span>"); } } if (item.TotalRefund != 0) { html.Append("<span class='order-info'><strong>Đổi trả:</strong> -" + string.Format("{0:N0}", item.TotalRefund) + " (<a href='xem-don-hang-doi-tra?id=" + item.RefundsGoodsID + "' target='_blank'>Xem đơn " + item.RefundsGoodsID + "</a>)</span>"); } if (item.TotalDiscount > 0) { html.Append("<span class='order-info'><strong>Chiết khấu:</strong> -" + string.Format("{0:N0}", Convert.ToDouble(item.TotalDiscount)) + "</span>"); } if (item.OtherFeeValue != 0) { html.Append("<span class='order-info'><strong>Phí khác:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.OtherFeeValue)) + " (<a href='#feeInfoModal' data-toggle='modal' data-backdrop='static' onclick='openFeeInfoModal(" + item.ID + ")'>" + item.OtherFeeName.Trim() + "</a>)</span>"); } if (item.FeeShipping > 0) { html.Append("<span class='order-info'><strong>Ship:</strong> " + string.Format("{0:N0}", Convert.ToDouble(item.FeeShipping)) + "</span>"); } if (!string.IsNullOrEmpty(item.CouponCode)) { html.Append(String.Format("<span class='order-info'><strong>Coupon ({0}):</strong> -{1:N0}</span>", item.CouponCode.Trim().ToUpper(), item.CouponValue)); } if (!string.IsNullOrEmpty(item.OrderNote)) { html.Append("<span class='order-info'><strong>Ghi chú:</strong> " + item.OrderNote + "</span>"); } html.Append("</td>"); html.Append("</tr>"); } } else { if (acc.RoleID == 0) { html.Append("<tr><td colspan='14'>Không tìm thấy đơn hàng...</td></tr>"); } else { html.Append("<tr><td colspan='13'>Không tìm thấy đơn hàng...</td></tr>"); } } html.Append("</tbody>"); ltrList.Text = html.ToString(); }
/// <summary> /// Lấy thông báo khuyến mải tại bảng NotifyPromition /// </summary> /// <param name="filter"></param> /// <param name="pagination"></param> /// <returns></returns> private List <FlutterNotificationCardModel> getNotifyPromotionList(FlutterNotificationFilterModel filter, ref PaginationMetadataModel pagination) { using (var con = new inventorymanagementEntities()) { var notifyPromotions = con.NotifyPromotions.Where(x => 1 == 1); if (!String.IsNullOrEmpty(filter.categorySlug)) { var categories = _notifyCategory.getPostCategoryChild(filter.categorySlug); if (categories == null || categories.Count == 0) { return(null); } var categoriesID = categories.Select(x => x.id).ToList(); notifyPromotions = notifyPromotions.Where(x => categoriesID.Contains(x.ID)); } if (!String.IsNullOrEmpty(filter.phone)) { var groupsNotifyPromotion = base.getGroupNotifyPromotion(filter.phone); if (groupsNotifyPromotion == null || groupsNotifyPromotion.Count == 0) { return(null); } var groupsID = groupsNotifyPromotion.Select(x => x.ID).ToList(); notifyPromotions = notifyPromotions.Where(x => groupsID.Contains(x.GroupID)); } // Lấy tổng số record sản phẩm pagination.totalCount = notifyPromotions.Count(); // Calculating Totalpage by Dividing (No of Records / Pagesize) pagination.totalPages = (int)Math.Ceiling(pagination.totalCount / (double)pagination.pageSize); var result = notifyPromotions .OrderByDescending(o => o.ModifiedDate) .Select(x => new FlutterNotificationCardModel() { kind = filter.kind, action = x.Action, name = x.Title, actionValue = x.Action == FlutterPageNavigation.ViewMore ? "notification/promotion/" + x.ActionValue : x.ActionValue, image = x.Thumbnail, message = x.Summary, createdDate = x.CreatedDate }) .Skip((pagination.currentPage - 1) * pagination.pageSize) .Take(pagination.pageSize) .ToList(); // if CurrentPage is greater than 1 means it has previousPage pagination.previousPage = pagination.currentPage > 1 ? "Yes" : "No"; // if TotalPages is greater than CurrentPage means it has nextPage pagination.nextPage = pagination.currentPage < pagination.totalPages ? "Yes" : "No"; return(result); } }
public void pagingall(ProductFilterModel filter, List <GoodsReceiptReport> acs, PaginationMetadataModel page) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); StringBuilder html = new StringBuilder(); html.AppendLine("<thead>"); html.AppendLine("<tr>"); html.AppendLine(" <th class='stt-column'>#</th>"); html.AppendLine(" <th class='image-column'>Ảnh</th>"); html.AppendLine(" <th class='name-column'>Sản phẩm</th>"); html.AppendLine(" <th class='sku-column'>Mã</th>"); html.AppendLine(" <th class='stock-column'>Nhập mới</th>"); html.AppendLine(" <th class='stock-column'>Kho hiện tại</th>"); html.AppendLine(" <th class='category-column'>Danh mục</th>"); html.AppendLine(" <th class='date-column'>Ngày nhập</th>"); html.AppendLine(" <th class='action-column'></th>"); html.AppendLine("</tr>"); html.AppendLine("</thead>"); html.AppendLine("<tbody>"); if (acs.Count > 0) { PageCount = page.totalPages; Int32 Page = page.currentPage; int i = 0; foreach (var item in acs) { i++; html.AppendLine("<tr class='parent-row'>"); html.AppendLine(" <td>" + i + "</td>"); html.AppendLine(" <td>"); html.AppendLine(" <a href='/xem-san-pham?sku=" + item.sku + "'>"); html.AppendLine(" <img src='" + Thumbnail.getURL(item.image, Thumbnail.Size.Small) + "'/>"); html.AppendLine(" </a>"); html.AppendLine(" <a href='javascript:;' onclick='copyProductInfo(" + item.productID + ")' class='btn download-btn h45-btn'><i class='fa fa-files-o'></i> Copy</a>"); html.AppendLine(" </td>"); html.AppendLine(" <td class='customer-name-link'>"); html.AppendLine(" <a href='/xem-san-pham?sku=" + item.sku + "'>" + item.title + "</a></td>"); html.AppendLine(" </td>"); html.AppendLine(" <td data-title='Mã' class='customer-name-link'>" + item.sku + "</td>"); html.AppendLine(" <td data-title='Nhập mới'>" + String.Format("{0:N0}", item.quantityInput) + "</td>"); html.AppendLine(" <td data-title='Kho hiện tại'><a target='_blank' href='/thong-ke-san-pham?SKU=" + item.sku + "'>" + String.Format("{0:N0}", item.quantityStock) + "</a></td>"); html.AppendLine(" <td data-title='Danh mục'>" + item.categoryName + "</td>"); html.AppendLine(" <td data-title='Ngày tạo'>" + String.Format("{0:dd/MM/yyyy HH:mm}", item.goodsReceiptDate) + "</td>"); html.AppendLine(" <td data-title='Thao tác' class='update-button'>"); if (item.isVariable) { html.AppendLine(" <a href='javascript:;' title='Xem thông tin sản phẩm con' class='btn primary-btn h45-btn btn-blue' onclick='showSubGoodsReceipt($(this), `" + item.sku + "`)'>"); html.AppendLine(" <i class='fa fa-chevron-down' aria-hidden='true'></i>"); html.AppendLine(" </a>"); } html.AppendLine(" <a href='javascript:;' title='Download tất cả hình sản phẩm này' class='btn primary-btn h45-btn' onclick='getAllProductImage(`" + item.sku + "`);'><i class='fa fa-file-image-o' aria-hidden='true'></i></a>"); if (acc.RoleID == 0) { html.Append(" <a href='javascript:;' title='Đồng bộ sản phẩm' class='up-product-" + item.productID + " btn primary-btn h45-btn " + (item.showHomePage == 1 ? "" : "hide") + "' onclick='showProductSyncModal(`" + item.sku + "`, " + item.productID + ", " + item.categoryID + ");'><i class='fa fa-refresh' aria-hidden='true'></i></a>"); } html.AppendLine(" </td>"); html.AppendLine("</tr>"); var productVariables = StockManagerController.getSubGoodsReceipt(filter, item); foreach (var subItem in productVariables) { html.AppendLine("<tr class='" + item.sku + " child-row hide'>"); html.AppendLine(" <td></td>"); html.AppendLine(" <td></td>"); html.AppendLine(" <td>"); html.AppendLine(" <a href='/xem-san-pham?sku=" + subItem.sku + "'>"); html.AppendLine(" <img src='" + Thumbnail.getURL(subItem.image, Thumbnail.Size.Small) + "'/>"); html.AppendLine(" </a>"); html.AppendLine(" </td>"); html.AppendLine(" <td data-title='Mã' class='customer-name-link'>" + subItem.sku + "</td>"); html.AppendLine(" <td data-title='Nhập mới'>" + String.Format("{0:N0}", subItem.quantityInput) + "</td>"); html.AppendLine(" <td data-title='Kho hiện tại'><a target='_blank' href='/thong-ke-san-pham?SKU=" + subItem.sku + "'>" + String.Format("{0:N0}", subItem.quantityStock) + "</a></td>"); html.AppendLine(" <td data-title='Danh mục'></td>"); html.AppendLine(" <td data-title='Ngày nhập'>" + String.Format("{0:dd/MM/yyyy HH:mm}", subItem.goodsReceiptDate) + "</td>"); html.AppendLine(" <td data-title='Thao tác' class='update-button'></td>"); html.AppendLine("</tr>"); } } } else { html.Append("<tr><td colspan='11'>Không tìm thấy sản phẩm...</td></tr>"); } html.Append("</tbody>"); ltrList.Text = html.ToString(); }