コード例 #1
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (string.IsNullOrWhiteSpace(this.PublicKey) || string.IsNullOrWhiteSpace(this.PrivateKey))
            {
                throw new ApplicationException("reCAPTCHA needs to be configured with a public & private key.");
            }

            ThisPage.RegisterScriptFile("re-captcha", GenerateChallengeUrl());
        }
コード例 #2
0
        public ActionResult Index(int?page)
        {
            var      users      = DbContext.Users.Where(s => s.Status == AppUser.UserStatus.NotDeleted).ToList();
            int      pageSize   = Constant.PageSize;
            int      pageNumber = (page ?? 1);
            ThisPage thisPage   = new ThisPage()
            {
                CurrentPage = pageNumber,
                TotalPage   = Math.Ceiling((double)users.Count() / pageSize)
            };

            ViewBag.Page = thisPage;
            return(View(users.Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList()));
        }
コード例 #3
0
        public ActionResult Index(string searchString, string currentFilter, int?page, string filter)
        {
            if (!string.IsNullOrEmpty(filter))
            {
                var filterThisPage = JsonConvert.DeserializeObject <ThisPage>(filter);
                currentFilter = filterThisPage.SearchString;
            }

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var flowerImages = imageService.GetList().Where(s => !string.IsNullOrEmpty(s.FlowerCode));

            if (!String.IsNullOrEmpty(searchString))
            {
                flowerImages = flowerImages.Where(s => s.Flower.Name.Contains(searchString));
            }

            int      pageSize   = Constant.PageSize;
            int      pageNumber = (page ?? 1);
            ThisPage thisPage   = new ThisPage()
            {
                CurrentPage  = pageNumber,
                TotalPage    = Math.Ceiling((double)flowerImages.Count() / pageSize),
                SearchString = searchString
            };

            ViewBag.Page = thisPage;
            // nếu page == null thì lấy giá trị là 1, nếu không thì giá trị là page
            //return View(students.ToList().ToPagedList(pageNumber, pageSize));
            return(View(flowerImages.OrderBy(s => s.FlowerCode).Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList()));
        }
コード例 #4
0
        public JsonResult ExportToExcel(string filter, string startDate, string endDate)
        {
            var filterThisPage = new ThisPage();

            if (!string.IsNullOrEmpty(filter))
            {
                filterThisPage = JsonConvert.DeserializeObject <ThisPage>(filter);
            }
            var orders = GetCurrentOrders(filterThisPage.SearchString, filterThisPage.Status,
                                          filterThisPage.PaymentType, filterThisPage.StartDate, filterThisPage.EndDate);

            //foreach (var item in orders)
            //{
            //    item.UserName = userService.GetUserNameByUserId(item.UserId);
            //}
            orders.ForEach(s => { s.UserName = userService.GetUserNameByUserId(s.UserId); });
            var gv = new GridView();

            gv.DataSource = orders;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            var strHeader = string.Format("attachment; filename=Orders - {0} to {1}.xls", startDate, endDate);

            Response.AddHeader("content-disposition", strHeader);
            Response.ContentType = "application/ms-excel";
            Response.Charset     = "";
            StringWriter   objStringWriter   = new StringWriter();
            HtmlTextWriter objHtmlTextWriter = new HtmlTextWriter(objStringWriter);

            gv.RenderControl(objHtmlTextWriter);
            Response.Output.Write(objStringWriter.ToString());
            Response.Flush();
            Response.End();
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public ActionResult IndexCustomer(string sortOrder, string searchString, string currentFilter,
                                          int?page, string start, string end, string status,
                                          string paymentType, string filter)
        {
            if (!string.IsNullOrEmpty(filter))
            {
                var filterThisPage = JsonConvert.DeserializeObject <ThisPage>(filter);
                currentFilter = filterThisPage.SearchString;
                paymentType   = filterThisPage.PaymentType;
                status        = filterThisPage.Status;
                start         = filterThisPage.StartDate;
                end           = filterThisPage.EndDate;
            }

            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            // lúc đầu vừa vào thì sortOrder là null, cho nên gán NameSortParm = name_desc
            // Ấn vào link Full name thì lúc đó NameSortParm có giá trị là name_desc, sortOrder trên view được gán = NameSortParm cho nên sortOrder != null
            // và NameSortParm = ""
            // Ấn tiếp vào link Full Name thì sortOrder = "" cho nên NameSortParm = name_desc
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            if (!string.IsNullOrEmpty(searchString))
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            var orders = GetCurrentOrders(searchString, status, paymentType, start, end).Where(s => s.UserId == userService.GetCurrentUserId());

            //ViewBag.CurrentFilter = searchString;

            //if (!String.IsNullOrEmpty(searchString))
            //{
            //    int id;
            //    if (Int32.TryParse(searchString, out id))
            //    {
            //        orders = orders.Where(s => s.Id == id);
            //    }
            //    else
            //    {
            //        orders = orders.Where(s => (!string.IsNullOrEmpty(s.ShipName) && s.ShipName.Contains(searchString)) || (!string.IsNullOrEmpty(s.CreatedBy) && s.CreatedBy.Contains(searchString)));
            //    }
            //}

            //if (!String.IsNullOrEmpty(status))
            //{
            //    orders = orders.Where(s => s.Status == (OrderStatus)Enum.Parse(typeof(OrderStatus), status));
            //}

            //if (!String.IsNullOrEmpty(paymentType))
            //{
            //    orders = orders.Where(s => s.PaymentTypeId == (PaymentType)Enum.Parse(typeof(PaymentType), paymentType));
            //}

            //var compareDate = new DateTimeModel();

            //if (!string.IsNullOrEmpty(start))
            //{
            //    var compareStartDate = Utility.GetNullableDate(start).Value.Date + new TimeSpan(0, 0, 0);
            //    orders = orders.Where(s => (s.UpdatedAt >= compareStartDate));
            //    compareDate.startDate = compareStartDate;
            //}
            //if (!string.IsNullOrEmpty(end))
            //{
            //    var compareEndDate = Utility.GetNullableDate(end).Value.Date + new TimeSpan(23, 59, 59);
            //    orders = orders.Where(s => (s.UpdatedAt <= compareEndDate));
            //    compareDate.endDate = compareEndDate;
            //}

            //ViewBag.CompareDate = compareDate;

            switch (sortOrder)
            {
            case "name_desc":
                orders = orders.OrderByDescending(s => s.ShipName);
                break;

            case "Date":
                orders = orders.OrderBy(s => s.CreatedAt);
                break;

            case "date_desc":
                orders = orders.OrderByDescending(s => s.CreatedAt);
                break;

            default:
                orders = orders.OrderBy(s => s.ShipName);
                break;
            }


            int      pageSize   = Constant.PageSizeOrdersOnCustomerPage;
            int      pageNumber = (page ?? 1);
            ThisPage thisPage   = new ThisPage()
            {
                CurrentPage  = pageNumber,
                TotalPage    = Math.Ceiling((double)orders.Count() / pageSize),
                CurrentType  = Constant.Customer,
                SearchString = searchString,
                PaymentType  = paymentType,
                Status       = status,
                StartDate    = start,
                EndDate      = end
            };

            ViewBag.Page = thisPage;
            // nếu page == null thì lấy giá trị là 1, nếu không thì giá trị là page
            //return View(students.ToList().ToPagedList(pageNumber, pageSize));
            //var nl = mySQLOrderService.GetList().ToList();
            return(View(orders.Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList()));
        }
コード例 #6
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public void Redirect(string Path)
 {
     ThisPage.Redirect(Path);
 }
コード例 #7
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public long QLong(string Key, long DefaultValue)
 {
     return(ThisPage.QLong(Key, DefaultValue));
 }
コード例 #8
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public int QInt(string Key)
 {
     return(ThisPage.QInt(Key));
 }
コード例 #9
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public int QInt(string Key, int DefaultValue)
 {
     return(ThisPage.QInt(Key, DefaultValue));
 }
コード例 #10
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public string href(string key, string path)
 {
     return(ThisPage.href(key, path));
 }
コード例 #11
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public string QString(string Key, string DefaultValue)
 {
     return(ThisPage.QString(Key, DefaultValue));
 }
コード例 #12
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public string QString(string Key)
 {
     return(ThisPage.QString(Key));
 }
コード例 #13
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public string css(object BasePath)
 {
     return(ThisPage.css(BasePath));
 }
コード例 #14
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public string img(object BasePath, string relDir = "", bool generateTag = false)
 {
     return(ThisPage.img(BasePath, relDir, generateTag));
 }
コード例 #15
0
        // GET: Products
        public ActionResult Index(string productCategoryCode, string sortOrder, string searchString, string currentFilter, int?page, string type, string filter)
        {
            if (!string.IsNullOrEmpty(filter))
            {
                var filterThisPage = JsonConvert.DeserializeObject <ThisPage>(filter);
                currentFilter = filterThisPage.SearchString;
            }

            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            // lúc đầu vừa vào thì sortOrder là null, cho nên gán NameSortParm = name_desc
            // Ấn vào link Full name thì lúc đó NameSortParm có giá trị là name_desc, sortOrder trên view được gán = NameSortParm cho nên sortOrder != null
            // và NameSortParm = ""
            // Ấn tiếp vào link Full Name thì sortOrder = "" cho nên NameSortParm = name_desc
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var flowers = mySQLFlowerService.GetList();

            if (!String.IsNullOrEmpty(productCategoryCode))
            {
                flowers = flowers.Where(s => s.CategoryCode == productCategoryCode);
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                flowers = flowers.Where(s => s.Name.Contains(searchString) || s.Code.Contains(searchString) ||
                                        s.Category.Name.Contains(searchString) || s.Category.Code.Contains(searchString));
            }
            switch (sortOrder)
            {
            case "name_desc":
                flowers = flowers.OrderByDescending(s => s.Name);
                break;

            case "Date":
                flowers = flowers.OrderBy(s => s.UpdatedAt);
                break;

            case "date_desc":
                flowers = flowers.OrderByDescending(s => s.UpdatedAt);
                break;

            default:
                flowers = flowers.OrderBy(s => s.Name);
                break;
            }

            int      pageSize   = Constant.PageSize;
            int      pageNumber = (page ?? 1);
            ThisPage thisPage   = new ThisPage()
            {
                CurrentPage  = pageNumber,
                TotalPage    = Math.Ceiling((double)flowers.Count() / pageSize),
                FunctionType = type,
                SearchString = searchString
            };

            ViewBag.Page = thisPage;

            // nếu page == null thì lấy giá trị là 1, nếu không thì giá trị là page
            //return View(students.ToList().ToPagedList(pageNumber, pageSize));
            return(View(flowers.Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList()));
        }
コード例 #16
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public long QLong(string Key)
 {
     return(ThisPage.QLong(Key));
 }
コード例 #17
0
        public ActionResult IndexCustomer(string amount, string sortFlower, string levelOneCategoryCode, string categoryCode,
                                          string searchString, string currentFilter, int?page, string searchFlowerGlobal, string filter)
        {
            if (!string.IsNullOrEmpty(filter))
            {
                var filterThisPage = JsonConvert.DeserializeObject <ThisPage>(filter);
                if (string.IsNullOrEmpty(searchString))
                {
                    currentFilter = filterThisPage.SearchString;
                }
                if (string.IsNullOrEmpty(amount))
                {
                    amount = filterThisPage.Amount;
                }
                if (string.IsNullOrEmpty(sortFlower))
                {
                    sortFlower = filterThisPage.SortFlower;
                }
                if (string.IsNullOrEmpty(searchFlowerGlobal))
                {
                    searchFlowerGlobal = filterThisPage.SearchFlowerGlobal;
                }
            }

            if (string.IsNullOrEmpty(levelOneCategoryCode) && string.IsNullOrEmpty(categoryCode) && string.IsNullOrEmpty(searchFlowerGlobal))
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.CurrentUserName = userService.GetCurrentUserName();

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var flowers = mySQLFlowerService.GetList();

            if (!String.IsNullOrEmpty(levelOneCategoryCode))
            {
                var categories = mySQLCategoryService.GetList().Where(s => s.ParentCode == levelOneCategoryCode);
                flowers            = categories.SelectMany(s => s.Flowers).Where(s => s.Status == Flower.FlowerStatus.NotDeleted).ToList();
                ViewBag.Categories = categories;
                //categoryCode = categories.FirstOrDefault().Code;
            }

            if (!String.IsNullOrEmpty(categoryCode))
            {
                flowers = flowers.Where(s => s.CategoryCode == categoryCode);
                var category = mySQLCategoryService.Detail(categoryCode);
                ViewBag.Categories = mySQLCategoryService.GetList().Where(s => s.ParentCode == category.ParentCode);
                //var productCategory = mySQLCategoryService.Detail(categoryCode);
                //var list = productCategory.OwnerOfCourses.ToList();
                //ViewBag.Teachers = list;
            }

            if (!String.IsNullOrEmpty(searchFlowerGlobal))
            {
                flowers = flowers.Where(s => s.Name.ToUpper().Contains(searchFlowerGlobal.ToUpper()) || s.Code.ToUpper().Contains(searchFlowerGlobal.ToUpper()));
            }

            ViewBag.CurrentFilterFlowerGlobal = searchFlowerGlobal;

            if (!String.IsNullOrEmpty(searchString))
            {
                flowers = flowers.Where(s => s.Name.ToUpper().Contains(searchString.ToUpper()) || s.Code.ToUpper().Contains(searchString.ToUpper()));
            }

            if (!String.IsNullOrEmpty(sortFlower))
            {
                switch (sortFlower)
                {
                case "1":
                    flowers = flowers.OrderBy(s => s.Name);
                    break;

                case "2":
                    flowers = flowers.OrderBy(s => Utility.NewPrice(s.Price, s.Discount));
                    break;

                default:
                    break;
                }

                if (string.IsNullOrEmpty(searchFlowerGlobal))
                {
                    levelOneCategoryCode = GetLevelOneCategoryCode(flowers);
                    var lstCategories = mySQLCategoryService.GetList().Where(s => s.ParentCode == levelOneCategoryCode);
                    ViewBag.Categories = lstCategories;
                }
            }

            if (!String.IsNullOrEmpty(amount))
            {
                //var culture = System.Globalization.CultureInfo.GetCultureInfo("vn");
                var nbspace      = "\u00A0";
                var text         = HttpUtility.HtmlDecode(HttpUtility.HtmlDecode(nbspace));
                var newStrAmount = amount.Replace(",", string.Empty).Replace(" ", string.Empty).Replace(text, string.Empty);
                var arrCharDong  = newStrAmount.Where(s => !char.IsDigit(s)).ToArray();
                var amounts      = newStrAmount.Replace(arrCharDong.FirstOrDefault(), ',').Split(',');
                amounts = amounts.Skip(1).ToArray();
                var min = Double.Parse(amounts.First());
                var max = Double.Parse(amounts.Last());
                flowers = flowers.Where(s => Utility.NewPrice(s.Price, s.Discount) <= max && Utility.NewPrice(s.Price, s.Discount) >= min);

                if (string.IsNullOrEmpty(searchFlowerGlobal))
                {
                    levelOneCategoryCode = GetLevelOneCategoryCode(flowers);
                    var lstCategories = mySQLCategoryService.GetList().Where(s => s.ParentCode == levelOneCategoryCode);
                    ViewBag.Categories = lstCategories;
                }
            }

            int      pageSize   = Constant.PageSizeFlowersOnCustomerPage;
            int      pageNumber = (page ?? 1);
            ThisPage thisPage   = new ThisPage()
            {
                CurrentPage          = pageNumber,
                TotalPage            = Math.Ceiling((double)flowers.Count() / pageSize),
                ProductCategoryCode  = categoryCode,
                LevelOneCategoryCode = levelOneCategoryCode,
                CurrentType          = Constant.Customer,
                SearchString         = searchString,
                Amount             = amount,
                SortFlower         = sortFlower,
                SearchFlowerGlobal = searchFlowerGlobal
            };

            ViewBag.Page = thisPage;

            //var flowerCategories = new List<Category>();
            //foreach(var item in flowers)
            //{
            //    var category = mySQLCategoryService.Detail(item.CategoryCode);
            //    flowerCategories.Add(category);
            //}

            // nếu page == null thì lấy giá trị là 1, nếu không thì giá trị là page
            //return View(students.ToList().ToPagedList(pageNumber, pageSize));

            var list = flowers.Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList();

            return(View(flowers.Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList()));
        }
コード例 #18
0
ファイル: BaseUserControl.cs プロジェクト: gvhung/nokta-crm
 public void Warn(string message, int hideAfter = 0, BasePage.MessageType mType = BasePage.MessageType.error, bool fromResource = true)
 {
     ThisPage.Warn(message, hideAfter, mType, fromResource);
 }