protected void btnAddCustomer_Click(object sender, EventArgs e) { if (discountGroupID != 0 && acc != null) { var customer = JsonConvert.DeserializeObject <CustomerModel>(hdfCustomer.Value); var order = JsonConvert.DeserializeObject <OrderModel>(hdfOrder.Value); if (customer != null) { var now = DateTime.Now; var data = new tbl_DiscountCustomer() { DiscountGroupID = discountGroupID, UID = customer.ID, CustomerName = customer.FullName, CustomerPhone = customer.Phone, IsHidden = false, CreatedDate = now, CreatedBy = acc.Username, ModifiedDate = now, ModifiedBy = acc.Username, VerifyOrder = order != null ? order.ID : 0 }; DiscountCustomerController.Insert(data); PJUtils.ShowMessageBoxSwAlert("Thêm khách hàng vào nhóm thành công", "s", true, Page); } else { PJUtils.ShowMessageBoxSwAlert("Vui lòng chọn khách hàng cần thêm", "e", true, Page); } } }
protected void btnLogin_Click(object sender, EventArgs e) { int groupID = Convert.ToInt32(ViewState["ID"]); string username = Request.Cookies["userLoginSystem"].Value; DateTime currentDate = DateTime.Now; var acc = AccountController.GetByUsername(username); if (acc != null) { if (acc.RoleID == 0) { int custID = ddlCustomer.SelectedValue.ToInt(0); if (custID > 0) { var cus = CustomerController.GetByID(custID); if (cus != null) { DiscountCustomerController.Insert(groupID, cus.ID, cus.CustomerName, cus.CustomerPhone, false, currentDate, username); PJUtils.ShowMessageBoxSwAlert("Thêm khách hàng vào nhóm thành công", "s", true, Page); } } else { PJUtils.ShowMessageBoxSwAlert("Vui lòng chọn khách hàng cần thêm", "e", true, Page); } } } }
public void LoadCustomerIn(int groupID) { var c = DiscountCustomerController.GetByGroupID(groupID); if (c.Count > 0) { pagingall(c.OrderBy(o => o.CustomerName).ToList()); } }
protected void btnDelete_Click(object sender, EventArgs e) { if (acc != null && acc.RoleID == 0) { var customer = JsonConvert.DeserializeObject <CustomerModel>(hdfCustomer.Value); if (customer != null) { DiscountCustomerController.Delete(customer.ID); PJUtils.ShowMessageBoxSwAlert("Xóa khách hàng ra khỏi nhóm thành công", "s", true, Page); } } }
public static string getCustomerDiscount(int ID) { var d = DiscountCustomerController.getbyCustID(ID); if (d.Count > 0) { var da = d[0].DiscountAmount; return(da.ToString()); } else { return("0"); } }
public static string getCustomerDiscount(int ID) { var d = DiscountCustomerController.getbyCustID(ID); if (d.Count > 0) { var ci = new CustomerGroup(); ci.Discount = d[0].DiscountAmount.ToString(); ci.FeeRefund = d[0].FeeRefund.ToString(); JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(ci)); } else { return("null"); } }
protected void btnDelete_Click(object sender, EventArgs e) { string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { if (acc.RoleID == 0) { int ID = hdfCustomerID.Value.ToInt(0); if (ID > 0) { var c = DiscountCustomerController.GetByID(ID); if (c != null) { DiscountCustomerController.Delete(c.ID); PJUtils.ShowMessageBoxSwAlert("Xóa khách hàng thành công", "s", true, Page); } } } } }
public static string getCustomerDetail(int ID) { var customer = CustomerController.GetByID(ID); if (customer != null) { var ci = new CustomerInfoWithDiscount(); ci.Customer = customer; ci.CreatedDate = customer.CreatedDate.ToString(); List <DiscountCustomerGet> dc = new List <DiscountCustomerGet>(); var d = DiscountCustomerController.getbyCustID(ID); if (d.Count > 0) { dc = d; } ci.AllDiscount = dc; JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(ci)); } else { return("null"); } }
public void LoadData() { int ID = Request.QueryString["id"].ToInt(0); if (ID > 0) { var order = OrderController.GetByID(ID); if (order == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng " + ID, "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } else { hdfOrderID.Value = order.ID.ToString(); string username = HttpContext.Current.Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); // check order condition if (acc.RoleID != 0) { if (order.ExcuteStatus == 4) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã chuyển hoàn", "w", false, "", Page); } else { if (order.CreatedBy != acc.Username) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của bạn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ExcuteStatus == 1) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này chưa hoàn tất nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ExcuteStatus == 3) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã hủy nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ShippingType == 1) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này lấy trực tiếp nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } } } else { if (order.ExcuteStatus == 4) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã chuyển hoàn", "w", false, "", Page); } else { if (order.ExcuteStatus == 1) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này chưa hoàn tất nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ExcuteStatus == 3) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã hủy nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ShippingType == 1) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này lấy trực tiếp nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } } } ViewState["ID"] = ID; Response.Cookies["odid"].Value = ID.ToString(); int AgentID = Convert.ToInt32(order.AgentID); txtPhone.Text = order.CustomerPhone; txtFullname.Text = order.CustomerName; txtAddress.Text = order.CustomerAddress; var cus = CustomerController.GetByID(order.CustomerID.Value); if (cus != null) { txtNick.Text = cus.Nick; txtZalo.Text = cus.Zalo; txtFacebook.Text = cus.Facebook; if (!string.IsNullOrEmpty(cus.Facebook)) { ltrFb.Text += "<a href =\"" + cus.Facebook + "\" class=\"btn primary-btn fw-btn not-fullwidth\" target=\"_blank\">Xem</a>"; } } int customerID = Convert.ToInt32(order.CustomerID); ltrViewDetail.Text = "<a href=\"javascript:;\" class=\"btn primary-btn fw-btn not-fullwidth\" onclick=\"viewCustomerDetail('" + customerID + "')\"><i class=\"fa fa-address-card-o\" aria-hidden=\"true\"></i> Xem chi tiết</a>"; ltrViewDetail.Text += "<a href=\"chi-tiet-khach-hang?id=" + customerID + "\" class=\"btn primary-btn fw-btn not-fullwidth edit-customer-btn\" target=\"_blank\"><i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\"></i> Chỉnh sửa</a>"; var d = DiscountCustomerController.getbyCustID(customerID); if (d.Count > 0) { var da = d[0].DiscountAmount; hdfIsDiscount.Value = "1"; hdfDiscountAmount.Value = da.ToString(); ltrDiscountInfo.Text = "<strong>Khách hàng được chiết khấu: " + string.Format("{0:N0}", Convert.ToDouble(da)) + " vnđ/sản phẩm.</strong>"; } else { hdfIsDiscount.Value = "0"; hdfDiscountAmount.Value = "0"; } int customerType = Convert.ToInt32(order.OrderType); ltrCustomerType.Text = ""; ltrCustomerType.Text += "<select disabled class=\"form-control customer-type\" onchange=\"getProductPrice($(this))\">"; if (customerType == 1) { ltrCustomerType.Text += "<option value=\"2\">Khách mua sỉ</option>"; ltrCustomerType.Text += "<option value=\"1\" selected>Khách mua lẻ</option>"; } else { ltrCustomerType.Text += "<option value=\"2\" selected>Khách mua sỉ</option>"; ltrCustomerType.Text += "<option value=\"1\">Khách mua lẻ</option>"; } ltrCustomerType.Text += "</select>"; double ProductQuantity = 0; double totalPrice = Convert.ToDouble(order.TotalPrice); double totalPriceNotDiscount = Convert.ToDouble(order.TotalPriceNotDiscount); hdfcheckR.Value = ""; int totalrefund = 0; if (order.RefundsGoodsID > 0) { var re = RefundGoodController.GetByID(order.RefundsGoodsID.Value); if (re != null) { totalrefund = Convert.ToInt32(re.TotalPrice); hdfcheckR.Value = order.RefundsGoodsID.ToString() + "," + re.TotalPrice; } ltrtotalpricedetail.Text = string.Format("{0:N0}", totalPrice - totalrefund); ltrTotalPriceRefund.Text = string.Format("{0:N0}", totalrefund); } hdfDiscountInOrder.Value = ""; if (order.DiscountPerProduct > 0) { hdfDiscountInOrder.Value = order.DiscountPerProduct.ToString(); } int paymentStatus = Convert.ToInt32(order.PaymentStatus); int excuteStatus = Convert.ToInt32(order.ExcuteStatus); int shipping = Convert.ToInt32(order.ShippingType); int TransportCompanyID = Convert.ToInt32(order.TransportCompanyID); int TransportCompanySubID = Convert.ToInt32(order.TransportCompanySubID); int PostalDeliveryType = Convert.ToInt32(order.PostalDeliveryType); int paymenttype = Convert.ToInt32(order.PaymentType); #region Lấy danh sách sản phẩm var orderdetails = OrderDetailController.GetByOrderID(ID); string html = ""; string Print = ""; if (orderdetails.Count > 0) { int t = 0; int orderitem = 0; foreach (var item in orderdetails) { ProductQuantity += Convert.ToDouble(item.Quantity); int ProductType = Convert.ToInt32(item.ProductType); int ProductID = Convert.ToInt32(item.ProductID); int ProductVariableID = Convert.ToInt32(item.ProductVariableID); double ItemPrice = Convert.ToDouble(item.Price); string SKU = item.SKU; double Giabansi = 0; double Giabanle = 0; string stringGiabansi = ""; string stringGiabanle = ""; double QuantityInstock = 0; string ProductImageOrigin = ""; string ProductVariable = ""; string ProductName = ""; int PID = 0; string ProductVariableName = ""; string ProductVariableValue = ""; string ProductVariableSave = ""; double QuantityMainInstock = 0; string ProductImage = ""; string QuantityMainInstockString = ""; string QuantityInstockString = ""; string productVariableDescription = item.ProductVariableDescrition; if (ProductType == 1) { PID = ProductID; var product = ProductController.GetBySKU(SKU); if (product != null) { double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); if (customerType == 1) { Giabansi = Convert.ToDouble(product.Regular_Price); Giabanle = ItemPrice; } else { Giabansi = ItemPrice; Giabanle = Convert.ToDouble(product.Retail_Price); } stringGiabansi = string.Format("{0:N0}", Giabansi); stringGiabanle = string.Format("{0:N0}", Giabanle); string variablename = ""; string variablevalue = ""; string variable = ""; QuantityInstock = mainstock; QuantityInstockString = string.Format("{0:N0}", mainstock); var img = ProductImageController.GetFirstByProductID(product.ID); if (!string.IsNullOrEmpty(product.ProductImage)) { ProductImage = "<img src=\"" + product.ProductImage + "\" />"; ProductImageOrigin = product.ProductImage; } else if (img != null) { ProductImage = "<img src=\"" + img.ProductImage + "\" />"; ProductImageOrigin = img.ProductImage; } else { ProductImage = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />"; ProductImageOrigin = ""; } ProductVariable = variable; ProductName = product.ProductTitle; QuantityMainInstock = mainstock; QuantityMainInstockString = string.Format("{0:N0}", mainstock); ProductVariableSave = item.ProductVariableDescrition; ProductVariableName = variablename; ProductVariableValue = variablevalue; } } else { PID = ProductVariableID; var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { SKU = productvariable.SKU.Trim().ToUpper(); double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); if (customerType == 1) { Giabansi = Convert.ToDouble(productvariable.Regular_Price); Giabanle = ItemPrice; } else { Giabansi = ItemPrice; Giabanle = Convert.ToDouble(productvariable.RetailPrice); } stringGiabansi = string.Format("{0:N0}", Giabansi); stringGiabanle = string.Format("{0:N0}", Giabanle); string variablename = ""; string variablevalue = ""; string variable = ""; string[] vs = productVariableDescription.Split('|'); if (vs.Length - 1 > 0) { for (int i = 0; i < vs.Length - 1; i++) { string[] items = vs[i].Split(':'); variable += items[0] + ":" + items[1] + "<br/>"; variablename += items[0] + "|"; variablevalue += items[1] + "|"; } } QuantityInstock = mainstock; QuantityInstockString = string.Format("{0:N0}", mainstock); var _product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (!string.IsNullOrEmpty(productvariable.Image)) { ProductImage = "<img src=\"" + productvariable.Image + "\" />"; ProductImageOrigin = productvariable.Image; } else if (_product != null && !string.IsNullOrEmpty(_product.ProductImage)) { ProductImage = "<img src=\"" + _product.ProductImage + "\" />"; ProductImageOrigin = _product.ProductImage; } else { ProductImage = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />"; ProductImageOrigin = ""; } ProductVariable = variable; if (_product != null) { ProductName = _product.ProductTitle; } QuantityMainInstock = mainstock; QuantityMainInstockString = string.Format("{0:N0}", mainstock); ProductVariableSave = item.ProductVariableDescrition; ProductVariableName = variablename; ProductVariableValue = variablevalue; } } orderitem++; html += "<tr class=\"product-result\" data-orderdetailid=\"" + item.ID + "\" data-giabansi=\"" + Giabansi + "\" data-giabanle=\"" + Giabanle + "\" " + "data-quantityinstock=\"" + QuantityInstock + "\" data-productimageorigin=\"" + ProductImageOrigin + "\" " + "data-productvariable=\"" + ProductVariable + "\" data-productname=\"" + ProductName + "\" " + "data-sku=\"" + SKU + "\" data-producttype=\"" + ProductType + "\" data-id=\"" + PID + "\" " + "data-productnariablename=\"" + ProductVariableName + "\" " + "data-productvariablevalue =\"" + ProductVariableValue + "\" " + "data-productvariablesave =\"" + ProductVariableSave + "\" " + "data-quantitymaininstock=\"" + QuantityMainInstock + "\">"; html += " <td class=\"order-item\">" + orderitem + ""; html += " <td class=\"image-item\">" + ProductImage + ""; html += " <td class=\"name-item\">" + ProductName + "</td>"; html += " <td class=\"sku-item\">" + SKU + "</td>"; html += " <td class=\"variable-item\">" + ProductVariable + "</td>"; html += " <td class=\"price-item gia-san-pham\" data-price=\"" + ItemPrice + "\">" + string.Format("{0:N0}", ItemPrice) + "</td>"; html += " <td class=\"quantity-item soluong\">" + QuantityInstockString + "</td>"; html += " <td class=\"quantity-item\"><input disabled data-quantity=\"" + item.Quantity + "\" value=\"" + item.Quantity + "\" type=\"text\" class=\"form-control in-quanlity\" value=\"1\" onblur=\"checkQuantiy($(this))\" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/></td>"; int k = Convert.ToInt32(ItemPrice) * Convert.ToInt32(item.Quantity); html += "<td class=\"total-item totalprice-view\">" + string.Format("{0:N0}", k) + "</td>"; html += " <td class=\"trash-item\"><a href=\"javascript:;\" class=\"link-btn\"><i class=\"fa fa-trash\"></i></a> </td>"; html += "</tr>"; Print += " <tr>"; t++; Print += "<td>" + t + "</td>"; Print += "<td>" + SKU + " - " + ProductName + " - " + ProductVariableSave.Replace("|", ", ") + "</td> "; Print += "<td>" + item.Quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>"; Print += "<td> " + string.Format("{0:N0}", k) + "</td>"; Print += "</tr>"; } ltrProducts.Text = html; } #endregion ddlPaymentStatus.SelectedValue = paymentStatus.ToString(); ddlExcuteStatus.SelectedValue = excuteStatus.ToString(); ddlPaymentType.SelectedValue = paymenttype.ToString(); ddlShippingType.SelectedValue = shipping.ToString(); ddlPostalDeliveryType.SelectedValue = PostalDeliveryType.ToString(); LoadTransportCompanySubID(TransportCompanyID); ddlTransportCompanyID.SelectedValue = TransportCompanyID.ToString(); ddlTransportCompanySubID.SelectedValue = TransportCompanySubID.ToString(); txtShippingCode.Text = order.ShippingCode; txtOrderNote.Text = order.OrderNote; ltrProductQuantity.Text = string.Format("{0:N0}", ProductQuantity) + " sản phẩm"; ltrTotalNotDiscount.Text = string.Format("{0:N0}", Convert.ToDouble(order.TotalPriceNotDiscount)); ltrTotalprice.Text = string.Format("{0:N0}", Convert.ToDouble(order.TotalPrice)); pDiscount.Value = order.DiscountPerProduct; pFeeShip.Value = Convert.ToDouble(order.FeeShipping); ltrOtherFeeName.Text = order.OtherFeeName; txtOtherFeeName.Text = order.OtherFeeName; pOtherFee.Value = Convert.ToDouble(order.OtherFeeValue); ltrTotalAfterCK.Text = string.Format("{0:N0}", (Convert.ToDouble(order.TotalPriceNotDiscount) - Convert.ToDouble(order.TotalDiscount))); ltrOrderID.Text = ID.ToString(); ltrCreateBy.Text = order.CreatedBy; ltrCreateDate.Text = order.CreatedDate.ToString(); ltrDateDone.Text = "Chưa hoàn tất"; if (order.DateDone != null) { ltrDateDone.Text = order.DateDone.ToString(); } ltrOrderNote.Text = order.OrderNote; ltrOrderQuantity.Text = ProductQuantity.ToString(); ltrOrderTotalPrice.Text = string.Format("{0:N0}", Convert.ToDouble(order.TotalPrice)); ltrOrderStatus.Text = PJUtils.OrderExcuteStatus(Convert.ToInt32(order.ExcuteStatus)); ltrOrderType.Text = PJUtils.OrderType(Convert.ToInt32(order.OrderType)); } } }
public static string checkphone(string phonefullname) { RefundCust rf = new RefundCust(); int AgentID = 0; string username = HttpContext.Current.Request.Cookies["usernameLoginSystem"].Value; if (!string.IsNullOrEmpty(username)) { var a = AccountController.GetByUsername(username); if (a != null) { AgentID = Convert.ToInt32(a.AgentID); } } var customer = CustomerController.GetByPhone(phonefullname); if (customer != null) { rf.CustName = customer.CustomerName; rf.CustPhone = customer.CustomerPhone; rf.CustZalo = customer.Zalo; rf.CustFB = customer.Facebook; rf.CustAddress = customer.CustomerAddress; int custID = customer.ID; double FeeRefund = 0; double NumOfDateToChangeProduct = 0; double NumOfProductCanChange = 0; var config = ConfigController.GetByTop1(); if (config != null) { FeeRefund = Convert.ToDouble(config.FeeChangeProduct); NumOfDateToChangeProduct = Convert.ToDouble(config.NumOfDateToChangeProduct); NumOfProductCanChange = Convert.ToDouble(config.NumOfProductCanChange); } var d = DiscountCustomerController.getbyCustID(custID); if (d.Count > 0) { FeeRefund = d[0].FeeRefund; NumOfDateToChangeProduct = d[0].NumOfDateToChangeProduct; NumOfProductCanChange = d[0].NumOfProductCanChange; } DateTime toDate = DateTime.Now.Date; var fromDate = toDate.AddDays(-NumOfDateToChangeProduct); double totalProductRefund = 0; var refundList = RefundGoodController.GetByAgentIDCustomerIDFromDateToDate(AgentID, custID, fromDate, toDate.AddDays(1)); if (refundList.Count > 0) { foreach (var item in refundList) { var rfD = RefundGoodDetailController.GetByRefundGoodsID(item.ID); if (rfD.Count > 0) { foreach (var fd in rfD) { totalProductRefund += Convert.ToDouble(fd.Quantity); } } } } double leftCanchange = NumOfProductCanChange - totalProductRefund; if (leftCanchange > 0) { rf.CustleftCanchange = leftCanchange.ToString(); JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(rf)); } else { rf.CustleftCanchange = "full"; JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(rf)); } } else { rf.CustleftCanchange = "nocustomer"; JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(rf)); } }
public static string getCustomerDiscount(int ID) { var now = DateTime.Now; var discount = DiscountCustomerController.getbyCustID(ID).FirstOrDefault(); var config = ConfigController.GetByTop1(); // Khởi tao object json bool isDiscount; var isUserApp = UserController.checkExists(userID: ID); var ci = new CustomerGroup(); var promotion = RefundGoodController.getPromotion(customerID: ID); if (discount != null) { // Phí đổi trả var feeRefund = discount.FeeRefund; // Tính số lượng hàng trã có phí var refundQuantityFee = Convert.ToInt32(discount.NumOfProductCanChange - discount.RefundQuantityNoFee); // Tính số lượng hàng đổi trả trong 30 ngày var fromDate = now.AddDays(-discount.NumOfDateToChangeProduct).Date; var toDate = now.Date; var customer = CustomerController.getRefundQuantity(ID, fromDate, toDate).FirstOrDefault(); var quantityNoFree = discount.RefundQuantityNoFee - (customer != null ? Convert.ToInt32(customer.refundNoFeeQuantity) : 0); var quantityFree = refundQuantityFee - (customer != null ? Convert.ToInt32(customer.refundFeeQuantity) : 0); isDiscount = discount.DiscountAmount > 0; quantityNoFree = quantityNoFree > 0 ? quantityNoFree : 0; quantityFree = quantityFree > 0 ? quantityFree : 0; if (promotion.IsPromotion) { isDiscount = true; feeRefund = feeRefund - promotion.DecreasePrice; if (feeRefund <= 0) { feeRefund = 0; quantityNoFree = quantityFree + quantityNoFree; quantityFree = 0; } } ci.IsDiscount = isDiscount; ci.Discount = discount.DiscountAmount.ToString(); ci.QuantityProduct = discount.QuantityProduct; ci.FeeRefund = feeRefund.ToString(); ci.DaysExchange = Convert.ToInt32(discount.NumOfDateToChangeProduct); ci.RefundQuantityNoFee = quantityNoFree; ci.RefundQuantityFee = quantityFree; ci.IsUserApp = isUserApp; JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(ci)); } else if (config != null) { // Phí đổi trả var feeRefund = config.FeeChangeProduct; // Tính số lượng hàng trã có phí var refundQuantityFee = config.NumOfProductCanChange.HasValue ? Convert.ToInt32(config.NumOfProductCanChange.Value) : 0; // Tính số lượng hàng đổi trả trong 30 ngày var days = config.NumOfDateToChangeProduct.HasValue ? config.NumOfDateToChangeProduct.Value : 0; var fromDate = now.AddDays(-days).Date; var toDate = now.Date; var customer = CustomerController.getRefundQuantity(ID, fromDate, toDate).FirstOrDefault(); var quantityFree = refundQuantityFee - (customer != null ? Convert.ToInt32(customer.refundNoFeeQuantity) : 0) - (customer != null ? Convert.ToInt32(customer.refundFeeQuantity) : 0); isDiscount = config.FeeDiscountPerProduct > 0; if (promotion.IsPromotion) { isDiscount = true; feeRefund = (feeRefund - promotion.DecreasePrice) < 0 ? 0 : feeRefund - promotion.DecreasePrice; } ci.IsDiscount = isDiscount; ci.Discount = config.FeeDiscountPerProduct.ToString(); ci.QuantityProduct = 0; ci.FeeRefund = feeRefund.ToString(); ci.DaysExchange = Convert.ToInt32(config.NumOfDateToChangeProduct); ci.RefundQuantityNoFee = 0; ci.RefundQuantityFee = quantityFree > 0 ? quantityFree : 0; ci.IsUserApp = isUserApp; JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(ci)); } else { return("null"); } }
public void LoadData() { int n; if (String.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out n)) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng", "e", true, "/danh-sach-don-tra-hang", Page); } string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { int AgentID = Convert.ToInt32(acc.AgentID); int ID = Request.QueryString["id"].ToInt(0); if (ID > 0) { ViewState["ID"] = ID; var r = RefundGoodController.GetByIDAndAgentID(ID, AgentID); if (r == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng " + ID, "e", true, "/danh-sach-don-tra-hang", Page); } else { if (acc.RoleID != 0) { // Kiểm tra nếu đơn hàng này không "chính chủ" if (r.CreatedBy != acc.Username) { // Kiểm tra đơn hàng này có đang được tạo giúp bởi nhân viên khác không? var usernameRequest = HttpContext.Current.Request["username"]; if (!String.IsNullOrEmpty(usernameRequest)) { var userRequest = AccountController.GetByUsername(usernameRequest); if (userRequest == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy nhân viên " + usernameRequest, "e", true, "/danh-sach-don-tra-hang", Page); } else { if (usernameRequest != r.CreatedBy) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của " + usernameRequest, "e", true, "/danh-sach-don-tra-hang", Page); } else { if (r.UserHelp != acc.Username) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải do bạn tạo giúp", "e", true, "/danh-sach-don-tra-hang", Page); } else { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này do bạn tạo giúp. Nhấn OK để tiếp tục xử lý!", "i", false, "", Page); } } } } else { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của bạn", "e", true, "/danh-sach-don-tra-hang", Page); } } } ltrCreateBy.Text = r.CreatedBy; ltrCreateDate.Text = r.CreatedDate.ToString(); ltrOrderStatus.Text = PJUtils.RefundStatus(Convert.ToInt32(r.Status)); if (r.OrderSaleID > 0) { ltrOrderSaleID.Text = "<td><a class='customer-name-link' target='_blank' title='Bấm vào xem đơn hàng trừ tiền' href='/thong-tin-don-hang?id=" + r.OrderSaleID + "'>" + r.OrderSaleID + " (Xem đơn)</a>"; } else { ltrOrderSaleID.Text = ""; } ltrOrderQuantity.Text = r.TotalQuantity.ToString(); ltrOrderTotalPrice.Text = string.Format("{0:N0}", (Convert.ToDouble(r.TotalPrice))); ltrTotalRefundFee.Text = string.Format("{0:N0}", (Convert.ToDouble(r.TotalRefundFee))); ltrRefundNote.Text = r.RefundNote; int cusID = 0; string zalo = ""; string nick = ""; string address = ""; string facebook = ""; var cus = CustomerController.GetByID(r.CustomerID.Value); if (cus != null) { cusID = cus.ID; zalo = cus.Zalo; nick = cus.Nick; address = cus.CustomerAddress; facebook = cus.Facebook; hdfCustomerPhone.Value = cus.CustomerPhone; } // Title this.Title = String.Format("{0} - Đổi trả", string.IsNullOrEmpty(nick) ? nick.ToTitleCase() : r.CustomerName.ToTitleCase()); ltrHeading.Text = "Đơn đổi trả " + ID.ToString() + " - " + (string.IsNullOrEmpty(nick) ? nick.ToTitleCase() : r.CustomerName.ToTitleCase()) + (!string.IsNullOrEmpty(r.UserHelp) ? " (được tạo giúp bởi " + r.UserHelp + ")" : ""); ltrInfo.Text += "<div class='row'>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Họ tên</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + r.CustomerName + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Điện thoại</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + r.CustomerPhone + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Nick đặt hàng</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + nick + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Facebook</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + facebook + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += "</div> "; ltrInfo.Text += "<div class='row'>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Tỉnh thành</label>"; ltrInfo.Text += " <select id='_ddlProvince' class='form-control' disable='true' readonly='readonly'></select>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Quận huyện</label>"; ltrInfo.Text += " <select id='_ddlDistrict' class='form-control' disable='true' readonly='readonly'></select>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Phường xã</label>"; ltrInfo.Text += " <select id='_ddlWard' class='form-control' disable='true' readonly='readonly'></select>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Địa chỉ</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + address + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "<div class='form-row view-detail'>"; ltrInfo.Text += " <a href='javascript:;' class='btn primary-btn fw-btn not-fullwidth' onclick='viewCustomerDetail(`" + cusID + "`)'><i class='fa fa-address-card-o' aria-hidden='true'></i> Xem</a>"; ltrInfo.Text += "</div>"; #region Thông tin phí đổi tra double feeRefundDefault = 0; var discount = DiscountCustomerController.getbyCustID(cusID).FirstOrDefault(); if (discount != null) { feeRefundDefault = discount.FeeRefund; ltrInfo.Text += "<div class='form-row discount-info'>"; ltrInfo.Text += String.Format(" <strong>* Chiết khấu của khách: {0:0,0}/cái. (đơn từ {1:N0} cái)</strong>", discount.DiscountAmount, discount.QuantityProduct); ltrInfo.Text += "</div>"; } else { var config = ConfigController.GetByTop1(); feeRefundDefault = config.FeeChangeProduct.Value; } var refundPromotion = RefundGoodController.getPromotion(cusID); if (refundPromotion.IsPromotion) { feeRefundDefault = (feeRefundDefault - refundPromotion.DecreasePrice) < 0 ? 0 : feeRefundDefault - refundPromotion.DecreasePrice; } ltrInfo.Text += "<div class='form-row refund-info'>"; if (feeRefundDefault == 0) { ltrInfo.Text += " <strong>* Miễn phí đổi hàng</strong>"; } else { ltrInfo.Text += String.Format(" <strong>* Phí đổi trả hàng: {0:0,0}/cái.</strong>", feeRefundDefault); } ltrInfo.Text += "</div>"; if (UserController.checkExists(cusID)) { ltrInfo.Text += "<div class='form-row refund-info'>"; ltrInfo.Text += " <strong class='font-green'>Đã đăng ký App</strong>"; ltrInfo.Text += "</div>"; } else { ltrInfo.Text += "<div class='form-row refund-info'>"; ltrInfo.Text += " <strong class='font-red'>Chưa đăng ký App</strong>"; ltrInfo.Text += "</div>"; } #endregion ltrTotal.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalPrice)); ltrQuantity.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalQuantity)); ltrRefund.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalRefundFee)); // get info tranfor page tao-don-hang-doi-tra.aspx _refundGood.RefundGoodsID = ID; _refundGood.CustomerID = r.CustomerID.Value; _refundGood.CustomerName = r.CustomerName; _refundGood.CustomerPhone = r.CustomerPhone; _refundGood.CustomerNick = cus != null ? cus.Nick : String.Empty; _refundGood.CustomerAddress = cus != null ? cus.CustomerAddress : String.Empty; _refundGood.CustomerZalo = cus != null ? cus.Zalo : String.Empty; _refundGood.CustomerFacebook = cus != null ? cus.Facebook : String.Empty; _refundGood.RefundDetails = RefundGoodDetailController.GetInfoShowRefundDetail(ID, feeRefundDefault); _refundGood.TotalPrice = Convert.ToDouble(r.TotalPrice); _refundGood.TotalQuantity = Convert.ToDouble(r.TotalQuantity); _refundGood.TotalFreeRefund = Convert.ToDouble(r.TotalRefundFee); _refundGood.Status = r.Status.Value; _refundGood.Note = txtRefundsNote.Text; _refundGood.CreateBy = r.CreatedBy; var rds = RefundGoodDetailController.GetByRefundGoodsID(ID); var product = _refundGood.RefundDetails .Join( rds, p1 => new { RefundGoodsID = p1.RefundGoodsID, RefundDetailID = p1.RefundDetailID }, p2 => new { RefundGoodsID = p2.RefundGoodsID.Value, RefundDetailID = p2.ID }, (p1, p2) => new { p1, p2 }) .Select(x => new { SKU = x.p2.SKU, OrderID = x.p2.OrderID, ProductName = x.p2.ProductName, ProductType = x.p2.ProductType, GiavonPerProduct = x.p2.GiavonPerProduct, SoldPricePerProduct = x.p2.SoldPricePerProduct, DiscountPricePerProduct = x.p2.DiscountPricePerProduct, Quantity = x.p2.Quantity, QuantityMax = x.p2.QuantityMax, RefundType = x.p2.RefundType, RefundFeePerProduct = x.p2.RefundFeePerProduct, TotalPriceRow = x.p2.TotalPriceRow, ProductImage = x.p1.ProductImage }) .ToList(); if (product.Count > 0) { string html = ""; int t = 0; foreach (var item in product) { var variables = ProductVariableValueController.GetByProductVariableSKU(item.SKU); string variable = ""; if (variables.Count > 0) { variable += "<br><br>"; foreach (var v in variables) { variable += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "<br>"; } } t++; html += "<tr ondblclick='clickrow($(this))' class='product-result' data-sku='" + item.SKU + "' data-orderID='" + item.OrderID + "' data-ProductName='" + item.ProductName + "' data-ProductType='" + item.ProductType + "' data-Giagoc='" + item.GiavonPerProduct + "' data-Giadaban='" + item.SoldPricePerProduct + "' data-TienGiam='" + item.DiscountPricePerProduct + "' data-Soluongtoida='" + item.QuantityMax + "' data-RefundFee='" + item.RefundFeePerProduct + "'>"; html += " <td>" + t + "</td>"; html += " <td class='image-item'><img src='" + Thumbnail.getURL(item.ProductImage, Thumbnail.Size.Small) + "'></td>"; html += " <td class='name-item'><a href='/xem-san-pham?sku=" + item.SKU + "' target='_blank'>" + item.ProductName + "</a>" + variable + "</td>"; html += " <td class='sku-item'>" + item.SKU + "</td>"; html += " <td class='price-item giagoc' data-giagoc='" + item.GiavonPerProduct + "'>" + string.Format("{0:N0}", Convert.ToDouble(item.GiavonPerProduct)) + "</td>"; html += " <td class='giadaban' data-giadaban='" + item.SoldPricePerProduct + "'><strong>" + string.Format("{0:N0}", Convert.ToDouble(item.SoldPricePerProduct)) + "</strong><br>(CK: " + string.Format("{0:N0}", Convert.ToDouble(item.DiscountPricePerProduct)) + ")</td>"; html += " <td class='slcandoi'>" + item.Quantity + "</td>"; html += " <td>"; int refundType = Convert.ToInt32(item.RefundType); string refuntTypeName = ""; if (item.RefundType == 1) { refuntTypeName = "Đổi size"; } else if (item.RefundType == 2) { refuntTypeName = "Đổi sản phẩm khác"; } else if (item.RefundType == 4) { refuntTypeName = "Đổi sản phẩm khác (miễn phí)"; } else { refuntTypeName = "Đổi hàng lỗi"; } html += refuntTypeName; html += " </td>"; html += " <td class='phidoihang'>" + string.Format("{0:N0}", Convert.ToDouble(item.RefundFeePerProduct)) + "</td>"; html += " <td class='thanhtien'>" + string.Format("{0:N0}", Convert.ToDouble(item.TotalPriceRow)) + "</td>"; html += "</tr>"; } ddlRefundStatus.SelectedValue = r.Status.ToString(); txtRefundsNote.Text = r.RefundNote; ltrList.Text = html; } ltrPrint.Text = "<a href='/print-invoice-return?id=" + ID + "' target='_blank' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-print' aria-hidden='true'></i> In hóa đơn</a>"; ltrPrint.Text += "<a href='/print-return-order-image?id=" + ID + "' target='_blank' class='btn primary-btn btn-blue fw-btn not-fullwidth print-invoice-merged'><i class='fa fa-picture-o' aria-hidden='true'></i> Lấy ảnh đơn hàng</a>"; } } } }
public void InserOrder(string AgentAPIID, string AgentAPICode, string OrderType, string CustomerName, string CustomerPhone, string CustomerEmail, string CustomerAddress, string TotalPrice, string PaymentStatus, string ExcuteStatus, string CreatedBy, string productquantity, string FeeShipping, int PaymentType, int ShippingType, string username, string password) { var rs = new ResponseClass(); if (Login(username, password)) { DateTime currentDate = DateTime.Now; var agent = AgentController.GetByAPICodeID(AgentAPIID, AgentAPICode); if (agent != null) { int AgentID = agent.ID; int CustomerID = 0; string AdditionFee = "0"; string DisCount = "0"; var checkphone = CustomerController.GetByPhone(CustomerPhone); if (checkphone != null) { CustomerID = checkphone.ID; } else { string kq = CustomerController.Insert(CustomerName, CustomerPhone, CustomerAddress, CustomerEmail, 0, 0, currentDate, CreatedBy, false, "", "", "", "", ""); if (kq.ToInt(0) > 0) { CustomerID = kq.ToInt(0); } } bool IsHidden = false; int Wayin = 2; double amount = 0; double totalDiscount = 0; double totalleft = 0; var d = DiscountCustomerController.getbyCustID(CustomerID); if (d.Count > 0) { amount = d[0].DiscountAmount; } int pquantity = productquantity.ToInt(0); if (amount == 0) { if (pquantity > 29 && pquantity <= 49) { amount = 3000; } else if (pquantity > 49 && pquantity <= 99) { amount = 5000; } else if (pquantity > 99 && pquantity <= 199) { amount = 7000; } else if (pquantity > 199) { amount = 8000; } else { amount = 0; } } if (amount > 0) { totalDiscount = amount * pquantity; totalleft = Convert.ToDouble(TotalPrice) - totalDiscount; } else { totalDiscount = 0; totalleft = Convert.ToDouble(TotalPrice); } var ret = OrderController.Insert(AgentID, OrderType.ToInt(1), AdditionFee, DisCount, CustomerID, CustomerName, CustomerPhone, CustomerAddress, CustomerEmail, totalleft.ToString(), TotalPrice.ToString(), PaymentStatus.ToInt(0), ExcuteStatus.ToInt(0), IsHidden, Wayin, currentDate, CreatedBy, amount, totalDiscount, FeeShipping.ToString(), PaymentType, ShippingType, DateTime.Now.ToString(), 0, 0, 0, 0, "", 0, 1); int OrderID = ret.ID; if (OrderID > 0) { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.SUCCESS); rs.Status = APIUtils.ResponseMessage.Success.ToString(); rs.OrderID = OrderID; rs.Message = "Tạo mới đơn hàng thành công"; } else { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.NotFound); rs.Status = APIUtils.ResponseMessage.Error.ToString(); rs.Message = "Có lỗi trong quá trình tạo mới đơn hàng, vui lòng thử lại sau."; } } else { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.NotFound); rs.Status = APIUtils.ResponseMessage.Error.ToString(); rs.Message = "Không tồn tại thông tin đại lý"; } } else { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.FAILED); rs.Status = APIUtils.ResponseMessage.Fail.ToString(); } Context.Response.ContentType = "application/json"; Context.Response.Write(JsonConvert.SerializeObject(rs, Formatting.Indented)); Context.Response.Flush(); Context.Response.End(); }
public void LoadData() { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { if (acc.ID == 1) { hdfPermittedEdit.Value = "1"; } else { hdfPermittedEdit.Value = "0"; } var groups = DiscountGroupController.getByAccount(acc); var customerGroups = DiscountCustomerController.getByDiscountGroup(groups) .Where(x => x.DiscountGroupID.HasValue) .GroupBy(g => g.DiscountGroupID.Value) .Select(x => new { DiscountGroupID = x.Key, NumberCustomer = x.Count() }) .ToList(); var discounts = groups .GroupJoin( customerGroups, g => g.ID, c => c.DiscountGroupID, (g, c) => new { group = g, customer = c } ) .SelectMany( x => x.customer.DefaultIfEmpty(), (parent, child) => new DiscountGroupModel() { ID = parent.group.ID, DiscountName = parent.group.DiscountName, NumberCustomer = child != null ? child.NumberCustomer : 0, DiscountAmount = parent.group.DiscountAmount, DiscountAmountPercent = parent.group.DiscountAmountPercent, DiscountNote = parent.group.DiscountNote, IsHidden = parent.group.IsHidden, CreatedDate = parent.group.CreatedDate, CreatedBy = parent.group.CreatedBy, ModifiedDate = parent.group.ModifiedDate, ModifiedBy = parent.group.ModifiedBy, FeeRefund = parent.group.FeeRefund, NumOfDateToChangeProduct = parent.group.NumOfDateToChangeProduct, NumOfProductCanChange = parent.group.NumOfProductCanChange, QuantityProduct = parent.group.QuantityProduct, RefundQuantityNoFee = parent.group.RefundQuantityNoFee, PermittedRead = parent.group.PermittedRead } ) .ToList(); if (discounts.Count > 0) { pagingall(discounts); } } }
public void LoadData() { if (discountGroupID > 0) { string username = Request.Cookies["usernameLoginSystem"].Value; acc = AccountController.GetByUsername(username); var discount = DiscountGroupController.GetByID(discountGroupID); if (discount != null) { hdfDiscountGroupID.Value = discountGroupID.ToString(); // Hiển thị thông tin của discount group ltrGroupName.Text = discount.DiscountName; var numberCustomer = DiscountCustomerController.GetByGroupID(discount.ID).Count; if (numberCustomer > 0) { ltrNumberCustomer.Text = String.Format("{0:N0} khách", numberCustomer); } if (discount.DiscountAmount.HasValue && discount.DiscountAmount.Value > 0) { ltrDiscount.Text = String.Format("{0:N0}đ/cái", discount.DiscountAmount); } if (discount.QuantityRequired.HasValue && discount.QuantityRequired.Value > 0) { ltrQuantityRequired.Text = String.Format("{0:N0} cái", discount.QuantityRequired); } if (discount.QuantityProduct.HasValue && discount.QuantityProduct.Value > 0) { ltrQuantityProduct.Text = String.Format("{0:N0} cái", discount.QuantityProduct); } if (discount.FeeRefund.HasValue && discount.FeeRefund.Value > 0) { ltrFeeRefund.Text = String.Format("{0:N0}đ/cái", discount.FeeRefund); } else { ltrFeeRefund.Text = "miễn phí"; } if (discount.NumOfDateToChangeProduct.HasValue && discount.NumOfDateToChangeProduct.Value > 0) { ltrNumberOfDateToChnageProduct.Text = String.Format("{0:N0} ngày", discount.NumOfDateToChangeProduct); } if (discount.NumOfProductCanChange.HasValue && discount.NumOfProductCanChange.Value > 0) { ltrNumberOfProductCanChange.Text = String.Format("{0:N0} cái/{1} ngày", discount.NumOfProductCanChange, discount.NumOfDateToChangeProduct); } if (discount.RefundQuantityNoFee.HasValue && discount.RefundQuantityNoFee.Value > 0) { ltrRefundQuantityNoFee.Text = String.Format("{0:N0} cái", discount.RefundQuantityNoFee); } string createdBy = ""; if (acc.RoleID == 2) { createdBy = acc.Username; } // Hiển thị thông tin khách hàng được hưởng chiết khấu var customer = CustomerController.getByDiscountGroupID(discountGroupID, createdBy) .OrderBy(o => o.FullName) .ToList(); if (customer.Count > 0) { pagingall(customer); } } } }
public void LoadData() { string TextSearch = ""; int Province = 0; string CreatedBy = ""; string CreatedDate = ""; if (Request.QueryString["textsearch"] != null) { TextSearch = Request.QueryString["textsearch"].Trim(); } if (Request.QueryString["createdby"] != null) { CreatedBy = Request.QueryString["createdby"]; } if (Request.QueryString["province"] != null) { Province = Request.QueryString["province"].ToInt(); } if (Request.QueryString["createddate"] != null) { CreatedDate = Request.QueryString["createddate"]; } txtTextSearch.Text = TextSearch; ddlProvince.SelectedValue = Province.ToString(); ddlCreatedBy.SelectedValue = CreatedBy.ToString(); ddlCreatedDate.SelectedValue = CreatedDate.ToString(); List <CustomerOut> rs = new List <CustomerOut>(); var customers = CustomerController.Filter(TextSearch, CreatedBy, Province, CreatedDate); if (customers.Count > 0) { foreach (var item in customers) { var discount = DiscountCustomerController.getbyCustID(item.ID); if (discount != null) { foreach (var temp in discount) { item.DiscountName += temp.DiscountName + "|"; item.DisID += temp.DiscountGroupID + "|"; } } rs.Add(item); } } string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc.RoleID != 0) { rs = rs.Where(x => x.CreatedBy == acc.Username).OrderByDescending(x => x.ID).ToList(); pagingall(rs); } else { rs = rs.OrderByDescending(x => x.ID).ToList(); pagingall(rs); } ltrNumberOfCustomer.Text = rs.Count().ToString(); }