예제 #1
0
 private void TxtEndDate_Validating(object sender, CancelEventArgs e)
 {
     if (_Tag == "" || ActiveControl == TxtEndDate)
     {
         return;
     }
     if (TxtEndDate.Text != "  /  /")
     {
         try
         {
             if (ClsGlobal.CheckDateInsideCompanyPeriod(Convert.ToDateTime(TxtEndDate.Text)) == 1)
             {
                 ClsGlobal.DateRangeMsg();
                 TxtEndDate.Focus();
             }
         }
         catch
         {
             MessageBox.Show("Please enter valid date.", "Mr. Solutions", MessageBoxButtons.OK, MessageBoxIcon.Error);
             TxtEndDate.Focus();
         }
     }
     else
     {
         ClsGlobal.DateRangeMsg();
         TxtEndDate.Focus();
     }
 }
예제 #2
0
        private void TxtEndDate_Validating(object sender, CancelEventArgs e)
        {
            if (_Tag == "" || ActiveControl == TxtEndDate)
            {
                return;
            }

            if (TxtEndDate.Text.Trim() != "/  /")
            {
                int day; int month;
                day   = Convert.ToInt32(Convert.ToString(TxtEndDate.Text).Substring(0, 2));
                month = Convert.ToInt32(Convert.ToString(TxtEndDate.Text).Substring(3, 2));

                if (day > 32 || day < 1)
                {
                    MessageBox.Show("Please Enter Valid Day !", "Info.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    TxtEndDate.Focus();
                    return;
                }
                else if (month > 12 || month < 1)
                {
                    MessageBox.Show("Please Enter Valid Month !", "Info.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    TxtEndDate.Focus();
                    return;
                }
                else if (Convert.ToDateTime(TxtEndDate.Text) < Convert.ToDateTime(TxtStartDate.Text))
                {
                    MessageBox.Show("End Date Cannot be less then Start Date !", "Info.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    TxtEndDate.Focus();
                    return;
                }
            }
            else
            {
                MessageBox.Show("Company Register Date Cannot be Left Blank!");
                TxtEndDate.Focus();
                return;
            }
            //string fyStart = TxtStartDate.Text.Substring(6, 4);
            //string fyEnd = TxtEndDate.Text.Substring(6, 4);
            //TxtFiscalYear.Text = fyStart + "." + fyEnd;
        }