Ejemplo n.º 1
0
        private void UpdateGrid()
        {
            var totalRow = 0;
            var page     = _grid.Pager;
            var sort     = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "Subject" : page.Sidx, page.Sord == "asc");
            IEnumerable <CRMPriceQuotation> customers = priceQuotationService.GetAll(priceSearch, sort, out totalRow, page.CurrentPage, page.PageSize, CurrenUser);

            _grid.Pager.Init(totalRow);
            if (totalRow == 0)
            {
                _grid.Data           = new List <CRMPriceQuotation>();
                ViewBag.TotalDisplay = string.Empty;
                return;
            }
            var crmPriceQuotations = customers as IList <CRMPriceQuotation> ?? customers.ToList();

            _grid.Data = crmPriceQuotations;

            var    cusFollow    = crmPriceQuotations.Count(x => x.CRMPriceStatus.Code == (byte)CRMPriceStaus.Following && x.CreatedById == CurrenUser.Id);
            var    cancle       = crmPriceQuotations.Count(x => x.CRMPriceStatus.Code == (byte)CRMPriceStaus.Cancel && x.CreatedById == CurrenUser.Id);
            var    cusFinish    = crmPriceQuotations.Count(x => x.CRMPriceStatus.Code == (byte)CRMPriceStaus.Finished && x.CreatedById == CurrenUser.Id);
            string totalDisplay =
                string.Format(Resources.Resource.CRM_PRICE_LIST_TOTAL,
                              totalRow, cusFollow, cusFinish, cancle);

            ViewBag.TotalDisplay = totalDisplay;
        }
Ejemplo n.º 2
0
        private void UpdateGridCarrierData()
        {
            var totalRow = 0;

            ViewData["CarrierTypes"] = CarrierTypes;
            var page = carriedGrid.Pager;
            var sort = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "CarrierAirLineName" : page.Sidx, page.Sord == "asc");
            //IEnumerable<ca> customers = customerServices.GetAll(_customerGrid.SearchCriteria, sort, out totalRow, page.CurrentPage, page.PageSize);
            var qr = carrierService.GetAll(carriedGrid.SearchCriteria);

            if (!CurrenUser.IsAdmin())
            {
                qr = qr.Where(x => x.IsHideUser == false);
            }
            qr       = qr.OrderBy(sort);
            totalRow = qr.Count();
            carriedGrid.Pager.Init(totalRow);
            if (totalRow == 0)
            {
                carriedGrid.Data = new List <CarrierAirLine>();
                return;
            }

            carriedGrid.Data = carrierService.GetListPager(qr, page.CurrentPage, page.PageSize);
        }
Ejemplo n.º 3
0
        private void UpdateGrid(CRMSearchModel filter = null)
        {
            var totalRow = 0;

            filter = filter ?? new CRMSearchModel();
            var page = _grid.Pager;
            var sort = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "Subject" : page.Sidx, page.Sord == "asc");
            IEnumerable <CrmCusDocumentModel> document = documentService.GetAll(filter, sort, out totalRow, page.CurrentPage, page.PageSize, CurrenUser);

            _grid.Pager.Init(totalRow);
            ViewBag.SearchingMode = filter;
            var sales = usersServices.GetAllSales(CurrenUser, false);

            ViewBag.AllSales = new SelectList(sales, "Id", "FullName");
            if (totalRow == 0)
            {
                _grid.Data           = new List <CrmCusDocumentModel>();
                ViewBag.TotalDisplay = string.Empty;
                return;
            }
            _grid.Data = document;

            string totalDisplay =
                string.Format("Tổng cộng:{0} tài liệu", totalRow);

            ViewBag.TotalDisplay = totalDisplay;
        }
Ejemplo n.º 4
0
        private void UpdateGridUserData()
        {
            var totalRow = 0;
            var page     = userGrid.Pager;
            var sort     = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "FullName" : page.Sidx, page.Sord == "asc");
            var model    = userGrid.SearchCriteria ?? new UsersModel();

            var user = UsersServices1.GetQuery(x =>
                                               (string.IsNullOrEmpty(model.UserName) || x.UserName.Contains(model.UserName)) &&
                                               (string.IsNullOrEmpty(model.FullName) || x.FullName.Contains(model.FullName)) &&
                                               (string.IsNullOrEmpty(model.RoleName) || x.RoleName == model.RoleName));

            user     = user.OrderBy(sort);
            totalRow = user.Count();
            userGrid.Pager.Init(totalRow);
            if (totalRow == 0)
            {
                userGrid.Data = new List <UsersModel>();
                return;
            }

            var list          = UsersServices1.GetListPager(user, page.CurrentPage, page.PageSize);
            var listUserModel = list.Select(u => UsersServicesImpl.ConvertModel(u)).ToList();

            userGrid.Data = listUserModel;
        }
Ejemplo n.º 5
0
        private void UpdateGridData()
        {
            var orderField = new SSM.Services.SortField(grid.Pager.Sidx, grid.Pager.Sord == "asc");

            filterModel.SortField = orderField;
            GetDefaultData();
            var totalRow = 0;

            grid.Data = stockReceivingService.GetAllModel(filterModel, grid.Pager.CurrentPage, grid.Pager.PageSize, out totalRow, CurrenUser);
            grid.Pager.Init(totalRow);
        }
Ejemplo n.º 6
0
        private void UpdateGridCountryData()
        {
            var totalRow = 0;
            var page     = countryGrid.Pager;
            var sort     = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "CountryName" : page.Sidx, page.Sord == "asc");
            var qr       = countryService.GetQuery(x => string.IsNullOrEmpty(countryGrid.SearchCriteria.CountryName) || x.CountryName.Contains(countryGrid.SearchCriteria.CountryName));

            qr       = qr.OrderBy(sort);
            totalRow = qr.Count();
            countryGrid.Pager.Init(totalRow);
            if (totalRow == 0)
            {
                countryGrid.Data = new List <Country>();
                return;
            }
            countryGrid.Data = countryService.GetListPager(qr, page.CurrentPage, page.PageSize);
        }
Ejemplo n.º 7
0
        private void UpdateGridCustomerData(bool isNotShipment = false)
        {
            ViewData["CustomerTypes"] = CustomerTypes;
            var totalRow = 0;
            var page     = _customerGrid.Pager;
            var sort     = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "FullName" : page.Sidx, page.Sord == "asc");
            IEnumerable <Customer> customers = customerServices.GetAll(_customerGrid.SearchCriteria, sort, out totalRow, page.CurrentPage, page.PageSize, CurrenUser);

            _customerGrid.Pager.Init(totalRow);
            if (totalRow == 0)
            {
                _customerGrid.Data = new List <Customer>();
                return;
            }

            _customerGrid.Data = customers;
        }
Ejemplo n.º 8
0
        public void UpdateGrid()
        {
            var page    = gridView.Pager;
            var sort    = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "Name" : page.Sidx, page.Sord == "asc");
            var prolist = productServices.GetAll(gridView.SearchCriteria);

            prolist = prolist.OrderBy(sort);
            int totalRows = prolist.Count();

            gridView.Pager.Init(totalRows);
            if (totalRows == 0)
            {
                gridView.Data = new List <Product>();
                return;
            }
            var list = productServices.GetListPager(prolist, page.CurrentPage, page.PageSize);

            gridView.Data = list;
        }
Ejemplo n.º 9
0
        private void UpdateGridSupplierData()
        {
            var page = _supplierGrid.Pager;
            var sort = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "FullName" : page.Sidx, page.Sord == "asc");
            var rows = 0;
            //var suppliers = _supplierServices.GetAll(_supplierGrid.SearchCriteria, sort, out rows, page.CurrentPage, page.PageSize);
            var suppliers = _supplierServices.GetAll(_supplierGrid.SearchCriteria);
            var q         = suppliers.OrderBy(sort);

            rows = q.Count();
            _supplierGrid.Pager.Init(rows);
            if (rows == 0)
            {
                _supplierGrid.Data = new List <Supplier>();
                return;
            }
            _supplierGrid.Data = _supplierServices.GetListPager(q, page.CurrentPage, page.PageSize);
            //_supplierGrid.Data = suppliers;
        }
Ejemplo n.º 10
0
        public JsonResult ListForCus(long refId)
        {
            var sort     = new SSM.Services.SortField("DocName", true);
            var totalRow = 0;
            //  var search = new PriceSearchModel() { CusId = cusId, PriceStaus = CRMPriceStaus.All };
            var filter = new CRMSearchModel()
            {
                Id = refId
            };
            IEnumerable <CrmCusDocumentModel> documentModels = documentService.GetAll(filter, sort, out totalRow, 1, int.MaxValue, CurrenUser);

            crmCustomer = crmCustomer ?? crmCustomerService.GetModelById(refId);
            var value = new
            {
                Views = this.RenderPartialView("_ListForCus", documentModels),
                Title = string.Format(@"{0}", "Danh sách tài liệu của khách hàng " + crmCustomer.CompanyShortName),
            };

            return(JsonResult(value, true));
        }
Ejemplo n.º 11
0
        public ActionResult ListByCus(long refId)
        {
            var sort     = new SSM.Services.SortField("Subject", true);
            var totalRow = 0;
            var search   = new PriceSearchModel()
            {
                CusId = refId
            };
            IEnumerable <CRMPriceQuotation> customers = priceQuotationService.GetAll(search, sort, out totalRow, 1, 100, CurrenUser);

            crmCustomer = crmCustomer ?? crmCustomerService.GetModelById(refId);
            var value = new
            {
                Views      = this.RenderPartialView("_ListForCus", customers),
                CloseOther = true,
                Title      = string.Format(@"{0}", "List Bao gia cua khách hàng " + crmCustomer.CompanyShortName),
            };

            return(JsonResult(value, true));
        }
Ejemplo n.º 12
0
        public void UpdateGridInfomation()
        {
            var orderField = new SSM.Services.SortField(_gridInfo.Pager.Sidx, _gridInfo.Pager.Sord == "asc");

            filter.SortField = orderField;
            var page = _gridInfo.Pager;
            //bool checkEdit = CurrenUser.IsEditNew(null) || CurrenUser.AllowRegulationApproval;
            //var grpermission = CurrenUser.UserGroups.Select(x => x.GroupId).ToList();
            var newlist = newsServices.GetScfNewsByUser(CurrenUser);

            newlist = newlist.Where(x => x.Type == (byte)NewType.Infomation &&
                                    (string.IsNullOrEmpty(filter.Keyworks) || x.Header.Contains(filter.Keyworks)) &&
                                    (filter.CategoryId == 0 || x.CateloryId == filter.CategoryId) &&
                                    (x.IsApproved != filter.IsPending) &&
                                    (filter.GroupId == 0 || x.GroupAccessPermissions.Any(g => g.GroupId == filter.GroupId))
                                    );
            newlist = newlist.OrderBy(orderField);
            var totalRows = (int)newlist.Count();

            ViewBag.SearchingMode = filter ?? new NewSearchModel();
            ViewBag.AllGroup      = groupService.GetAll(x => x.IsActive);
            _gridInfo.Pager.Init(totalRows);
            if (totalRows == 0)
            {
                _gridInfo.Data = new List <NewsModel>();
                return;
            }

            var list     = newsServices.GetListPager(newlist, page.CurrentPage, page.PageSize);
            var listview = list.Select(x => NewsServices.ToModel(x));
            var viewData = new List <NewsModel>();

            foreach (var it in listview)
            {
                IEnumerable <ServerFile> files = freightServices.getServerFile(it.Id, new SSM.Models.NewsModel().GetType().ToString());
                it.FilesList = files != null?files.ToList() : new List <ServerFile>();

                viewData.Add(it);
            }
            _gridInfo.Data = viewData;
        }
Ejemplo n.º 13
0
        private void UpdateGridData()
        {
            // int skip = (gridView.Pager.CurrentPage - 1) * gridView.Pager.PageSize;
            var page   = gridView.Pager;
            int take   = gridView.Pager.PageSize;
            var groups = groupService.GetQuerys(gridView.SearchCriteria);
            var sort   = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "Name" : page.Sidx, page.Sord == "asc");

            int totalRows = groups.Count();

            gridView.Pager.Init(totalRows);
            if (totalRows == 0)
            {
                gridView.Data = new List <Group>();
                return;
            }
            groups = groups.OrderBy(sort);
            IEnumerable <Group> list = groupService.GetListPager(groups, gridView.Pager.CurrentPage, take);

            gridView.Data = list;
        }
Ejemplo n.º 14
0
        private void UpdateGridAgentData()
        {
            ViewData["CountryListAgent"] = new SelectList(Countries, "CountryName", "CountryName");
            var totalRow = 0;
            var page     = agentGrid.Pager;
            var sort     = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "AgentName" : page.Sidx, page.Sord == "asc");
            var qr       = agentService.GetAll(agentGrid.SearchCriteria);

            if (!CurrenUser.IsAdmin())
            {
                qr = qr.Where(x => x.IsHideUser == false);
            }
            qr       = qr.OrderBy(sort);
            totalRow = qr.Count();
            agentGrid.Pager.Init(totalRow);
            if (totalRow == 0)
            {
                agentGrid.Data = new List <Agent>();
                return;
            }
            agentGrid.Data = agentService.GetListPager(qr, page.CurrentPage, page.PageSize);
        }
Ejemplo n.º 15
0
        public JsonResult ListByCus(long refId, bool isEventAction = false)
        {
            var sort = new SSM.Services.SortField("Subject", true);

            ViewBag.IsEventAction = isEventAction;
            var totalRow = 0;
            var page     = new Pager()
            {
                CurrentPage = 1, PageSize = 100
            };
            IEnumerable <CRMEventModel> listEvents = eventService.GetAll(sort, out totalRow, page, refId, isEventAction, CurrenUser);

            crmCustomer = crmCustomer ?? crmCustomerService.GetModelById(refId);
            var value = new
            {
                Views      = this.RenderPartialView("_ListForCus", listEvents),
                CloseOther = true,
                Title      = string.Format(@"Danh sách {0} của khách hàng {1}", isEventAction ? "sự kiện" : "viếng thăm", crmCustomer.CompanyShortName),
            };

            return(JsonResult(value, true));
        }
Ejemplo n.º 16
0
        private void UpdateGridAreaData()
        {
            var totalRow = 0;
            var page     = areaGrid.Pager;
            var sort     = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "AreaAddress" : page.Sidx, page.Sord == "asc");

            var area = new Area();

            if (areaGrid.SearchCriteria != null)
            {
                area = new Area
                {
                    AreaAddress = areaGrid.SearchCriteria.AreaAddress,
                    CountryId   = areaGrid.SearchCriteria.CountryId,
                    trading_yn  = areaGrid.SearchCriteria.IsTrading,
                };
            }
            var qr = areaService.GetAll(area);

            if (!CurrenUser.IsAdmin())
            {
                qr = qr.Where(x => x.IsHideUser == false);
            }
            qr       = qr.OrderBy(sort);
            totalRow = qr.Count();
            areaGrid.Pager.Init(totalRow);
            List <AreaModel> list = new List <AreaModel>();

            if (totalRow == 0)
            {
                areaGrid.Data = list;
                return;
            }
            var data = areaService.GetListPager(qr, page.CurrentPage, page.PageSize);

            list.AddRange(data.Select(db => Mapper.Map <AreaModel>(db)));
            areaGrid.Data = list;
        }
Ejemplo n.º 17
0
        private void UpdateGridEmailHist(long idPrice)
        {
            var price = priceQuotationService.GetModel(idPrice);

            if (price == null)
            {
                return;
            }
            var totalRow = 0;
            var page     = _gridEmailHist.Pager;
            var sort     = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "Subject" : page.Sidx, page.Sord == "asc");
            IEnumerable <CRMEmailHistoryModel> emaiList = emailHistoryService.GetAll(sort, out totalRow, page.CurrentPage, page.PageSize, idPrice);

            _gridEmailHist.Pager.Init(totalRow);
            if (totalRow == 0)
            {
                _gridEmailHist.Data  = new List <CRMEmailHistoryModel>();
                ViewBag.TotalDisplay = string.Empty;
                return;
            }
            _gridEmailHist.Data    = emaiList;
            ViewBag.PriceQuotation = price ?? new CRMPriceQuotationModel();
        }
Ejemplo n.º 18
0
        private void UpdateGrid(ListEventFilter filter = null)
        {
            filter       = filter ?? new ListEventFilter();
            filter.Sales = filter.Sales ?? 0;
            bool isEventAction = filter.OfEvent == TypeOfEvent.Events;

            ViewBag.IsEventAction = isEventAction;
            var page     = _grid.Pager;
            var sort     = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "DateEvent" : page.Sidx, page.Sord == "asc");
            var totalRow = 0;
            var qr       = eventService.GetQuery(x => (filter.Sales == 0 || filter.Sales == x.CreatedById ||
                                                       (x.CRMCustomer.CRMFollowCusUsers != null &&
                                                        x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == filter.Sales)) ||
                                                       (x.CRMCustomer.CreatedById == CurrenUser.Id) ||
                                                       (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == filter.Sales))
                                                       ) &&
                                                 (filter.Status == CRMEventStatus.All || x.Status == (byte)filter.Status) &&
                                                 (string.IsNullOrEmpty(filter.CustomerName) ||
                                                  x.CRMCustomer.CompanyShortName.Contains(filter.CustomerName) ||
                                                  x.CRMCustomer.CompanyName.Contains(filter.CustomerName)));

            if (filter.OfEvent.HasValue)
            {
                qr = filter.OfEvent == TypeOfEvent.Events ? qr.Where(x => x.IsEventAction == true) : qr.Where(x => x.IsEventAction == false);
            }

            if (filter.BeginDate.HasValue)
            {
                qr = qr.Where(x => x.DateEvent >= filter.BeginDate);
            }
            if (filter.EndDate.HasValue)
            {
                qr = qr.Where(x => x.DateEvent.Date <= filter.EndDate);
            }

            if (!CurrenUser.IsDirecter() && filter.Sales == 0)
            {
                if (CurrenUser.IsDepManager())
                {
                    qr = qr.Where(x => x.User.DeptId == CurrenUser.DeptId || (x.CRMCustomer.CRMFollowCusUsers != null &&
                                                                              x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == CurrenUser.Id)) ||
                                  (x.CRMCustomer.CreatedById == CurrenUser.Id) ||
                                  (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == CurrenUser.Id)));
                }
                else
                {
                    qr = qr.Where(x => x.CreatedById == CurrenUser.Id ||
                                  (x.CRMCustomer.CRMFollowCusUsers != null &&
                                   x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == CurrenUser.Id)) ||
                                  (x.CRMCustomer.CreatedById == CurrenUser.Id) ||
                                  (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == CurrenUser.Id)));
                }
            }
            qr       = qr.OrderByDescending(x => x.DateEvent).ThenBy(sort);
            totalRow = qr.Count();
            var list     = eventService.GetListPager(qr, page.CurrentPage, page.PageSize);
            var listView = list.Select(x => eventService.ToModel(x)).ToList();

            _grid.Pager.Init(totalRow);
            if (totalRow == 0)
            {
                _grid.Data           = new List <CRMEventModel>();
                ViewBag.TotalDisplay = string.Empty;
                return;
            }
            var    typeOfEvent = filter.OfEvent == TypeOfEvent.Visited ? "viếng thăm" : "sự kiện";
            var    finished    = list.Count(x => x.Status == (byte)CRMEventStatus.Finished);
            var    follow      = list.Count(x => x.Status == (byte)CRMEventStatus.Follow);
            string display     = string.Format(Resources.Resource.CRM_EVENT_LIST_TOTAL, totalRow, typeOfEvent, finished, follow);

            ViewBag.TotalDisplay = display;
            _grid.Data           = listView;
        }