コード例 #1
0
        private bool ValidateControls()
        {
            try
            {
                var period = int.Parse(ddlPaymentPeriod.SelectedValue);

                if (period < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Please Select a Period.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (period == 3)
                {
                    if (string.IsNullOrEmpty(txtPaymentStart.Text.Trim()) && string.IsNullOrEmpty(txtPaymentEndDate.Text.Trim()))
                    {
                        ConfirmAlertBox1.ShowMessage("Please enter a date range.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }

                    if (string.IsNullOrEmpty(txtPaymentStart.Text.Trim()) || string.IsNullOrEmpty(txtPaymentStart.Text.Trim()))
                    {
                        ConfirmAlertBox1.ShowMessage("Please enter a date range.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }

                    if (!string.IsNullOrEmpty(txtPaymentStart.Text.Trim()))
                    {
                        if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtPaymentStart.Text.Trim())))
                        {
                            ConfirmAlertBox1.ShowMessage("Please enter a valid date.", ConfirmAlertBox.PopupMessageType.Error);
                            return(false);
                        }
                    }


                    if (!string.IsNullOrEmpty(DateMap.ReverseToServerDate(txtPaymentEndDate.Text.Trim())))
                    {
                        if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtPaymentEndDate.Text.Trim())))
                        {
                            ConfirmAlertBox1.ShowMessage("Please enter a valid date.", ConfirmAlertBox.PopupMessageType.Error);
                            return(false);
                        }
                    }

                    if (!DateMap.IsEarlyDate(DateMap.ReverseToServerDate(txtPaymentStart.Text.Trim()), DateMap.ReverseToServerDate(txtPaymentEndDate.Text.Trim())))
                    {
                        ConfirmAlertBox1.ShowMessage("The 'From' date should not be LATER than the 'To' date.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                }

                return(true);
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
コード例 #2
0
        private bool ValidateControls()
        {
            try
            {
                if (string.IsNullOrEmpty(txtStart.Text.Trim()) && string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    ErrorDisplay1.ShowError("Please enter at least a date.");
                    return(false);
                }

                if (!string.IsNullOrEmpty(txtStart.Text.Trim()))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtStart.Text.Trim())))
                    {
                        ErrorDisplay1.ShowError("Please enter a valid date.");
                        return(false);
                    }
                }


                if (!string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtEndDate.Text.Trim())))
                    {
                        ErrorDisplay1.ShowError("Please enter a valid date.");
                        return(false);
                    }
                }

                if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    if (!DateMap.IsEarlyDate(DateMap.ReverseToServerDate(txtStart.Text.Trim()), DateMap.ReverseToServerDate(txtEndDate.Text.Trim())))
                    {
                        ErrorDisplay1.ShowError("The 'From' date should not be LATER than the 'To' date.");
                        return(false);
                    }
                }
                return(true);
            }
            catch
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                return(false);
            }
        }