private void btnFilterDone_Click(object sender, EventArgs e) { if (filterstate != "add" && filterstate != "edit") { return; } if (cboFilter.SelectedIndex < 1) { MessageBox.Show("Please select some field in the dropdown list first", "Filed is not selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (rbnOptions.Checked) { WFReport.DataReport.OptionsRestriction rest = new DataReport.OptionsRestriction(); rest.table = currentDB.Tables[cboFilter.Items[cboFilter.SelectedIndex].ToString().Split(new char[] { ':' })[0]]; rest.column = rest.table.Columns[cboFilter.Items[cboFilter.SelectedIndex].ToString().Split(new char[] { ':' })[1].Split(new char[] { ' ' })[1]]; foreach (var i in lbxOptions.CheckedItems) rest.options.Add(i.ToString()); if (filterstate == "add") currentReport.restrictions.Add(rest); if (filterstate == "edit") currentReport.restrictions[lbxAdditionalFilters.SelectedIndex] = rest; UpdateUIwithReportData(); btnFilterCancel_Click(sender, e); } if (rbnFromTo.Checked) { WFReport.DataReport.FromToRestriction rest = new DataReport.FromToRestriction(); rest.table = currentDB.Tables[cboFilter.Items[cboFilter.SelectedIndex].ToString().Split(new char[] { ':' })[0]]; rest.column = rest.table.Columns[cboFilter.Items[cboFilter.SelectedIndex].ToString().Split(new char[] { ':' })[1].Split(new char[] { ' ' })[1]]; rest.fromValue = tbxFrom.Text; rest. toValue = tbxTo .Text; if (filterstate == "add") currentReport.restrictions.Add(rest); if (filterstate == "edit") currentReport.restrictions[lbxAdditionalFilters.SelectedIndex] = rest; UpdateUIwithReportData(); btnFilterCancel_Click(sender, e); } filterstate = ""; }
private WFReport.DataReport.OptionsRestriction ParseOptions(XmlElement node) { WFReport.DataReport.OptionsRestriction rest = new DataReport.OptionsRestriction(); foreach(XmlElement i in node) { if (i.Name == "table") rest.table = currentDB.Tables[i.InnerText]; if (i.Name == "column") rest.column = rest.table.Columns[i.InnerText]; if (i.Name == "option") rest.options.Add(i.InnerText); } return rest; }