コード例 #1
0
ファイル: DatePicker.cs プロジェクト: sohbati/Automation
        public void showDialog(string strDate)
        {
            int y = 0;
            int m = 0;
            int d = 0;

            if (CheckDate.checkDate(strDate, ref y, ref m, ref d))
            {
                init(y, m, d);
            }
            else
            {
                init(0, 0, 0);
            }
            this.ShowDialog();
        }
コード例 #2
0
ファイル: DatePicker.cs プロジェクト: sohbati/Automation
        public void init(int y, int m, int d)
        {
            _selected          = false;
            _persianCalendar   = new PersianCalendar();
            _gregorianCalendar = new GregorianCalendar();
            cmbYear.Items.Clear();

            for (int i = YEAR_BOUNDARY[0]; i <= YEAR_BOUNDARY[1]; i++)
            {
                cmbYear.Items.Add(i);
            }
            cmbMonth.Items.Clear();
            for (int i = 1; i <= 12; i++)
            {
                cmbMonth.Items.Add(i);
            }

            //set persian day to today
            if (CheckDate.checkDate(y + "/" + m + "/" + d))
            {
                _selectedYear  = y;
                _selectedMonth = m;
                _selectedDay   = d;
            }
            else
            {
                DateTime greDateTime = DateTime.Now;

                string   date    = DateXFormer.gregorianToPersianString(greDateTime);
                string[] dateArr = date.Split('/');
                _selectedYear  = int.Parse(dateArr[0].ToString());
                _selectedMonth = int.Parse(dateArr[1].ToString());
                _selectedDay   = int.Parse(dateArr[2].ToString());
            }

            cmbMonth.SelectedItem = _selectedMonth;
            cmbYear.SelectedItem  = _selectedYear;
            paintPanel();
            lblSelectedDate.Text = generalizeDate(_selectedYear + "/" + _selectedMonth + "/" + _selectedDay);
            // today date
            string todayStr = DateXFormer.gregorianToPersianString(DateTime.Now);

            lblToday.Text = todayStr;
        }
コード例 #3
0
ファイル: DateXFormer.cs プロジェクト: sohbati/Automation
        public static DateTime persianToGreGorian(string strDate)
        {
            int y = 0;
            int m = 0;
            int d = 0;

            if (!CheckDate.checkDate(strDate, ref y, ref m, ref d))
            {
                return(DateTime.MinValue);
            }

            DateTime persianDateDime  = new DateTime(y, m, d, new PersianCalendar());
            DateTime greorianDateTime =
                new DateTime(gcal.GetYear(persianDateDime),
                             gcal.GetMonth(persianDateDime),
                             gcal.GetDayOfMonth(persianDateDime), new GregorianCalendar());

            return(greorianDateTime);
        }