コード例 #1
0
        public ActionResult Index()
        {
            var    login = SKtimeManagement.Login.Get(UserID);
            object model;
            string view;
            var    isAjax = Request.IsAjaxRequest();

            if (login.Name == "admin" || login.Type == LoginType.Office)
            {
                view  = isAjax ? Views.SummaryAdminPartial : Views.SummaryAdmin;
                model = SummaryAdmin.Get(Employee.BussinessID);
            }
            else
            {
                view  = isAjax ? Views.SummaryPartial : Views.Summary;
                model = Summary.Get(Employee.ID, Employee.BussinessID, UserID);
            }
            if (isAjax)
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(view, model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(view, model));
        }
コード例 #2
0
ファイル: Summary.cs プロジェクト: war-man/SKTIME
 public static SummaryAdmin Get(int bussinessID)
 {
     try
     {
         using (var con = Repo.DB.SKtimeManagement)
         {
             var now    = DateTime.Now;
             var result = new SummaryAdmin();
             result.Logs = con.Query <Log>(
                 String.Format(
                     @"select top 100 l.*, e.Name as [EmployeeName] 
                     from Log l join Employee e on l.EmployeeID = e.ID 
                     where e.BussinessID = {0} and (Action like N'%create%' or Action like N'%modify%' or Action like N'%remove%') 
                     order by l.ID desc", bussinessID)).ToList();
             result.PopularProductsByQuantity = con.Query <Popular>(
                 String.Format(
                     @"select top 100 e.ProductID as [ID], p.Name, sum(e.Quantity) as [TotalQuantity], sum(e.Quantity * e.Price) as [Revenue]
                     from ExportProduct e join Product p on e.ProductID = p.ID 
                     where p.BussinessID = {0} and e.OrderID is not null group by e.ProductID, p.Name 
                     order by sum(e.Quantity) desc",
                     bussinessID)).ToList();
             result.PopularTagsByQuantity = con.Query <Popular>(
                 String.Format(
                     @"select top 100 t.Name, sum(e.Quantity) as [TotalQuantity], sum(e.Quantity * e.Price)  as [Revenue]
                     from Tag t join ProductTag pt on t.ID = pt.TagID join ExportProduct e on pt.ProductID = e.ProductID join Product p on e.ProductID = p.ID 
                     where p.BussinessID = 1 and e.OrderID is not null 
                     group by t.Name order by sum(e.Quantity) desc",
                     bussinessID)).ToList();
             result.PendingExports = con.Query <ExportRecord>(
                 String.Format(
                     @"select e.ID, e.EmployeeID, e.BussinessID, e.WarehouseID, e.Code, e.SubmitDate, e.Note, e.Status, e.ToWarehouseID, tw.Name as [ToWarehouseName], w.Name as [WarehouseName], em.Name as [EmployeeName]
                     from Export e 
                         join Warehouse w on e.WarehouseID = w.ID and w.Status = 'active'
                         join Employee em on e.EmployeeID = em.ID
                         join ExportProduct p on e.ID = p.ExportID
                         join Warehouse tw on e.ToWarehouseID = tw.ID and tw.Status = 'active'
                     where e.BussinessID = {0} and e.Removed = 0 and e.Status <> N'{1}'
                     group by e.ID, e.EmployeeID, e.BussinessID, e.WarehouseID, e.Code, e.SubmitDate, e.Note, e.Status, e.ToWarehouseID, tw.Name, w.Name, em.Name
                     order by e.ID desc", bussinessID, ExportStatus.Exported)).ToList();
             return(result);
         }
     }
     catch
     {
         return(new SummaryAdmin());
     }
 }