public ActionResult Orders(OrderManageViewModel model) { if (ModelState.IsValid) { if (Request.Form["saveinbutton"] != null || Request.Form["saveoutbutton"] != null) { //Update orders OrderHelpers.UpdateOrders(db, model, User); } return(RedirectToAction("Orders", "ManageInfo")); } //rebuild the blank models as these have no entries anyway if (model.OrdersInViewModel == null) { model.OrdersInViewModel = new List <OrderInViewModel>(); } if (model.OrdersOutViewModel == null) { model.OrdersOutViewModel = new List <OrderOutViewModel>(); } return(View(model)); }
public static OrderManageViewModel GetOrderManageViewModel(ApplicationDbContext db, Guid organisationId) { OrderManageViewModel model = new OrderManageViewModel() { OrdersInViewModel = CreateOrdersInViewModel(db, organisationId, false), OrdersOutViewModel = CreateOrdersOutViewModel(db, organisationId, false) }; return(model); }
public static OrderManageViewModel GetOrderManageViewModelHistory(ApplicationDbContext db, string type, Guid organisationId) { OrderManageViewModel model = new OrderManageViewModel(); if (type == "in") { model.OrdersInViewModel = CreateOrdersInViewModel(db, organisationId, true); } if (type == "out") { model.OrdersOutViewModel = CreateOrdersOutViewModel(db, organisationId, true); } return(model); }
public ActionResult OrdersHistory(string type) { OrderManageViewModel model = OrderViewHelpers.GetOrderManageViewModelHistory(db, type, AppUserHelpers.GetOrganisationIdFromUser(db, User)); if (type == "in") { ViewBag.Type = "Orders In"; } if (type == "out") { ViewBag.Type = "Orders Out"; } return(View(model)); }
public PagedList <OrderManageViewModel> GetOrderList(int pageIndex, int pageSize) { var orderList = new List <OrderManageViewModel>(); var count = 0; using (var cmd = DataCommandManager.GetDataCommand("GetOrderListAll")) { cmd.SetParameterValue("@PageIndex", pageIndex); cmd.SetParameterValue("@PageSize", pageSize); using (var ds = cmd.ExecuteDataSet()) { if (ds.Tables.Count >= 2) { foreach (DataRow dr in ds.Tables[0].Rows) { var omvm = new OrderManageViewModel(); omvm.OrderId = !Convert.IsDBNull(dr["OrderId"]) ? Convert.ToInt64(dr["OrderId"]) : 0; omvm.UserId = !Convert.IsDBNull(dr["UserId"]) ? Convert.ToInt32(dr["UserId"]) : 0; omvm.CreateTime = !Convert.IsDBNull(dr["CreateTime"]) ? Convert.ToDateTime(dr["CreateTime"]) : DateTime.MinValue; omvm.ProductId = !Convert.IsDBNull(dr["ProductId"]) ? Convert.ToInt32(dr["ProductId"]) : 0; omvm.ProductCount = !Convert.IsDBNull(dr["ProductCount"]) ? Convert.ToInt32(dr["ProductCount"]) : 0; omvm.Price = !Convert.IsDBNull(dr["Price"]) ? Convert.ToDecimal(dr["Price"]) : 0; omvm.Status = !Convert.IsDBNull(dr["Status"]) ? Convert.ToInt32(dr["Status"]) : 0; omvm.PayType = !Convert.IsDBNull(dr["PayType"]) ? Convert.ToInt32(dr["PayType"]) : 0; omvm.ProductName = !Convert.IsDBNull(dr["ProductName"]) ? dr["ProductName"].ToString() : string.Empty; omvm.TotalMoney = !Convert.IsDBNull(dr["TotalMoney"]) ? Convert.ToDecimal(dr["TotalMoney"]) : 0; omvm.Mobile = !Convert.IsDBNull(dr["Mobile"]) ? dr["Mobile"].ToString() : string.Empty; if (omvm.OrderId > 0) { orderList.Add(omvm); } } var countDr = ds.Tables[1].Rows[0][0]; count = !Convert.IsDBNull(countDr) ? Convert.ToInt32(countDr) : 0; } } } var result = new PagedList <OrderManageViewModel>(orderList, pageIndex, pageSize, count); return(result); }
public static void UpdateOrders(ApplicationDbContext db, OrderManageViewModel model, IPrincipal user) { //Update Orders In if (model.OrdersInViewModel != null) { foreach (OrderInViewModel item in model.OrdersInViewModel) { UpdateOrderDates(db, "in", item.OrderId, item.OrderCollected, item.OrderReceived, item.OrderInClosed, false, false, false, user); } } //Update Orders Out if (model.OrdersOutViewModel != null) { foreach (OrderOutViewModel item in model.OrdersOutViewModel) { UpdateOrderDates(db, "out", item.OrderId, false, false, false, item.OrderDistributed, item.OrderDelivered, item.OrderOutClosed, user); } } }
public PagedList <OrderManageViewModel> GetOrderList(int pageIndex, int pageSize, DateTime?startTime, DateTime?endTime, long?orderId, string mobile, int?status) { var orderList = new List <OrderManageViewModel>(); var totalOrderCount = 0; using (var cmd = DataCommandManager.GetDataCommand("GetOrderListWithCondition")) { cmd.SetParameterValue("@PageIndex", pageIndex); cmd.SetParameterValue("@PageSize", pageSize); var command = cmd.CommandText; StringBuilder condition = new StringBuilder(); if (startTime != null) { condition.Append(" AND op.CreateTime>@StartTime"); cmd.SetParameterValue("@StartTime", startTime.Value); } if (endTime != null) { condition.Append(" AND op.CreateTime>@EndTime"); cmd.SetParameterValue("@EndTime", endTime.Value); } if (orderId != null) { condition.Append(" AND op.OrderId = @OrderId"); cmd.SetParameterValue("@OrderId", orderId.Value); } if (!string.IsNullOrEmpty(mobile)) { condition.Append(" AND u.Mobile = @Mobile"); cmd.SetParameterValue("@Mobile", mobile); } if (status != null) { condition.Append(" AND op.Status = @Status"); cmd.SetParameterValue("@Status", status.Value); } cmd.CommandText = string.Format(command, condition.ToString()); using (var dr = cmd.ExecuteDataReader()) { while (dr.Read()) { var orderViewModel = new OrderManageViewModel(); if (totalOrderCount == 0) { totalOrderCount = !Convert.IsDBNull(dr["TotalOrderCount"]) ? int.Parse(dr["TotalOrderCount"].ToString()) : 0; } orderViewModel.OrderId = !Convert.IsDBNull(dr["OrderId"]) ? Convert.ToInt64(dr["OrderId"]) : 0; orderViewModel.UserId = !Convert.IsDBNull(dr["UserId"]) ? Convert.ToInt32(dr["UserId"]) : 0; orderViewModel.CreateTime = !Convert.IsDBNull(dr["CreateTime"]) ? Convert.ToDateTime(dr["CreateTime"]) : DateTime.MinValue; orderViewModel.ProductId = !Convert.IsDBNull(dr["ProductId"]) ? Convert.ToInt32(dr["ProductId"]) : 0; orderViewModel.ProductCount = !Convert.IsDBNull(dr["ProductCount"]) ? Convert.ToInt32(dr["ProductCount"]) : 0; orderViewModel.Price = !Convert.IsDBNull(dr["Price"]) ? Convert.ToDecimal(dr["Price"]) : 0; orderViewModel.Status = !Convert.IsDBNull(dr["Status"]) ? Convert.ToInt32(dr["Status"]) : 0; orderViewModel.PayType = !Convert.IsDBNull(dr["PayType"]) ? Convert.ToInt32(dr["PayType"]) : 0; orderViewModel.ProductName = !Convert.IsDBNull(dr["ProductName"]) ? dr["ProductName"].ToString() : string.Empty; orderViewModel.TotalMoney = !Convert.IsDBNull(dr["TotalMoney"]) ? Convert.ToDecimal(dr["TotalMoney"]) : 0; orderViewModel.Mobile = !Convert.IsDBNull(dr["Mobile"]) ? dr["Mobile"].ToString() : string.Empty; orderViewModel.PayLogCount = !Convert.IsDBNull(dr["PayLogCount"]) ? Convert.ToInt32(dr["PayLogCount"]) : 0; if (orderViewModel.OrderId > 0) { orderList.Add(orderViewModel); } } } } var result = new PagedList <OrderManageViewModel>(orderList, pageIndex, pageSize, totalOrderCount); return(result); }
public ActionResult Orders() { OrderManageViewModel model = OrderViewHelpers.GetOrderManageViewModel(db, AppUserHelpers.GetOrganisationIdFromUser(db, User)); return(View(model)); }