Ejemplo n.º 1
0
        // use in ICS030
        // select backward 25 month
        /// <summary>
        /// Generate html of combobox for month/year list
        /// </summary>
        /// <param name="helper">html helper</param>
        /// <param name="id">control id</param>
        /// <param name="attribute">html attribute</param>
        /// <param name="include_idx0">is display first combobox item</param>
        /// <param name="firstElement">first combobox item</param>
        /// <returns></returns>
        public static MvcHtmlString MonthYearComboBox(this HtmlHelper helper, string id, object attribute = null, bool include_idx0 = true, string firstElement = null)
        {
            List <SelectListItem> MonthYearList = new List <SelectListItem>();

            try
            {
                IIncomeHandler iincomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

                //int j = iincomeHandler.GetWorkingDayNoOfMonth(DateTime.Now);
                int j = DateTime.Now.Day;
                if (iincomeHandler.GetWorkingDayNoOfMonth(DateTime.Now) <= 6)
                {
                    j = 1;
                }
                else
                {
                    j = 0;
                }

                for (int i = 0; i < 25; i++)
                {
                    if (i == j)
                    {
                        MonthYearList.Add(new SelectListItem()
                        {
                            Selected = true,
                            Text     = ToMonthName(DateTime.Now.AddMonths((-1) * i)) + "-" + DateTime.Now.AddMonths((-1) * i).Year.ToString(),
                            Value    = DateTime.Now.AddMonths((-1) * i).ToShortDateString()
                        });
                    }
                    else
                    {
                        MonthYearList.Add(new SelectListItem()
                        {
                            Selected = false,
                            Text     = ToMonthName(DateTime.Now.AddMonths((-1) * i)) + "-" + DateTime.Now.AddMonths((-1) * i).Year.ToString(),
                            Value    = DateTime.Now.AddMonths((-1) * i).ToShortDateString()
                        });
                    }
                }
                ;
            }
            catch
            { }
            return(CommonUtil.CommonComboBox <SelectListItem>(id, MonthYearList, "Text", "Value", attribute, false));
        }