Example #1
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(FilterName))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err1"));
     }
     else if (string.IsNullOrEmpty(XPathExpression))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err2"));
     }
     else if (!string.IsNullOrEmpty(XPathExpression) && XPathExpression.Length > 5120)
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err19"));
     }
     else if (!CustomFilter.ValidateXPath(XPathExpression))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err3"));
     }
     else if (parent.IsDuplicateFilterName(FilterName, (currentFilter == null) ? string.Empty : currentFilter.FilterName))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err4"));
     }
     else
     {
         try
         {
             currentFilter = new CustomFilter(FilterName, FilterDescription, XPathExpression, Namespaces, Parameters);
         }
         catch (AppSettingsException)
         {
             errorReport.ReportErrorToUser(SR.GetString("CF_Err5"));
             return;
         }
         base.DialogResult = DialogResult.OK;
         Close();
     }
 }
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (!UpdateXPathExpression())
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_InvalidLogic"));
     }
     if (string.IsNullOrEmpty(filterName.Text))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err1"));
     }
     else if (string.IsNullOrEmpty(xpathExpression.Text))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err2"));
     }
     else if (!string.IsNullOrEmpty(xpathExpression.Text) && xpathExpression.Text.Length > 5120)
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err19"));
     }
     else if (!CustomFilter.ValidateXPath(xpathExpression.Text.Trim()))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err3"));
     }
     else if (parent.IsDuplicateFilterName(filterName.Text, string.Empty))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err4"));
     }
     else
     {
         try
         {
             Dictionary <string, string> dictionary = new Dictionary <string, string>();
             foreach (string key in nsMap.Keys)
             {
                 dictionary.Add(nsMap[key], key);
             }
             List <CustomFilter.CustomFilterParameter> list = new List <CustomFilter.CustomFilterParameter>();
             int num = -1;
             foreach (DataGridViewRow item in (IEnumerable)logicGrid.Rows)
             {
                 if (item.Cells[3].Value.ToString() != SR.GetString("CF_None"))
                 {
                     int num2 = int.Parse(item.Cells[3].Value.ToString().Substring(1, 1), CultureInfo.InvariantCulture);
                     if (num2 > num)
                     {
                         num = num2;
                     }
                 }
             }
             if (num != -1)
             {
                 for (int i = 0; i <= num; i++)
                 {
                     CustomFilter.CustomFilterParameter customFilterParameter = new CustomFilter.CustomFilterParameter();
                     customFilterParameter.type = CustomFilterParameterValueType.AnyText;
                     list.Add(customFilterParameter);
                 }
             }
             currentFilter = new CustomFilter(filterName.Text, filterDescription.Text, xpathExpression.Text.Trim(), dictionary, list);
         }
         catch (AppSettingsException)
         {
             errorReport.ReportErrorToUser(SR.GetString("CF_Err5"));
             return;
         }
         base.DialogResult = DialogResult.OK;
         Close();
     }
 }