public ActionResult OrderList() { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null || currentUser.IsAdmin == false) { return(RedirectToAction("Login", "Login")); } ManageDistrictDa dataAccess = new ManageDistrictDa(); AdminOrderList model = new AdminOrderList(); CommonService comService = new CommonService(); CommonController comControl = new CommonController(); int HaNoiCity = 1; model.DISTRICT_LIST = dataAccess.getDistrictList(HaNoiCity).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.DISTRICT_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "Chọn Quận/huyện" }); model.SORT_TYPE_LIST = UtilityServices.UtilityServices.SortTypeList(); model.STATUS_SELECT_LIST = UtilityServices.UtilityServices.getListStatusAll(); model.TO_DATE = DateTime.Now; model.FROM_DATE = model.TO_DATE.Value.AddDays(-15); return(View(model)); }
public ActionResult AdminOrderShipList() { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; var authorityList = currentUser != null ? currentUser.USER_AUTHORITY : 0; if (currentUser == null || currentUser.USER_ID == 0) { return(RedirectToAction("Login", "UserAccount")); } AdminOrderList model = new AdminOrderList(); CommonService comService = new CommonService(); model.GROUP_CD_RECEIVE_LIST = comService.GetListGroupArea(GroupForUser.Receive).ToList().Select( f => new SelectListItem { Value = f.GROUP_CD.ToString(), Text = f.GROUP_NAME }).ToList(); model.GROUP_CD_RECEIVE_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); model.GROUP_CD_SENDER_LIST = comService.GetListGroupArea(GroupForUser.Sender).ToList().Select( f => new SelectListItem { Value = f.GROUP_CD.ToString(), Text = f.GROUP_NAME }).ToList(); model.GROUP_CD_SENDER_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); return(View(model)); }
public long UpdateInfo(AdminOrderList model) { var order = da.Order.Where(x => x.ID == model.ID).SingleOrDefault(); if (order != null) { try { // set data if (order.Receive_District != model.Receive_District) { order.Receive_District = model.Receive_District; order.PriceShip = model.PriceShip; order.PriceTotal = model.PriceTotal; } order.Receive_Phone = model.Receive_Phone; order.Receive_Address = model.Receive_Address; order.Note = model.Note; da.SaveChanges(); } catch (Exception ex) { throw ex; } } else { return(0); } return(order.ID); }
public ActionResult UpdateNoteOrder(AdminOrderList model) { try { using (AdminOrderService service = new AdminOrderService()) { if (ModelState.IsValid) { { var update = service.UpdateNoteOrder(model); JsonResult result = Json(new { result = update }, JsonRequestBehavior.AllowGet); return(result); } } else { var ErrorMessages = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); } return(new EmptyResult()); } } catch (Exception ex) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; System.Web.HttpContext.Current.Session["ERROR"] = ex; return(new EmptyResult()); } }
public long UpdateNoteOrder(AdminOrderList model) { var order = da.Order.Where(x => x.ID == model.ID).SingleOrDefault(); if (order != null) { try { // set data order.Note = model.Note; da.SaveChanges(); } catch (Exception ex) { throw ex; } } else { return(0); } return(order.ID); }
public long UpdateCancelOrder(AdminOrderList model) { var order = da.Order.Where(x => x.ID == model.ID).SingleOrDefault(); if (order != null) { try { // set data order.Status = OrderStatus.Cancel; order.ReasonCancel = model.ReasonCancel; da.SaveChanges(); } catch (Exception ex) { throw ex; } } else { return(0); } return(order.ID); }
public IEnumerable <AdminOrderList> SearchOrderList(DataTableModel dt, AdminOrderList model, out int total_row) { AdminOrderDa dataAccess = new AdminOrderDa(); IEnumerable <AdminOrderList> results = dataAccess.SearchOrderList(dt, model, out total_row); return(results); }
public bool UpdateStatusOrder(AdminOrderList model) { AdminOrderDa dataAccess = new AdminOrderDa(); long result = 0; using (var transaction = new TransactionScope()) { try { result = dataAccess.UpdateStatusOrder(model); if (result > 0) { transaction.Complete(); } } catch (Exception ex) { transaction.Dispose(); result = -1; throw new Exception(ex.Message, ex); } finally { transaction.Dispose(); } } return(result > 0); }
// GET: UserManageOrder #region LIST ORDER USER public ActionResult ManageOrderList(AdminOrderList condition, int?page) { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null) { return(RedirectToAction("Login", "Login")); } ManageDistrictDa dataAccess = new ManageDistrictDa(); AdminOrderList model = new AdminOrderList(); CommonService comService = new CommonService(); CommonController comControl = new CommonController(); model.SORT_TYPE_LIST = UtilityServices.UtilityServices.SortTypeList(); model.STATUS_SELECT_LIST = UtilityServices.UtilityServices.getListStatusAll(); model.TO_DATE = DateTime.Now; model.FROM_DATE = model.TO_DATE.Value.AddDays(-15); AdminOrderDa da = new AdminOrderDa(); UserOrderService service = new UserOrderService(); DataTableModel dt = new DataTableModel(); dt.iDisplayStart = 0; dt.iDisplayLength = 25; int total_row = 0; condition.UserID = currentUser.ID; var dataList = service.SearchOrderListbyUser(dt, condition, out total_row).ToList(); var totalDataNoneStatus = service.SearchOrderListTotalNoneStatus(dt, condition); for (int i = 0; i < dataList.Count(); i++) { dataList[i].ORDER_STATUS_TEXT = OrderStatus.Items[dataList[i].Status].ToString(); dataList[i].CREATE_DATE_STRING = dataList[i].CreatedDate.HasValue ? dataList[i].CreatedDate.Value.ToString("dd/MM/yyyy hh:mm") : ""; var getProductDetail = da.getlistProductByOrder(dataList[i].ID).Take(3); List <string> listName = new List <string>(); foreach (var det in getProductDetail) { det.Name = det.Name.Length > 20 ? det.Name.Substring(0, 20) : det.Name; listName.Add(det.Name); } if (listName.Count > 0) { dataList[i].Product_Name = string.Join(", ", listName); } } if (Request.HttpMethod != "GET") { page = 1; } int Pagesize = 20; // tạo biến số trang hiện tại int PageNumber = (page ?? 1); return(View(dataList.ToPagedList(PageNumber, Pagesize))); }
public IEnumerable <OrderShipModel> SearchOrderShipList(DataTableModel dt, AdminOrderList condition, out int total_row) { AdminOrderShipDa dataAccess = new AdminOrderShipDa(); IEnumerable <OrderShipModel> results = dataAccess.SearchOrderShipList(dt, condition, out total_row); return(results); }
public ActionResult PopupCancelOrder(long OrderId = 0) { AdminOrderList model = new AdminOrderList(); CommonController con = new CommonController(); model.ID = OrderId; return(this.PartialView("PopupCancelOrder", model)); }
public ActionResult PopupUpdateNote(long OrderId = 0, string oldNote = "") { AdminOrderList model = new AdminOrderList(); CommonController con = new CommonController(); model.ID = OrderId; model.Note = oldNote; return(this.PartialView("PopupUpdateNote", model)); }
public ActionResult PopupUpdateStatus(long OrderId = 0, int oldStatus = 0) { AdminOrderList model = new AdminOrderList(); CommonController con = new CommonController(); model.ID = OrderId; model.OldStatus = oldStatus; model.STATUS_SELECT_LIST = UtilityServices.UtilityServices.getListStatusAll().Where(i => i.Value != oldStatus.ToString()).ToList(); return(this.PartialView("PopupUpdateStatus", model)); }
public IList <OrderShipModel> getDataForCSV(AdminOrderList condition) { StringBuilder sql = new StringBuilder(); DateTime fromDate = new DateTime(); DateTime toDate = new DateTime(); sql.Append(@" SELECT A.*, B.CITY_NAME as RECEIVE_CITY_NAME, C.DISTRICT_NAME as RECEIVE_DISTRICT_NAME, D.TOWN_NAME as RECEIVE_TOWN_NAME, E.USER_NAME as ACCEPTANCE_NAME FROM TblOrder A LEFT JOIN MstCity B ON A.RECEIVED_CITY = B.CITY_CD LEFT JOIN MstDistrict C ON A.RECEIVED_CITY = C.CITY_CD AND A.RECEIVED_DISTRICT = C.DISTRICT_CD LEFT JOIN MstTown D ON A.RECEIVED_CITY = D.CITY_CD AND A.RECEIVED_DISTRICT = D.DISTRICT_CD AND A.RECEIVED_TOWN = D.TOWN_CD LEFT JOIN TblUserAccount E ON A.ACCEPTANCE_ID = E.USER_ID WHERE A.USER_ID = @USER_ID AND A.DEL_FLG = @DEL_FLG"); if (!string.IsNullOrEmpty(condition.ORDER_STATUS_LIST)) { sql.Append(" AND A.ORDER_STATUS IN ('" + condition.ORDER_STATUS_LIST + "')"); } if (!string.IsNullOrEmpty(condition.TEXT_SEARCH)) { sql.Append(" AND (A.SHIP_CODE LIKE @TEXT_SEARCH ESCAPE '|' ) OR ( A.RECEIVED_NAME LIKE @TEXT_SEARCH ESCAPE '|') OR ( A.RECEIVED_PHONE LIKE @TEXT_SEARCH ESCAPE '|') "); } if (!string.IsNullOrEmpty(condition.FROM_DATE)) { fromDate = DateTime.ParseExact(condition.FROM_DATE, "dd/MM/yyyy", CultureInfo.InvariantCulture); sql.Append(" AND A.CREATE_DATE >= @FROM_DATE "); } if (!string.IsNullOrEmpty(condition.TO_DATE)) { toDate = DateTime.ParseExact(condition.TO_DATE, "dd/MM/yyyy", CultureInfo.InvariantCulture); sql.Append(" AND A.CREATE_DATE <= @TO_DATE "); } sql.Append(" ORDER BY CREATE_DATE DESC, SHIP_CODE DESC, RECEIVED_NAME ASC"); return(base.Query <OrderShipModel>(sql.ToString(), new { USER_ID = CmnEntityModel.USER_ID, DEL_FLG = DeleteFlag.NON_DELETE, TEXT_SEARCH = '%' + UtilityServices.UtilityServices.replaceWildcardCharacters(condition.TEXT_SEARCH) + '%', TO_DATE = toDate, FROM_DATE = fromDate }).ToList()); }
/// <summary> /// List display paging /// </summary> /// <param name="dt"></param> /// <param name="model"></param> /// <param name="total_row"></param> /// <returns></returns> public IEnumerable <OrderShipModel> SearchOrderShipList(DataTableModel dt, AdminOrderList model, out int total_row) { StringBuilder sql = new StringBuilder(); DateTime fromDate = new DateTime(); DateTime toDate = new DateTime(); sql.Append(@" SELECT A. * FROM TblOrder A WHERE A.USER_ID = @USER_ID AND A.DEL_FLG = @DEL_FLG"); if (!string.IsNullOrEmpty(model.ORDER_STATUS_LIST)) { sql.Append(" AND A.ORDER_STATUS IN ('" + model.ORDER_STATUS_LIST + "')"); } if (!string.IsNullOrEmpty(model.TEXT_SEARCH)) { sql.Append(" AND (A.SHIP_CODE LIKE @TEXT_SEARCH ESCAPE '|' ) OR ( A.RECEIVED_NAME LIKE @TEXT_SEARCH ESCAPE '|') OR ( A.RECEIVED_PHONE LIKE @TEXT_SEARCH ESCAPE '|') "); } if (!string.IsNullOrEmpty(model.FROM_DATE)) { fromDate = DateTime.ParseExact(model.FROM_DATE, "dd/MM/yyyy", CultureInfo.InvariantCulture); sql.Append(" AND CAST(A.CREATE_DATE AS DATE) >= @FROM_DATE "); } if (!string.IsNullOrEmpty(model.TO_DATE)) { toDate = DateTime.ParseExact(model.TO_DATE, "dd/MM/yyyy", CultureInfo.InvariantCulture); sql.Append(" AND CAST(A.CREATE_DATE AS DATE) <= @TO_DATE "); } sql.Append(" ORDER BY CREATE_DATE DESC, SHIP_CODE DESC, RECEIVED_NAME ASC"); int lower = dt.iDisplayStart + 1; int upper = dt.iDisplayStart + dt.iDisplayLength; PagingHelper.SQLParts parts; PagingHelper.SplitSQL(sql.ToString(), out parts); string sqlpage = PagingHelper.BuildPageQuery(lower, dt.iDisplayLength, parts); string sqlcount = parts.sqlCount; var dataList = base.Query <OrderShipModel>(sqlpage, new { USER_ID = CmnEntityModel.USER_ID, DEL_FLG = DeleteFlag.NON_DELETE, TEXT_SEARCH = '%' + UtilityServices.UtilityServices.replaceWildcardCharacters(model.TEXT_SEARCH) + '%', TO_DATE = toDate, FROM_DATE = fromDate, pageindex = lower, pagesize = upper }).ToList(); total_row = base.Query <int>(sqlcount, new { USER_ID = CmnEntityModel.USER_ID, DEL_FLG = DeleteFlag.NON_DELETE, TEXT_SEARCH = '%' + UtilityServices.UtilityServices.replaceWildcardCharacters(model.TEXT_SEARCH) + '%', TO_DATE = toDate, FROM_DATE = fromDate, pageindex = lower, pagesize = upper }).FirstOrDefault(); return(dataList); }
public ActionResult List(DataTableModel dt, AdminOrderList condition) { if (ModelState.IsValid) { using (AdminOrderShipService service = new AdminOrderShipService()) { int total_row = 0; var OrderSummaryInfo = new AdminOrderList(); if (!string.IsNullOrEmpty(condition.ORDER_STATUS_LIST)) { List <long> statusList = condition.ORDER_STATUS_LIST.Split(',').Select(long.Parse).ToList(); if (statusList.Count > 0) { condition.ORDER_STATUS_LIST = string.Join("','", statusList.ToArray()); } } var totaldataList = service.SearchOrderShipListTotal(dt, condition); var dataList = service.SearchOrderShipList(dt, condition, out total_row); var dataByStatusWaitCOD = service.SearchOrderShipByStatus(OrderStatus.WaitCOD); var totalDataNoneStatus = service.SearchOrderListTotalNoneStatus(dt, condition); OrderSummaryInfo.TotalStatus_0 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.Create).ToList().Count(); OrderSummaryInfo.TotalStatus_1 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.TakingOrder).ToList().Count(); OrderSummaryInfo.TotalStatus_2 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.TakedOrder).ToList().Count(); OrderSummaryInfo.TotalStatus_3 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.Shiping).ToList().Count(); OrderSummaryInfo.TotalStatus_4 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.Delivery).ToList().Count(); OrderSummaryInfo.TotalStatus_5 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.ReShip).ToList().Count(); OrderSummaryInfo.TotalStatus_6 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.ReturnOrder).ToList().Count(); OrderSummaryInfo.TotalStatus_7 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.ReturnOrderSuccess).ToList().Count(); OrderSummaryInfo.TotalStatus_8 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.Finished).ToList().Count(); OrderSummaryInfo.TotalStatus_9 = totalDataNoneStatus.Where(i => i.ORDER_STATUS == OrderStatus.WaitCOD).ToList().Count(); OrderSummaryInfo.TotalStatusAll = totalDataNoneStatus.Count(); //var dataListWaitCOD = totaldataList.Where(i => i.ORDER_STATUS == OrderStatus.WaitCOD).ToList(); //var OrderMonth = totaldataList.Where(i => i.CREATE_DATE.ToString("MM/yyyy").b); foreach (var data in totaldataList) { OrderSummaryInfo.TotalPriceProduct += data.PRICE_PRODUCT.Value; if (data.USER_PAYMENT.Equals(User_Pay.Sender)) { OrderSummaryInfo.TotalPriceShip += data.PRICE_SHIP; } } OrderSummaryInfo.TotalMoney = OrderSummaryInfo.TotalPriceProduct - OrderSummaryInfo.TotalPriceShip; decimal totalPriceWaitCOD = 0; decimal totalShipWaitCOD = 0; foreach (var data in dataByStatusWaitCOD) { totalPriceWaitCOD += data.PRICE_PRODUCT.Value; if (data.USER_PAYMENT.Equals(User_Pay.Sender)) { totalShipWaitCOD += data.PRICE_SHIP; } } OrderSummaryInfo.TotalWaitCOD = totalPriceWaitCOD - totalShipWaitCOD; OrderSummaryInfo.thisMonth = Utility.GetCurrentDateOnly().Month; var thismonth = Utility.GetCurrentDateOnly().ToString("MM/yyyy"); var dataThisMonth = service.SearchOrderByMonth(thismonth); OrderSummaryInfo.TotalOrderthisMonth = dataThisMonth.Count(); int totalRowCount = dataList.Count(); int lastItem = dt.iDisplayLength + dt.iDisplayStart; var tableData = (from i in dataList select new object[] { i.ORDER_ID, i.CREATE_DATE.ToString("dd/MM/yyyy"), i.SHIP_CODE, i.RECEIVED_NAME, i.RECEIVED_PHONE, i.PRODUCT_NAME, i.PRICE_PRODUCT, i.USER_PAYMENT == User_Pay.Sender ?i.PRICE_SHIP : 0, i.RECEIVE_HOUR_FROM + "h - " + i.RECEIVE_HOUR_TO + "h Ngày:" + i.RECEIVE_TIME_DATE.ToString("dd/MM/yyyy"), OrderStatus.Items[i.ORDER_STATUS].ToString() }); var result = Json(new { sEcho = dt.sEcho, iTotalRecords = total_row, iTotalDisplayRecords = total_row, objOrderSummaryInfo = OrderSummaryInfo, aaData = tableData }); Session["SearchOrderShipList"] = condition; result.MaxJsonLength = Int32.MaxValue; return(result); } } else { var ErrorMessages = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); } return(new EmptyResult()); }
/// <summary> /// Select list no have status /// </summary> /// <param name="dt"></param> /// <param name="model"></param> /// <returns></returns> public IEnumerable <OrderShipModel> SearchOrderListTotalNoneStatus(DataTableModel dt, AdminOrderList model) { StringBuilder sql = new StringBuilder(); DateTime fromDate = new DateTime(); DateTime toDate = new DateTime(); sql.Append(@" SELECT A. * FROM TblOrder A WHERE A.USER_ID = @USER_ID AND A.DEL_FLG = @DEL_FLG"); if (!string.IsNullOrEmpty(model.TEXT_SEARCH)) { sql.Append(" AND (A.SHIP_CODE LIKE @TEXT_SEARCH ESCAPE '|' ) OR ( A.RECEIVED_NAME LIKE @TEXT_SEARCH ESCAPE '|') OR ( A.RECEIVED_PHONE LIKE @TEXT_SEARCH ESCAPE '|') "); } if (!string.IsNullOrEmpty(model.FROM_DATE)) { fromDate = DateTime.ParseExact(model.FROM_DATE, "dd/MM/yyyy", CultureInfo.InvariantCulture); sql.Append(" AND CAST(A.CREATE_DATE AS DATE) >= @FROM_DATE "); } if (!string.IsNullOrEmpty(model.TO_DATE)) { toDate = DateTime.ParseExact(model.TO_DATE, "dd/MM/yyyy", CultureInfo.InvariantCulture); sql.Append(" AND CAST(A.CREATE_DATE AS DATE) <= @TO_DATE "); } sql.Append(" ORDER BY CREATE_DATE DESC, SHIP_CODE DESC, RECEIVED_NAME ASC"); var dataList = base.Query <OrderShipModel>(sql.ToString(), new { USER_ID = CmnEntityModel.USER_ID, DEL_FLG = DeleteFlag.NON_DELETE, TEXT_SEARCH = '%' + UtilityServices.UtilityServices.replaceWildcardCharacters(model.TEXT_SEARCH) + '%', TO_DATE = toDate, FROM_DATE = fromDate }).ToList(); return(dataList); }
public IEnumerable <OrderShipModel> SearchOrderListTotalNoneStatus(DataTableModel dt, AdminOrderList condition) { AdminOrderShipDa dataAccess = new AdminOrderShipDa(); IEnumerable <OrderShipModel> results = dataAccess.SearchOrderListTotalNoneStatus(dt, condition); return(results); }
public IEnumerable <AdminOrderList> SearchOrderList(DataTableModel dt, AdminOrderList model, out int total_row) { model.TO_DATE = model.FROM_DATE.HasValue ? model.TO_DATE.Value.AddDays(1) : model.TO_DATE; var lstOrder = (from pro in da.Order join user in da.TblUser on pro.UserID equals user.ID join dis in da.TblCity on pro.Receive_District equals dis.ID where (pro.del_flg == model.del_flg && (!String.IsNullOrEmpty(model.Code) == true ? pro.Code.Contains(model.Code) : 1 == 1)) where (model.FROM_DATE.HasValue ? pro.CreatedDate >= model.FROM_DATE : 1 == 1) where (model.TO_DATE.HasValue ? pro.CreatedDate <= model.TO_DATE : 1 == 1) where ((model.Receive_District.HasValue && model.Receive_District > 0) ? pro.Receive_District == model.Receive_District : 1 == 1) where ((model.UserID.HasValue && model.UserID > 0)? pro.UserID == model.UserID : 1 == 1) where ((model.PaymentMethod.HasValue && model.PaymentMethod > 0) ? pro.PaymentMethod == model.PaymentMethod.Value : 1 == 1) where (model.Paid.HasValue ? pro.Paid == model.Paid.Value : 1 == 1) where (!String.IsNullOrEmpty(model.ORDER_STATUS_LIST) == true ? pro.Status.ToString().Contains(model.ORDER_STATUS_LIST) : 1 == 1) select new AdminOrderList { ID = pro.ID, Code = pro.Code, Status = pro.Status, TongTienHang = pro.TongTienHang, PriceDiscountTotal = pro.PriceDiscountTotal, PriceShip = pro.PriceShip, PriceTotal = pro.PriceTotal, UserName = user.UserName, Receive_Phone = pro.Receive_Phone, DistrictName = dis.Name, Receive_Address = pro.Receive_Address, CreatedDate = pro.CreatedDate, //CREATE_DATE_STRING = pro.CreatedDate.HasValue ? pro.CreatedDate.Value.ToString("dd/MM/yyyy hh:mm") : "", PaymentMethod = pro.PaymentMethod, Paid = pro.Paid, del_flg = pro.del_flg }); total_row = lstOrder.Count(); // Sắp xếp theo lựa chọn if (!String.IsNullOrEmpty(model.SORT_COL)) { switch (model.SORT_COL) { case SortAdminOrderShipList.CREATE_DATE: if (model.SORT_TYPE == SortType.ASC) { lstOrder = lstOrder.OrderBy(i => i.CreatedDate).ThenBy(i => i.Code).ThenBy(i => i.PriceTotal).Skip(dt.iDisplayStart).Take(dt.iDisplayLength); } else { lstOrder = lstOrder.OrderByDescending(i => i.CreatedDate).ThenByDescending(i => i.Code).ThenByDescending(i => i.PriceTotal).Skip(dt.iDisplayStart).Take(dt.iDisplayLength); } break; case SortAdminOrderShipList.ORDER_CODE: if (model.SORT_TYPE == SortType.ASC) { lstOrder = lstOrder.OrderBy(i => i.Code).ThenBy(i => i.CreatedDate).ThenBy(i => i.PriceTotal).Skip(dt.iDisplayStart).Take(dt.iDisplayLength); } else { lstOrder = lstOrder.OrderByDescending(i => i.Code).ThenByDescending(i => i.CreatedDate).ThenByDescending(i => i.PriceTotal).Skip(dt.iDisplayStart).Take(dt.iDisplayLength); } break; case SortAdminOrderShipList.TOTAL_MONEY: if (model.SORT_TYPE == SortType.ASC) { lstOrder = lstOrder.OrderBy(i => i.PriceTotal).ThenBy(i => i.CreatedDate).ThenBy(i => i.Code).Skip(dt.iDisplayStart).Take(dt.iDisplayLength); } else { lstOrder = lstOrder.OrderByDescending(i => i.PriceTotal).ThenByDescending(i => i.CreatedDate).ThenByDescending(i => i.Code).Skip(dt.iDisplayStart).Take(dt.iDisplayLength); } break; } } else { lstOrder = lstOrder.OrderByDescending(i => i.CreatedDate).Skip(dt.iDisplayStart).Take(dt.iDisplayLength); } return(lstOrder); }
public IEnumerable <AdminOrderList> SearchOrderListTotalNoneStatus(DataTableModel dt, AdminOrderList model) { AdminOrderDa dataAccess = new AdminOrderDa(); IEnumerable <AdminOrderList> results = dataAccess.SearchOrderListTotalNoneStatus(dt, model); return(results); }
public IEnumerable <AdminOrderList> SearchOrderListTotalNoneStatus(DataTableModel dt, AdminOrderList model) { model.TO_DATE = model.FROM_DATE.HasValue ? model.TO_DATE.Value.AddDays(1) : model.TO_DATE; var lstOrder = (from pro in da.Order join user in da.TblUser on pro.UserID equals user.ID join dis in da.TblCity on pro.Receive_District equals dis.ID where (pro.del_flg == model.del_flg && (!String.IsNullOrEmpty(model.Code) == true ? pro.Code.Contains(model.Code) : 1 == 1)) where (model.FROM_DATE.HasValue ? pro.CreatedDate >= model.FROM_DATE : 1 == 1) where (model.TO_DATE.HasValue ? pro.CreatedDate <= model.TO_DATE : 1 == 1) where ((model.Receive_District.HasValue && model.Receive_District > 0) ? pro.Receive_District == model.Receive_District : 1 == 1) where ((model.UserID.HasValue && model.UserID > 0) ? pro.UserID == model.UserID : 1 == 1) where ((model.PaymentMethod.HasValue && model.PaymentMethod > 0) ? pro.PaymentMethod == model.PaymentMethod.Value : 1 == 1) where (model.Paid.HasValue ? pro.Paid == model.Paid.Value : 1 == 1) select new AdminOrderList { ID = pro.ID, Code = pro.Code, Status = pro.Status, Product_Name = "", TongTienHang = pro.TongTienHang, PriceDiscountTotal = pro.PriceDiscountTotal, PriceShip = pro.PriceShip, PriceTotal = pro.PriceTotal, UserName = user.UserName, Receive_Phone = pro.Receive_Phone, DistrictName = dis.Name, Receive_Address = pro.Receive_Address, CreatedDate = pro.CreatedDate, //CREATE_DATE_STRING = pro.CreatedDate.HasValue ? pro.CreatedDate.Value.ToString("dd/MM/yyyy hh:mm") : "", PaymentMethod = pro.PaymentMethod, Paid = pro.Paid, del_flg = pro.del_flg }); return(lstOrder); }
public ActionResult List(DataTableModel dt, AdminOrderList condition) { if (ModelState.IsValid) { using (AdminOrderService service = new AdminOrderService()) { try { int total_row = 0; var OrderSummaryInfo = new AdminOrderList(); AdminOrderDa da = new AdminOrderDa(); if (!string.IsNullOrEmpty(condition.ORDER_STATUS_LIST)) { List <string> statusList = condition.ORDER_STATUS_LIST.Split(',').ToList(); if (statusList.Count > 0) { condition.ORDER_STATUS_LIST = string.Join("','", statusList.ToArray()); } } var dataList = service.SearchOrderList(dt, condition, out total_row).ToList(); var totalDataNoneStatus = service.SearchOrderListTotalNoneStatus(dt, condition); OrderSummaryInfo.TotalStatus_0 = totalDataNoneStatus.Where(i => i.Status == OrderStatus.Create).ToList().Count(); OrderSummaryInfo.TotalStatus_1 = totalDataNoneStatus.Where(i => i.Status == OrderStatus.TakingOrder).ToList().Count(); OrderSummaryInfo.TotalStatus_2 = totalDataNoneStatus.Where(i => i.Status == OrderStatus.Shiping).ToList().Count(); OrderSummaryInfo.TotalStatus_3 = totalDataNoneStatus.Where(i => i.Status == OrderStatus.Delivery).ToList().Count(); OrderSummaryInfo.TotalStatus_4 = totalDataNoneStatus.Where(i => i.Status == OrderStatus.Finished).ToList().Count(); OrderSummaryInfo.TotalStatus_5 = totalDataNoneStatus.Where(i => i.Status == OrderStatus.Cancel).ToList().Count(); OrderSummaryInfo.TotalStatus_6 = totalDataNoneStatus.Where(i => i.Status == OrderStatus.Error).ToList().Count(); OrderSummaryInfo.TotalStatusAll = totalDataNoneStatus.Count(); for (int i = 0; i < dataList.Count(); i++) { var getProductDetail = da.getlistProductByOrder(dataList[i].ID).Take(3); List <string> listName = new List <string>(); foreach (var det in getProductDetail) { det.Name = det.Name.Length > 20 ? det.Name.Substring(0, 20) : det.Name; listName.Add(det.Name); } if (listName.Count > 0) { dataList[i].Product_Name = string.Join(", ", listName); } } OrderSummaryInfo.thisMonth = Utility.GetCurrentDateOnly().Month; //var thismonth = Utility.GetCurrentDateOnly().ToString("MM/yyyy"); //var dataThisMonth = service.SearchOrderByMonth(thismonth); //OrderSummaryInfo.TotalOrderthisMonth = dataThisMonth.Count(); int totalRowCount = dataList.Count(); int lastItem = dt.iDisplayLength + dt.iDisplayStart; var tableData = (from i in dataList select new object[] { i.ID, i.Code, OrderStatus.Items[i.Status.Value].ToString(), i.Product_Name, i.TongTienHang, i.PriceDiscountTotal, i.PriceShip, i.PriceTotal, i.UserName, i.Receive_Phone, i.DistrictName, i.Receive_Address, i.CreatedDate.HasValue ? i.CreatedDate.Value.ToString("dd/MM/yyyy hh:mm") : "", PaymentMethodType.Items[i.PaymentMethod], i.Paid == true ? true : false, i.Status, i.del_flg }); var result = Json(new { sEcho = dt.sEcho, iTotalRecords = total_row, iTotalDisplayRecords = total_row, objOrderSummaryInfo = OrderSummaryInfo, aaData = tableData }); Session["SearchAdminOrderShipList"] = condition; result.MaxJsonLength = Int32.MaxValue; return(result); } catch (Exception ex) { logger.Error(ex); } } } else { var ErrorMessages = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); } return(new EmptyResult()); }
public ApiResult OrderList([FromQuery] AdminOrderList parameter) { var orderList = Resolve <IOrderService>().GetPagedList(Query); return(ApiResult.Success(orderList)); }