コード例 #1
0
        private void textButtonOk_Click(object sender, EventArgs e)
        {
            try
            {
                IsOk = false;
                var dt = dateTimePicker.Value;
                if (!VerificationRule.IsNullOrEmpty())
                {
                    if (VerificationRule.ToLower() == "CanNotBeFutureTime".ToLower())
                    {
                        if (dt.ToUtcTime().IsFutureTime())
                        {
                            MessageHelper.Popup(WinformRes.Input + ValidationRes.CanNotBeFutureTime);
                            return;
                        }
                    }
                    else if (VerificationRule.ToLower() == "CanNotBePastTime".ToLower())
                    {
                        if (dt.ToUtcTime().IsPastTime())
                        {
                            MessageHelper.Popup(WinformRes.Input + ValidationRes.CanNotBePastTime);
                            return;
                        }
                    }
                    else if (VerificationRule.ToLower() == "CanNotBeEarlierThan".ToLower())
                    {
                        var dt1 = DateTime.ParseExact(VerificationParams, dateTimePicker.CustomFormat, System.Globalization.CultureInfo.CurrentCulture);
                        if (dt < dt1)
                        {
                            MessageHelper.Popup(string.Format(WinformRes.Input + ValidationRes.CanNotBeEarlierThan, VerificationParams));
                            return;
                        }
                    }
                    else if (VerificationRule.ToLower() == "CanNotBeLaterThan".ToLower())
                    {
                        var dt1 = DateTime.ParseExact(VerificationParams, dateTimePicker.CustomFormat, System.Globalization.CultureInfo.CurrentCulture);
                        if (dt > dt1)
                        {
                            MessageHelper.Popup(string.Format(WinformRes.Input + ValidationRes.CanNotBeLaterThan, VerificationParams));
                            return;
                        }
                    }
                    else if (VerificationRule.ToLower() == "ShouldBeBetween".ToLower())
                    {
                        var verificationParamArry = VerificationParams.GetSubParamArray(true, false);
                        var dt1 = DateTime.ParseExact(verificationParamArry[0], dateTimePicker.CustomFormat, System.Globalization.CultureInfo.CurrentCulture);
                        var dt2 = DateTime.ParseExact(verificationParamArry[1], dateTimePicker.CustomFormat, System.Globalization.CultureInfo.CurrentCulture);
                        if (dt1 > dt2)
                        {
                            MessageHelper.Popup(WinformRes.VerificationParamsHaveProblem);
                            Close();
                        }

                        if (!(dt > dt1 & dt < dt2))
                        {
                            MessageHelper.Popup(string.Format(WinformRes.Input + ValidationRes.ShouldBeBetween, verificationParamArry[0], verificationParamArry[1]));
                            return;
                        }
                    }
                }

                InputText     = dateTimePicker.Text;
                InputDateTime = dateTimePicker.Value;
                IsOk          = true;
                Close();
            }
            catch (Exception ex)
            {
                MessageHelper.Popup(ex.Message);
            }
        }
 public void StatusReceived(VerificationParams request)
 {
     _diagnostics.Enqueue(request);
     _availableDiagnostics.Release();
 }