public void LoadData() { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); string error = ""; String rowHtml = String.Empty; string PrintButton = ""; int ID = Request.QueryString["id"].ToInt(0); var order = OrderController.GetByID(ID); if (order == null) { error += "Không tìm thấy đơn hàng!"; } else { if (order.PaymentStatus == 1) { error += "<p>- Đơn hàng này <strong>Chưa thanh toán</strong>!</p>"; } if (order.ExcuteStatus != 2) { error += "<p>- Đơn hàng này <strong>Chưa hoàn tất</strong>!</p>"; } if (order.ShippingType == 1 && acc.RoleID != 0) { error += "<p>- Đơn hàng này <strong>Lấy trực tiếp</strong>. Hãy chuyển sang phương thức khác hoặc nhờ chị Ngọc in phiếu!</p>"; } if (order.PaymentType == 1 && acc.RoleID != 0) { error += "<p>- Đơn hàng này <strong>Thanh toán tiền mặt</strong>. Hãy chuyển sang phương thức khác hoặc nhờ chị Ngọc in phiếu!</p>"; } string address = ""; string phone = ""; string leader = ""; var agent = AgentController.GetByID(Convert.ToInt32(order.AgentID)); if (agent != null) { address = agent.AgentAddress; leader = agent.AgentLeader; phone = agent.AgentPhone; } double TotalOrder = Convert.ToDouble(order.TotalPrice); if (order.RefundsGoodsID != null) { var refund = RefundGoodController.GetByID(Convert.ToInt32(order.RefundsGoodsID)); if (refund != null) { TotalOrder = TotalOrder - Convert.ToDouble(refund.TotalPrice); } else { error += "<p>Không tìm thấy đơn hàng đổi trả " + order.RefundsGoodsID.ToString() + " (có thể đã bị xóa khi làm lại đơn đổi trả). Thêm lại đơn hàng đổi trả nhé!</p>"; } } var customer = CustomerController.GetByID(order.CustomerID.Value); string addressDetail = ""; string ProvinceName = ""; if (customer.ProvinceID.HasValue) { var Province = ProvinceController.GetByID(customer.ProvinceID.Value); addressDetail = ", " + Province.Name; ProvinceName = Province.Name; } if (customer.DistrictId.HasValue) { var District = ProvinceController.GetByID(customer.DistrictId.Value); addressDetail = ", " + District.Name + addressDetail; } if (customer.WardId.HasValue && customer.WardId.Value > 0) { var Ward = ProvinceController.GetByID(customer.WardId.Value); addressDetail = ", " + Ward.Name + addressDetail; } string CustomerAddress = order.CustomerAddress.ToTitleCase() + addressDetail; string DeliveryInfo = ""; string ShippingFeeInfo = ""; string ShipperFeeInfo = ""; // BƯU ĐIỆN if (order.ShippingType == 2) { if (!string.IsNullOrEmpty(order.ShippingCode)) { string PostalDeliveryType = "Thường"; if (order.PostalDeliveryType == 2) { PostalDeliveryType = "Nhanh"; } DeliveryInfo = String.Format("<p class='delivery'><strong>Bưu điện - {0}:</strong> {1}</p><p><img src='{2}'></p>", PostalDeliveryType, order.ShippingCode, createBarcode(order.ShippingCode)); } else { error += "<p>- Đơn hàng này <strong>gửi Bưu điện</strong> nhưng <strong>chưa nhập</strong> MÃ VẬN ĐƠN!</p>"; } if (order.PaymentType != 3 && acc.RoleID != 0) { PrintButton = "<a class='btn btn-black' href='javascript:;' onclick='printError(`Bưu điện`)'>Không in được</a>"; } } // PROSHIP else if (order.ShippingType == 3) { if (!string.IsNullOrEmpty(order.ShippingCode)) { DeliveryInfo = String.Format("<p class='delivery'><strong>Proship:</strong> {0}</p><p><img src='{1}'></p>", order.ShippingCode, createBarcode(order.ShippingCode)); } else { error += "<p>- Đơn hàng này <strong>gửi Proship</strong> nhưng <strong>chưa nhập</strong> MÃ VẬN ĐƠN!</p>"; } if (order.PaymentType != 3 && acc.RoleID != 0) { PrintButton = "<a class='btn btn-black' href='javascript:;' onclick='printError(`Proship`)'>Không in được</a>"; } } // GỬI XE else if (order.ShippingType == 4) { var company = TransportCompanyController.GetTransportCompanyForOrderList(Convert.ToInt32(order.TransportCompanyID)); if (company != null) { string transportCompany = ""; string transportCompanyPhone = ""; string transportCompanyAddress = ""; string transportCompanyNote = ""; transportCompany = "<strong>" + company.CompanyName.ToTitleCase() + "</strong>"; if (company.CompanyPhone != "") { transportCompanyPhone = "<span class='transport-info'>(" + company.CompanyPhone + ")</span>"; } transportCompanyAddress = "<span class='transport-info'>" + company.CompanyAddress.ToTitleCase() + "</span>"; if (company.Note != "") { transportCompanyNote = "<span class='transport-info capitalize'> - " + company.Note.ToTitleCase() + "</span>"; } var subID = Convert.ToInt32(order.TransportCompanySubID); var shipto = TransportCompanyController.GetReceivePlaceForOrderList(company.ID, subID); if (shipto != null && subID > 0) { if (!String.IsNullOrEmpty(ProvinceName)) { CustomerAddress = "<span class='phone'>" + shipto.ShipTo.ToTitleCase() + " (" + ProvinceName + ")</span>"; } else { CustomerAddress = "<span class='phone'>" + shipto.ShipTo.ToTitleCase() + "</span>"; } } else { error += "<p>- Đơn hàng này gửi xe " + transportCompany + " nhưng <strong>chưa chọn Nơi nhận</strong>!</p>"; } DeliveryInfo = String.Format("<p class='delivery'>Xe: {0} {1} {2}</p><p>{3}</p>", transportCompany, transportCompanyPhone, transportCompanyNote, transportCompanyAddress); } else { error += "<p>- Đơn hàng này <strong>gửi xe</strong> nhưng <strong>chưa chọn Chành xe</strong> nào!</p>"; } } // NHÂN VIÊN GIAO else if (order.ShippingType == 5) { DeliveryInfo = String.Format("<p class='delivery'>Nhân viên giao</p>"); } // GHTK else if (order.ShippingType == 6) { if (!string.IsNullOrEmpty(order.ShippingCode)) { string[] barcode = order.ShippingCode.Split('.'); string newCode = barcode[barcode.Length - 1]; if (newCode.Length < 9) { error += "<p>- MÃ VẬN ĐƠN của GHTK phải có ít nhất 9 số ở cuối!</p>"; } DeliveryInfo = String.Format("<p class='delivery'><strong>GHTK:</strong> {0}</p>", order.ShippingCode); DeliveryInfo += String.Format("<p><img src='{0}'></p>", createBarcode(newCode)); } else { error += "<p>- Đơn hàng này <strong>gửi GHTK</strong> nhưng <strong>chưa nhập</strong> MÃ VẬN ĐƠN!</p>"; } if (order.PaymentType != 3 && acc.RoleID != 0) { PrintButton = "<a class='btn btn-black' href='javascript:;' onclick='printError(`GHTK`)'>Không in được</a>"; } } // VIETTEL else if (order.ShippingType == 7) { DeliveryInfo = String.Format("<p class='delivery'><strong>Viettel</strong></p>"); } // Lấy tiền THU HỘ if (order.PaymentType == 3) { ShippingFeeInfo = String.Format("<p class='cod'>Thu hộ: {0}</p>", string.Format("{0:N0}", TotalOrder)); } else { ShippingFeeInfo = String.Format("<p class='cod'>Thu hộ: KHÔNG</p>"); } // Lấy phí nhân viên giao if (order.ShippingType == 5) { if (Convert.ToDouble(order.FeeShipping) > 0) { ShipperFeeInfo = String.Format("<p class='shipping-fee'>Phí ship (đã cộng vào thu hộ): {0}</p>", string.Format("{0:N0}", Convert.ToDouble(order.FeeShipping))); } else { ShipperFeeInfo = String.Format("<p class='shipping-fee'>Phí ship: không</p>"); } } // Lấy số điện thoại 2 nếu có string CustomerPhone = order.CustomerPhone; if (!string.IsNullOrEmpty(customer.CustomerPhone2)) { CustomerPhone += " - " + customer.CustomerPhone2; } // Lấy logo ANN string LogoANN = ""; if (order.ShippingType != 2 && order.ShippingType != 3 && order.ShippingType != 6) { LogoANN = String.Format("<img class='img' src='https://ann.com.vn/wp-content/uploads/ANN-logo-3.png'>"); } // Xử lý phiếu GHTK string cssClass = ""; string bodyClass = ""; string destination = ""; if (order.ShippingType == 6 && !string.IsNullOrEmpty(order.ShippingCode)) { string[] barcode = order.ShippingCode.Split('.'); if (barcode.Length < 6 && barcode.Length > 3) { destination = String.Format("<p>{0}.{1}</p>", barcode[barcode.Length - 3], barcode[barcode.Length - 2]); } else if (barcode.Length >= 6) { destination = String.Format("<p>{0}.{1}.{2}</p>", barcode[barcode.Length - 4], barcode[barcode.Length - 3], barcode[barcode.Length - 2]); } } if (destination != "") { bodyClass = "table-ghtk"; } // HTML in phiếu gửi hàng rowHtml += Environment.NewLine + String.Format("<div class='table {0}'>", bodyClass); rowHtml += Environment.NewLine + String.Format(" <div class='top-left'>"); rowHtml += Environment.NewLine + String.Format(" <p>Người gửi: <span class='name'>{0}</span></p>", leader); rowHtml += Environment.NewLine + String.Format(" <p>{0}</p>", phone); rowHtml += Environment.NewLine + String.Format(" <p class='agent-address'>{0}</p>", address); rowHtml += Environment.NewLine + String.Format(" <p class='web'>ANN.COM.VN</p>"); rowHtml += Environment.NewLine + String.Format(" </div>"); rowHtml += Environment.NewLine + String.Format(" <div class='bottom-left'>"); rowHtml += Environment.NewLine + String.Format(" {0}", ShippingFeeInfo); rowHtml += Environment.NewLine + String.Format(" <p>Nhân viên: {0}</p>", order.CreatedBy); rowHtml += Environment.NewLine + String.Format(" <p><img src='{0}'></p>", createBarcode(order.ID.ToString())); rowHtml += Environment.NewLine + String.Format(" <p>Mã đơn hàng: {0}</p>", order.ID); rowHtml += Environment.NewLine + String.Format(" </div>"); rowHtml += Environment.NewLine + String.Format(" <div class='top-right'>"); rowHtml += Environment.NewLine + String.Format(" {0}", LogoANN); rowHtml += Environment.NewLine + String.Format(" {0}", DeliveryInfo); rowHtml += Environment.NewLine + String.Format(" {0}", ShippingFeeInfo); rowHtml += Environment.NewLine + String.Format(" {0}", ShipperFeeInfo); rowHtml += Environment.NewLine + String.Format(" </div>"); rowHtml += Environment.NewLine + String.Format(" <div class='bottom-right'>"); rowHtml += Environment.NewLine + String.Format(" <p>Người nhận: <span class='name'>{0}</span></p>", order.CustomerName.ToTitleCase()); rowHtml += Environment.NewLine + String.Format(" <p>Điện thoại: <span class='phone'>{0}</span></p>", CustomerPhone); rowHtml += Environment.NewLine + String.Format(" <p>Địa chỉ: <span class='address'>{0}</span></p>", CustomerAddress); rowHtml += Environment.NewLine + String.Format(" </div>"); if (destination != "") { rowHtml += Environment.NewLine + String.Format(" <div class='rotated ghtk'>"); rowHtml += Environment.NewLine + String.Format(" {0}", destination); rowHtml += Environment.NewLine + String.Format(" </div>"); cssClass = "margin-left-ghtk"; } rowHtml += Environment.NewLine + String.Format(" <div class='rotated {0}'>", cssClass); rowHtml += Environment.NewLine + String.Format(" KHO HÀNG SỈ ANN"); rowHtml += Environment.NewLine + String.Format(" </div>"); rowHtml += Environment.NewLine + String.Format("</div>"); // Kết thúc HTML in phiếu gửi hàng } /// Hiển thị lỗi nếu có if (error != "") { ltrShippingNote.Text = "<h1>Lỗi:</h1>" + error; } else { ltrShippingNote.Text = rowHtml; ltrPrintButton.Text = "<div class='print-it'>"; if (!string.IsNullOrEmpty(PrintButton)) { ltrPrintButton.Text += PrintButton; ltrDisablePrint.Text = "<style type='text/css' media='print'>* { display: none; }</style>"; ltrDisablePrint.Text += "<script type='text/javascript'>jQuery(document).bind('keyup keydown', function(e){ if (e.ctrlKey && e.keyCode == 80){ return false;}});</script>"; } else { ltrPrintButton.Text += "<a class='btn' href='javascript:;' onclick='printIt()'>In phiếu gửi hàng</a>"; } if (order.ShippingType == 4) { ltrPrintButton.Text += "<a class='btn show-transport-info' href='javascript:;' onclick='showTransportInfo()'>Hiện thông tin nhà xe</a>"; } if (order.ShippingType == 3 && order.PaymentType == 3) { ltrPrintButton.Text += "<a class='btn show-transport-info' href='https://proship.vn/quan-ly-van-don/?isInvoiceFilter=1&generalInfo=" + order.ShippingCode + "' target='_blank'>Kiểm tra thu hộ trên Proship</a>"; } ltrPrintButton.Text += "</div>"; } }
public void pagingall(List <CustomerOut> acs) { string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); int PageSize = 30; StringBuilder html = new StringBuilder(); html.Append("<tr>"); html.Append(" <th class='image-column'>Ảnh</th>"); html.Append(" <th class='nick-column'>Nick đặt hàng</th>"); html.Append(" <th class='name-column'>Họ tên</th>"); html.Append(" <th class='phone-column'>Điện thoại</th>"); html.Append(" <th class='zalo-column'>Zalo</th>"); html.Append(" <th class='facebook-column'>FB</th>"); html.Append(" <th class='province-column'>Tỉnh</th>"); html.Append(" <th class='buy-column'>Đơn</th>"); html.Append(" <th class='buy-column'>Mua</th>"); if (acc.RoleID == 0) { html.Append(" <th class='staff-column'>Nhân viên</th>"); } html.Append(" <th class='group-column'>Nhóm</th>"); html.Append(" <th class='date-column'>Ngày tạo</th>"); html.Append(" <th class='action-column'></th>"); html.Append("</tr>"); if (acs.Count > 0) { int TotalItems = acs.Count; if (TotalItems % PageSize == 0) { PageCount = TotalItems / PageSize; } else { PageCount = TotalItems / PageSize + 1; } Int32 Page = GetIntFromQueryString("Page"); if (Page == -1) { Page = 1; } int FromRow = (Page - 1) * PageSize; int ToRow = Page * PageSize - 1; if (ToRow >= TotalItems) { ToRow = TotalItems - 1; } for (int i = FromRow; i < ToRow + 1; i++) { var item = acs[i]; html.Append("<tr>"); var order = OrderController.GetByCustomerID(item.ID); int TotalQuantity = 0; int TotalOrder = 0; if (order != null) { foreach (var temp in order) { var detail = OrderDetailController.GetByOrderID(temp.ID); TotalOrder++; if (detail != null) { foreach (var vl in detail) { TotalQuantity += Convert.ToInt32(vl.Quantity); } } } } html.Append(" <td><a href=\"/chi-tiet-khach-hang?id=" + item.ID + "\"><img src=\"" + item.Avatar + "\"/></a></td>"); html.Append(" <td class=\"customer-name-link capitalize\">" + item.Nick + "</td>"); html.Append(" <td class=\"customer-name-link capitalize\"><a href=\"/chi-tiet-khach-hang?id=" + item.ID + "\">" + item.CustomerName + "</a></td>"); html.Append(" <td>" + item.CustomerPhone + "</td>"); html.Append(" <td>" + item.Zalo + "</td>"); if (!string.IsNullOrEmpty(item.Facebook)) { html.Append(" <td><a class=\"link\" href=\"" + item.Facebook + "\" target=\"_blank\">Xem</a></td>"); } else { html.Append(" <td></td>"); } if (!string.IsNullOrEmpty(item.Province)) { var pro = ProvinceController.GetByID(item.Province.ToInt()); if (pro != null) { html.Append(" <td>" + pro.ProvinceName + "</td>"); } else { html.Append(" <td></td>"); } } else { html.Append(" <td></td>"); } if (TotalOrder > 0) { html.Append(" <td>" + TotalOrder + " đơn</td>"); } else { html.Append(" <td></td>"); } if (TotalQuantity > 0) { html.Append(" <td>" + TotalQuantity + " cái</td>"); } else { html.Append(" <td></td>"); } if (acc.RoleID == 0) { html.Append(" <td>" + item.CreatedBy + "</td>"); } if (!string.IsNullOrEmpty(item.DiscountName)) { string[] dis = item.DiscountName.Split('|'); if (dis.Count() > 1) { html.Append(" <td>" + dis[0] + "</br>" + dis[1] + "</td>"); } } else { html.Append(" <td>" + item.DiscountName + "</td>"); } string date = string.Format("{0:dd/MM/yyyy}", item.CreatedDate); html.Append(" <td>" + date + "</td>"); string ishidden = ""; if (item.IsHidden != null) { bool IsHidden = Convert.ToBoolean(item.IsHidden); ishidden = PJUtils.IsHiddenStatus(IsHidden); } else { ishidden = PJUtils.IsHiddenStatus(false); } html.Append(" <td>"); html.Append(" <a href=\"/danh-sach-don-hang?textsearch=" + item.CustomerPhone + "\" title=\"Xem đơn hàng\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-shopping-cart\" aria-hidden=\"true\"></i></a>"); html.Append(" </td>"); html.Append("</tr>"); } } else { if (acc.RoleID == 0) { html.Append("<tr><td colspan=\"12\">Không tìm thấy khách hàng...</td></tr>"); } else { html.Append("<tr><td colspan=\"11\">Không tìm thấy khách hàng...</td></tr>"); } } ltrList.Text = html.ToString(); }