Ejemplo n.º 1
0
 public static IncomeList Find(int userID, int bussinessID, IncomeFilter filter = null, int? max = 100)
 {
     var result = new IncomeList("", filter);
     using (var con = Repo.DB.SKtimeManagement)
     {
         result.Data = con.Query<IncomeInfo>(FindQuery(userID, bussinessID, filter, max)).ToList();
     }
     return result;
 }
Ejemplo n.º 2
0
        public ActionResult List(IncomeFilter filter)
        {
            var data = IncomeInfo.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));
        }
Ejemplo n.º 3
0
        public ActionResult Download(IncomeFilter filter)
        {
            var result = false;

            try
            {
                var data = IncomeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", filter, true, null);
                if (data != null)
                {
                    var fileName = String.Format("Incomes_{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));
        }
Ejemplo n.º 4
0
        public static string FindQuery(int userID, int bussinessID, IncomeFilter filter = null, int? max = 100)
        {
            var conditions = new List<string>();
            if (filter != null)
            {
                if (!String.IsNullOrEmpty(filter.Code))
                    conditions.Add(String.Format("and i.Code like N'%{0}%'", filter.Code));
                if (filter.EmployeeID.HasValue)
                    conditions.Add(String.Format("and i.EmployeeID = {0}", filter.EmployeeID.Value));
                if (filter.WarehouseID.HasValue)
                    conditions.Add(String.Format("and i.WarehouseID = {0}", filter.WarehouseID.Value));
                if (filter.From.HasValue)
                    conditions.Add(String.Format("and i.SubmitDate >= '{0}'", filter.From.Value.ToString(Constants.DatabaseDatetimeString)));
                if (filter.To.HasValue)
                    conditions.Add(String.Format("and i.SubmitDate <= '{0}'", filter.To.Value.ToString(Constants.DatabaseDatetimeString)));

            }
            return String.Format(
                    @"select {3} i.*, e.Name as [EmployeeName], w.Name as [WarehouseName]
                    from Income i join Employee e on i.EmployeeID = e.ID  join Warehouse w on i.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 i.Status = 'active' and i.BussinessID = {0} {1} order by i.ID desc",
                bussinessID, String.Join(" ", conditions), userID,
                max.HasValue ? String.Format("top {0}", max.Value) : "");
        }
Ejemplo n.º 5
0
 public IncomeList(string message = "", IncomeFilter filter = null)
 {
     Data = new List<IncomeInfo>();
     Filter = filter != null ? filter : new IncomeFilter();
     Message = message;
 }
Ejemplo n.º 6
0
 public static IncomeList Find(int userID, int employeeID, int bussinessID, string message = "", IncomeFilter filter = null, bool log = false, int? max = 100)
 {
     QueryOutput queryResult;
     var result = new IncomeList(message, filter);
     result.Data = Query<IncomeInfo>(new DbQuery(userID, employeeID, DbAction.Income.View, FindQuery(userID, bussinessID, filter, max), log), out queryResult);
     return result;
 }