示例#1
0
        // GET: Filter
        public ActionResult Index()
        {
            FilterView            clsFiltVw = null;
            DataSetInfo           clsDSInf  = null;
            TPFilter              clsFilt   = null;
            List <SelectListItem> selDays;
            SelectedIDsAndItems   vmSelDays = null;
            APIHelper             apiHlp;
            SavedDataHelper       sdHlp;
            string strErr = "";

            try
            {
                clsFiltVw = new FilterView();
                selDays   = new List <SelectListItem>();
                vmSelDays = new SelectedIDsAndItems();
                apiHlp    = new APIHelper();
                sdHlp     = new SavedDataHelper();

                if (apiHlp.GetDataSet(User.Identity.Name, 440, ref clsDSInf, ref strErr))
                {
                    if (clsDSInf.DayName != null && clsDSInf.DayNameAbbrev != null)
                    {
                        for (int i = 0; i < 7; i++)
                        {
                            selDays.Add(new SelectListItem {
                                Text = clsDSInf.DayName[i], Value = clsDSInf.DayName[i]
                            });
                        }
                    }

                    if (sdHlp.LoadItem(User.Identity.Name, null, null, "TPFilter", ref clsFilt, ref strErr))
                    {
                        clsFiltVw.Filter = clsFilt;
                    }
                    else
                    {
                        clsFilt = new TPFilter(clsDSInf.DayNameAbbrev);
                    }

                    vmSelDays.Items           = selDays;
                    vmSelDays.SelectedItemIds = clsFilt.DaysOfWk;
                    clsFiltVw.DaysOfWeek      = vmSelDays;
                    clsFiltVw.Filter          = clsFilt;
                }
                else
                {
                    ModelState.AddModelError("", "Could not retrieve days of the week");
                }

                vmSelDays.Items      = selDays;
                clsFiltVw.DaysOfWeek = vmSelDays;
            }
            catch (Exception exc)
            {
                ModelState.AddModelError("", "Unexpected error:" + exc.Message);
            }

            return(View(clsFiltVw));
        }
示例#2
0
        // GET: Date
        /// <summary>
        /// Dates view/selection
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            List <AvailableDate>  lstDates = null;
            List <SelectListItem> selDates;
            SelectedIDsAndItems   vmSelDates = null;
            APIHelper             apiHlp;
            SavedDataHelper       sdHlp;

            string[] arrStr = null;
            string   strErr = "";

            try
            {
                selDates   = new List <SelectListItem>();
                vmSelDates = new SelectedIDsAndItems();
                apiHlp     = new APIHelper();
                sdHlp      = new SavedDataHelper();

                if (apiHlp.GetDates(User.Identity.Name, 440, ref lstDates, ref strErr) &&
                    lstDates != null &&
                    lstDates.Count > 0)
                {
                    foreach (AvailableDate ad in lstDates)
                    {
                        for (DateTime d = ad.StartDate; d <= ad.EndDate; d = d.AddDays(1))
                        {
                            selDates.Add(new SelectListItem {
                                Text = d.ToShortDateString(), Value = d.ToBinary().ToString()
                            });
                        }
                    }

                    if (sdHlp.LoadItem(User.Identity.Name, null, null, "Date", ref arrStr, ref strErr))
                    {
                        vmSelDates.SelectedItemIds = arrStr;
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Could not retrieve dates");
                }

                vmSelDates.Items = selDates;
            }
            catch (Exception exc)
            {
                ModelState.AddModelError("", "Unexpected error:" + exc.Message);
            }

            return(View(vmSelDates));
        }
示例#3
0
        // GET: Region
        /// <summary>
        /// Region view/selection
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            List <Region>         lstRegions = null;
            List <SelectListItem> selRegs;
            SelectedIDsAndItems   vmSelRegs = null;
            APIHelper             apiHlp;
            SavedDataHelper       sdHlp;

            string[] arrStr = null;
            string   strErr = "";

            try
            {
                selRegs   = new List <SelectListItem>();
                vmSelRegs = new SelectedIDsAndItems();
                apiHlp    = new APIHelper();
                sdHlp     = new SavedDataHelper();

                if (apiHlp.GetRegions(User.Identity.Name, 440, ref lstRegions, ref strErr) &&
                    lstRegions != null &&
                    lstRegions.Count > 0)
                {
                    foreach (Region r in lstRegions)
                    {
                        selRegs.Add(new SelectListItem {
                            Text = r.Name, Value = r.Id.ToString()
                        });
                    }

                    if (sdHlp.LoadItem(User.Identity.Name, null, null, "Region", ref arrStr, ref strErr))
                    {
                        vmSelRegs.SelectedItemIds = arrStr;
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Could not retrieve regions");
                }

                vmSelRegs.Items = selRegs;
            }
            catch (Exception exc)
            {
                ModelState.AddModelError("", "Unexpected error:" + exc.Message);
            }

            return(View(vmSelRegs));
        }