Example #1
0
        private void DayCalendar_ModifySelectedDate_Lunar()
        {
            //Month
            ArrayList months = LunarDate.GetMonths(currentLunarYear, timeZone);

            if (currentLunarIsLeapMonth)
            {
                bool flag = false;
                foreach (string month in months)
                {
                    if (month.Length > 2 && month.Substring(0, 2) == currentLunarMonth.ToString("00"))
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    currentLunarIsLeapMonth = false;
                }
            }

            //Day
            int n = LunarDate.GetNumberOfDaysInMonth(currentLunarMonth, currentLunarIsLeapMonth, currentLunarYear, timeZone);

            if (currentLunarDay > n)
            {
                currentLunarDay = n;
            }
        }
Example #2
0
        private void DayCalendar_ModifySelectedDate_Lunar(int lunarMonth, bool lunarIsLeapMonth, int lunarYear)
        {
            //Check mininum value
            if (lunarYear == 0)
            {
                if (currentLunarDate.Month < 11)
                {
                    currentLunarDate = new LunarDate(19, 11, false, 0, timeZone);
                }
                else if (currentLunarDate.Month == 11)
                {
                    if (currentLunarDate.Day < 19)
                    {
                        currentLunarDate = new LunarDate(19, 11, false, 0, timeZone);
                    }
                    else
                    {
                        currentLunarDate = new LunarDate(currentLunarDate.Day, 11, false, 0, timeZone);
                    }
                }
            }

            //Month
            ArrayList months = LunarDate.GetMonths(lunarYear, timeZone);

            if (lunarIsLeapMonth)
            {
                bool flag = false;
                foreach (string month in months)
                {
                    if (month.Length > 2 && month.Substring(0, 2) == lunarMonth.ToString("00"))
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    currentLunarDate = new LunarDate(currentLunarDate.Day, lunarMonth, false, lunarYear, timeZone);
                }
            }

            //Day
            int n = LunarDate.GetNumberOfDaysInMonth(lunarMonth, lunarIsLeapMonth, lunarYear, timeZone);

            if (currentLunarDate.Day > n)
            {
                currentLunarDate = new LunarDate(n, lunarMonth, lunarIsLeapMonth, lunarYear, timeZone);
            }
            else
            {
                currentLunarDate = new LunarDate(currentLunarDate.Day, lunarMonth, lunarIsLeapMonth, lunarYear, timeZone);
            }
            currentSolarDate = currentLunarDate.ToSolarDate();
        }
Example #3
0
        private void DayCalendar_FillValue()
        {
            //Solar Date
            //Year
            txtDayCalendar_Solar_Year.Text = currentSolarYear.ToString("0000");
            //Month
            cmbDayCalendar_Solar_Month.Text = currentSolarMonth.ToString("00");
            //Day
            cmbDayCalendar_Solar_Day.Items.Clear();
            int n = SolarDate.GetNumberOfDaysInMonth(currentSolarMonth, currentSolarYear);

            for (int i = 1; i <= n; i++)
            {
                cmbDayCalendar_Solar_Day.Items.Add((i).ToString("00"));
            }
            cmbDayCalendar_Solar_Day.Text = currentSolarDay.ToString("00");

            //Lunar Date
            //Year
            txtDayCalendar_Lunar_Year.Text = currentLunarYear.ToString("0000");
            //Month
            cmbDayCalendar_Lunar_Month.Items.Clear();
            foreach (string month in LunarDate.GetMonths(currentLunarYear, timeZone))
            {
                cmbDayCalendar_Lunar_Month.Items.Add(month);
            }
            string str = currentLunarMonth.ToString("00");

            if (currentLunarIsLeapMonth)
            {
                str += " nhuận";
            }
            cmbDayCalendar_Lunar_Month.Text = str;
            //Day
            cmbDayCalendar_Lunar_Day.Items.Clear();
            int m = LunarDate.GetNumberOfDaysInMonth(currentLunarMonth, currentLunarIsLeapMonth, currentLunarYear, timeZone);

            for (int i = 1; i <= m; i++)
            {
                cmbDayCalendar_Lunar_Day.Items.Add(i.ToString("00"));
            }
            cmbDayCalendar_Lunar_Day.Text = currentLunarDay.ToString("00");
        }
Example #4
0
        private void DayCalendar_UpdateValue() //Modify the Selected Date and Update Value
        {
            //Solar Date
            //Year
            txtDayCalendar_Solar_Year.Text = currentSolarYear.ToString("0000");
            //Month
            cmbDayCalendar_Solar_Month.Text = currentSolarMonth.ToString("00");
            //Day
            int n = SolarDate.GetNumberOfDaysInMonth(currentSolarMonth, currentSolarYear);

            if (n != cmbDayCalendar_Solar_Day.Items.Count)
            {
                if (n > cmbDayCalendar_Solar_Day.Items.Count)
                {
                    for (int i = cmbDayCalendar_Solar_Day.Items.Count + 1; i <= n; i++)
                    {
                        cmbDayCalendar_Solar_Day.Items.Add(i.ToString("00"));
                    }
                }
                else
                {
                    if (int.Parse(cmbDayCalendar_Solar_Day.Text) > n)
                    {
                        cmbDayCalendar_Solar_Day.Text = currentSolarDay.ToString("00");
                    }
                    for (int i = cmbDayCalendar_Solar_Day.Items.Count - 1; i >= n; i--)
                    {
                        cmbDayCalendar_Solar_Day.Items.RemoveAt(i);
                    }
                }
            }
            cmbDayCalendar_Solar_Day.Text = currentSolarDay.ToString("00");

            //Lunar Date
            //Year
            txtDayCalendar_Lunar_Year.Text = currentLunarYear.ToString("0000");
            //Month
            ArrayList months = months = LunarDate.GetMonths(currentLunarYear, timeZone);

            for (int i = cmbDayCalendar_Lunar_Month.Items.Count - 1; i >= 0; i--)
            {
                string month = (string)cmbDayCalendar_Lunar_Month.Items[i];
                if (month.Length > 2)
                {
                    bool flag = false;
                    foreach (string month1 in months)
                    {
                        if (month1 == month)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        cmbDayCalendar_Lunar_Month.Items.RemoveAt(i);
                    }
                }
            }
            foreach (string month in months)
            {
                if (month.Length > 2)
                {
                    bool flag = false;
                    foreach (string month1 in cmbDayCalendar_Lunar_Month.Items)
                    {
                        if (month1 == month)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        cmbDayCalendar_Lunar_Month.Items.Add(month);
                    }
                }
            }
            string str = currentLunarMonth.ToString("00");

            if (currentLunarIsLeapMonth)
            {
                str += " nhuận";
            }
            cmbDayCalendar_Lunar_Month.Text = str;
            //Day
            int m = LunarDate.GetNumberOfDaysInMonth(currentLunarMonth, currentLunarIsLeapMonth, currentSolarYear, timeZone);

            if (m != cmbDayCalendar_Lunar_Day.Items.Count)
            {
                if (m > cmbDayCalendar_Lunar_Day.Items.Count)
                {
                    for (int i = cmbDayCalendar_Lunar_Day.Items.Count + 1; i <= m; i++)
                    {
                        cmbDayCalendar_Lunar_Day.Items.Add((i).ToString("00"));
                    }
                }
                else
                {
                    if (int.Parse(cmbDayCalendar_Lunar_Day.Text) > m)
                    {
                        cmbDayCalendar_Lunar_Day.Text = currentLunarDay.ToString("00");
                    }
                    for (int i = cmbDayCalendar_Lunar_Day.Items.Count - 1; i >= m; i--)
                    {
                        cmbDayCalendar_Lunar_Day.Items.RemoveAt(i);
                    }
                }
            }

            cmbDayCalendar_Lunar_Day.Text = currentLunarDay.ToString("00");
        }
Example #5
0
        private void DayCalendar_UpdateValue()
        {
            //Solar Date
            //Year
            txtDayCalendar_Solar_Year.Text = currentSolarDate.Year.ToString("0000");
            //Month
            cmbDayCalendar_Solar_Month.Text = currentSolarDate.Month.ToString("00");
            //Day
            cmbDayCalendar_Solar_Day.Items.Clear();
            int n = SolarDate.GetNumberOfDaysInMonth(currentSolarDate.Month, currentSolarDate.Year);

            for (int i = 1; i <= n; i++)
            {
                cmbDayCalendar_Solar_Day.Items.Add(i.ToString("00"));
            }
            cmbDayCalendar_Solar_Day.Text = currentSolarDate.Day.ToString("00");

            //Lunar Date
            //Year
            txtDayCalendar_Lunar_Year.Text = currentLunarDate.Year.ToString("0000");
            //Month
            if (currentLunarDate.Year > 0)
            {
                cmbDayCalendar_Lunar_Month.Items.Clear();
                ArrayList months = months = LunarDate.GetMonths(currentLunarDate.Year, timeZone);
                foreach (string month in months)
                {
                    cmbDayCalendar_Lunar_Month.Items.Add(month);
                }
                string str = currentLunarDate.Month.ToString("00");
                if (currentLunarDate.IsLeapMonth)
                {
                    str += " nhuận";
                }
                cmbDayCalendar_Lunar_Month.Text = str;
            }
            else if (currentLunarDate.Year == 0)
            {
                cmbDayCalendar_Lunar_Month.Items.Clear();
                cmbDayCalendar_Lunar_Month.Items.Add("11");
                cmbDayCalendar_Lunar_Month.Items.Add("12");
                cmbDayCalendar_Lunar_Month.Text = currentLunarDate.Month.ToString("00");
            }

            //Day
            if (currentLunarDate.Year > 0 || (currentLunarDate.Year == 0 && currentLunarDate.Month > 11))
            {
                cmbDayCalendar_Lunar_Day.Items.Clear();
                int m = LunarDate.GetNumberOfDaysInMonth(currentLunarDate.Month, currentLunarDate.IsLeapMonth, currentLunarDate.Year, timeZone);
                for (int i = 1; i <= m; i++)
                {
                    cmbDayCalendar_Lunar_Day.Items.Add((i).ToString("00"));
                }
                cmbDayCalendar_Lunar_Day.Text = currentLunarDate.Day.ToString("00");
            }
            else if (currentLunarDate.Year == 0 && currentLunarDate.Month == 11)
            {
                cmbDayCalendar_Lunar_Day.Items.Clear();
                for (int i = 19; i <= 30; i++)
                {
                    cmbDayCalendar_Lunar_Day.Items.Add(i.ToString());
                }
                cmbDayCalendar_Lunar_Day.Text = currentLunarDate.Day.ToString("00");
            }
        }