public static List <ReceivedProductHistory> getReceivedProductHistories(int registerID, string sku) { return(RegisterProductController.GetReceivedProductHistory(registerID, sku)); }
public void pagingall(List <RegisterProductList> 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='col-checkbox'><input id='checkRegisterAll' type='checkbox'/></th>"); html.AppendLine(" <th class='col-image'>Ảnh</th>"); html.AppendLine(" <th class='col-customer'>Khách hàng</th>"); html.AppendLine(" <th class='col-product'>Sản phẩm</th>"); html.AppendLine(" <th class='col-color'>Màu</th>"); html.AppendLine(" <th class='col-size'>Size</th>"); html.AppendLine(" <th class='col-quantity-request'>Đặt</th>"); html.AppendLine(" <th class='col-quantity-in'>Về</th>"); html.AppendLine(" <th class='col-status'>Trạng thái</th>"); html.AppendLine(" <th class='col-createdby'>Nhân viên</th>"); html.AppendLine(" <th class='col-createddate'>Ngày đặt</th>"); html.AppendLine(" <th class='col-datein'>Ngày về</th>"); html.AppendLine(" <th class='col-action'></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) { var receivedProduct = RegisterProductController.GetReceivedProductHistory(item.id) .GroupBy(g => new { registerID = g.RegisterID, sku = g.SKU, image = g.Image, color = g.Color, size = g.Size }) .Select(x => new { registerID = x.Key.registerID, sku = x.Key.sku, image = x.Key.image, color = x.Key.color, size = x.Key.size, quantity = x.Sum(s => s.Quantity), receivedDate = x.Max(m => m.ReceivedDate) }) .ToList(); // Insert transfer bank info for tr tag var TrTag = new StringBuilder(); TrTag.AppendLine("<tr class='parent-row'"); TrTag.AppendLine(String.Format("data-registerid='{0}' ", item.id)); TrTag.AppendLine(String.Format("data-customer='{0}' ", item.customer)); TrTag.AppendLine(String.Format("data-status='{0}' ", item.status)); TrTag.AppendLine(String.Format("data-variableid='{0}' ", item.variableID)); TrTag.AppendLine(String.Format("data-sku='{0}' ", item.sku)); TrTag.AppendLine(String.Format("data-productstyle='{0}' ", item.productStyle)); TrTag.AppendLine(String.Format("data-numberchild='{0:#,###}' ", item.numberchild)); TrTag.AppendLine(String.Format("data-quantity='{0:#,###}' ", item.quantity)); TrTag.AppendLine(String.Format("data-expecteddate='{0:dd/MM/yyyy HH:mm}' ", item.expectedDate)); TrTag.AppendLine(String.Format("data-note1='{0}' ", item.note1)); TrTag.AppendLine(String.Format("data-note2='{0}' ", item.note2)); TrTag.AppendLine("/>"); html.AppendLine(TrTag.ToString()); html.AppendLine(" <td><input type='checkbox' onchange='checkRegister($(this))'/></td>"); html.AppendLine(" <td data-title='Ảnh'><a target='_blank' href='/xem-san-pham?sku=" + item.sku + "'><img src='" + Thumbnail.getURL(item.image, Thumbnail.Size.Small) + "'></a></td>"); html.AppendLine(" <td data-title='Khách hàng' class='customer-td'><span class='name'>" + item.customer.ToTitleCase() + "</span>"); html.AppendLine(String.Format(" <br><span class='note1'>{0}</span>", String.IsNullOrEmpty(item.note1) ? String.Empty: "<strong>Nhân viên</strong>: " + item.note1)); html.AppendLine(String.Format(" <br><span class='note2'>{0}</span>", String.IsNullOrEmpty(item.note2) ? String.Empty : "<strong>Quản lý</strong>: " + item.note2)); html.AppendLine(" </td>"); html.AppendLine(" <td data-title='Sản phẩm'>" + item.sku + "<br/><a target='_blank' href='/xem-san-pham?sku=" + item.sku + "'>" + item.title + "</a></td>"); html.AppendLine(" <td data-title='Màu'>" + item.color + "</td>"); html.AppendLine(" <td data-title='Size'>" + item.size + "</td>"); if (item.productStyle == 2 && item.variableID == 0) { html.AppendLine(String.Format(" <td class='totalQuantity' data-title='Số lượng hàng đặt'>{0:#,###}<br/>({1})</td>", item.numberchild * item.quantity, item.quantity)); } else { html.AppendLine(" <td class='totalQuantity' data-title='Số lượng hàng đặt'>" + String.Format("{0:#,###}", item.quantity) + "</td>"); } html.AppendLine(" <td class='totalReceivedQuantity' data-title='Số lượng hàng về'>" + String.Format("{0:#,###}", receivedProduct.Sum(s => s.quantity)) + "</td>"); html.AppendLine(" <td id='status' data-title='Trạng thái'>"); switch (item.status) { case (int)RegisterProductStatus.Approve: html.AppendLine(" <span class='bg-green'>" + item.statusName + "</span>"); break; case (int)RegisterProductStatus.Ordering: html.AppendLine(" <span class='bg-yellow'>" + item.statusName + "</span>"); break; case (int)RegisterProductStatus.Done: html.AppendLine(" <span class='bg-blue'>" + item.statusName + "</span>"); break; default: html.AppendLine(" <span class='bg-red'>" + item.statusName + "</span>"); break; } html.AppendLine(" </td>"); html.AppendLine(" <td data-title='Nhân viên'>" + item.staffName + "</td>"); html.AppendLine(" <td data-title='Ngày đặt'>" + String.Format("{0:dd/MM}", item.createdDate) + "</td>"); if (receivedProduct.Count > 0) { html.AppendLine(" <td id='expectedDate' data-title='Ngày về dự kiến'>" + String.Format("{0:dd/MM}", receivedProduct.Max(m => m.receivedDate)) + "</td>"); } else { html.AppendLine(" <td id='expectedDate' data-title='Ngày về dự kiến'>" + String.Format("{0:dd/MM}", item.expectedDate) + "</td>"); } html.AppendLine(" <td data-title='Thao tác' class='update-button' id='updateButton'>"); html.AppendLine(" <button type='button' class='btn primary-btn h45-btn' data-toggle='modal' data-target='#RegisterProductModal' data-backdrop='static' data-keyboard='false' title='Cập nhật thông yêu cầu nhập hàng'>"); html.AppendLine(" <span class='glyphicon glyphicon-edit'></span>"); html.AppendLine(" </button>"); if (acc.RoleID == 0) { html.AppendLine(" <button type='button' class='btn primary-btn remove-btn h45-btn' title='Hủy yêu cầu nhập hàng' onclick='removeRegister(" + item.id + ")'>"); html.AppendLine(" <span class='glyphicon glyphicon-trash'></span>"); html.AppendLine(" </button>"); } html.AppendLine(" <br/>"); if (item.productStyle == 2 && item.variableID == 0) { html.AppendLine(" <button type='button'"); html.AppendLine(" class='btn primary-btn btn-blue h45-btn show-sub-product'"); html.AppendLine(" title='Xem thông tin sản phẩm con'"); html.AppendLine(" data-status='false'"); if (receivedProduct.Count == 0) { html.AppendLine(" style='display:none;'"); } html.AppendLine(" >"); html.AppendLine(" <span class='glyphicon glyphicon-chevron-down'></span>"); html.AppendLine(" </button>"); } else { html.AppendLine(" <button type='button'"); html.AppendLine(" class='btn primary-btn btn-blue h45-btn show-received-product-histories'"); html.AppendLine(" title='Xem thông tin nhận hàng'"); html.AppendLine(String.Format(" onclick='showReceivedProductHistories({0}, `{1}`)'", item.id, item.sku)); if (receivedProduct.Count == 0) { html.AppendLine(" style='display:none;'"); } html.AppendLine(" >"); html.AppendLine(" <span class='glyphicon glyphicon-list-alt'></span>"); html.AppendLine(" </button>"); } html.AppendLine(" <button type='button'"); html.AppendLine(" class='btn primary-btn btn-insert h45-btn'"); html.AppendLine(" title='Insert thông tin nhận hàng'"); html.AppendLine(String.Format(" onclick='getReceivedProduct({0}, `{1}`, `{2:yyyy-MM-dd}`)'", item.id, item.sku, item.createdDate)); html.AppendLine(" >"); html.AppendLine(" <span class='glyphicon glyphicon-import'></span>"); html.AppendLine(" </button>"); html.AppendLine(" </td>"); html.AppendLine("</tr>"); var subHTML = new StringBuilder(); foreach (var subItem in receivedProduct) { subHTML.AppendLine("<tr class='child-row'"); subHTML.AppendLine(" data-registerid='" + subItem.registerID + "'"); subHTML.AppendLine(" data-sku='" + subItem.sku + "'"); subHTML.AppendLine(" style='display: none;'"); subHTML.AppendLine(" >"); subHTML.AppendLine(" <td></td>"); subHTML.AppendLine(" <td data-title='Ảnh'>"); subHTML.AppendLine(" <a target='_blank' href='/xem-san-pham?sku=" + subItem.sku + "'>"); subHTML.AppendLine(" <img src='/uploads/images/85x113/" + subItem.image + "' style='width: auto'>"); subHTML.AppendLine(" </a>"); subHTML.AppendLine(" </td>"); subHTML.AppendLine(" <td data-title='Mã'>" + subItem.sku + "</td>"); subHTML.AppendLine(" <td></td>"); subHTML.AppendLine(" <td data-title='Màu'>" + subItem.color + "</td>"); subHTML.AppendLine(" <td data-title='Size'>" + subItem.size + "</td>"); subHTML.AppendLine(" <td></td>"); subHTML.AppendLine(String.Format(" <td class='totalReceivedQuantity' data-title='Số lượng hàng về'>{0:#,###}</td>", subItem.quantity)); subHTML.AppendLine(" <td></td>"); subHTML.AppendLine(" <td></td>"); subHTML.AppendLine(" <td></td>"); subHTML.AppendLine(String.Format(" <td class='receivedDate' data-title='Ngày nhận hàng'>{0:dd/MM}</td>", subItem.receivedDate)); subHTML.AppendLine(" <td data-title='Thao tác' class='update-button' id='updateButton'>"); subHTML.AppendLine(" <button type='button'"); subHTML.AppendLine(" class='btn primary-btn btn-blue h45-btn'"); subHTML.AppendLine(" title='Xem thông tin lịch nhập hàng'"); subHTML.AppendLine(" onclick='showReceivedProductHistories(" + subItem.registerID + ", `" + subItem.sku + "`)'"); subHTML.AppendLine(" >"); subHTML.AppendLine(" <span class='glyphicon glyphicon-list-alt'></span>"); subHTML.AppendLine(" </button>"); subHTML.AppendLine(" </td>"); subHTML.AppendLine("</tr>"); } if (item.productStyle == 2 && item.variableID == 0 && !String.IsNullOrEmpty(subHTML.ToString())) { html.AppendLine(subHTML.ToString()); } } } else { if (acc.RoleID == 0) { html.AppendLine("<tr><td colspan=\"14\">Không tìm thấy đơn hàng...</td></tr>"); } else { html.AppendLine("<tr><td colspan=\"13\">Không tìm thấy đơn hàng...</td></tr>"); } } html.AppendLine("</tbody>"); ltrList.Text = html.ToString(); }