public static string FindQuery(int userID, int bussinessID, OutcomeFilter filter = null, int?max = 100) { var conditions = new List <string>(); if (filter != null) { if (!String.IsNullOrEmpty(filter.Code)) { conditions.Add(String.Format("and o.Code like N'%{0}%'", filter.Code)); } if (filter.EmployeeID.HasValue) { conditions.Add(String.Format("and o.EmployeeID = {0}", filter.EmployeeID.Value)); } if (filter.WarehouseID.HasValue) { conditions.Add(String.Format("and o.WarehouseID = {0}", filter.WarehouseID.Value)); } if (filter.From.HasValue) { conditions.Add(String.Format("and o.SubmitDate >= '{0}'", filter.From.Value.ToString(Constants.DatabaseDatetimeString))); } if (filter.To.HasValue) { conditions.Add(String.Format("and o.SubmitDate <= '{0}'", filter.To.Value.ToString(Constants.DatabaseDatetimeString))); } } return(String.Format( @"select {3} o.*, e.Name as [EmployeeName], w.Name as [WarehouseName] from Outcome o join Employee e on o.EmployeeID = e.ID join Warehouse w on o.WarehouseID = w.ID and w.Status = 'active' and ((select Username from Login where ID = {2}) = 'admin' or w.ID in (select WarehouseID from LoginWarehouse where LoginID = {2})) where o.Status = 'active' and o.BussinessID = {0} {1} order by o.ID desc", bussinessID, String.Join(" ", conditions), userID, max.HasValue ? String.Format("top {0}", max.Value) : "")); }
public static OutcomeList Find(int userID, int bussinessID, OutcomeFilter filter = null, int?max = 100) { var result = new OutcomeList("", filter); using (var con = Repo.DB.SKtimeManagement) { result.Data = con.Query <OutcomeInfo>(FindQuery(userID, bussinessID, filter, max)).ToList(); } return(result); }
public ActionResult List(OutcomeFilter filter) { var data = OutcomeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", filter, true); if (Request.IsAjaxRequest()) { return(Json(new { result = true, html = RenderPartialViewToString(Views.ListPartial, data) }, JsonRequestBehavior.AllowGet)); } return(View(Views.List, data)); }
public ActionResult Download(OutcomeFilter filter) { var result = false; try { var data = OutcomeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", filter, true, null); if (data != null) { var fileName = String.Format("Outcomes_{0}.xls", DateTime.Now.ToString("ddMMyyyyHHmmss")); var file = String.Format("{0}/Content/Download/{1}", SiteConfiguration.ApplicationPath, fileName); Functions.CheckDirectory(String.Format("{0}/Content/Download/", SiteConfiguration.ApplicationPath)); SaveDownload(file, data.Data); Session[SessionKey.Download] = fileName; result = true; } } catch { } return(Json(new { result = result }, JsonRequestBehavior.DenyGet)); }
public OutcomeList(string message = "", OutcomeFilter filter = null) { Data = new List <OutcomeInfo>(); Filter = filter != null ? filter : new OutcomeFilter(); Message = message; }
public static OutcomeList Find(int userID, int employeeID, int bussinessID, string message = "", OutcomeFilter filter = null, bool log = false, int?max = 100) { QueryOutput queryResult; var result = new OutcomeList(message, filter); result.Data = Query <OutcomeInfo>(new DbQuery(userID, employeeID, DbAction.Outcome.View, FindQuery(userID, bussinessID, filter, max), log), out queryResult); return(result); }