private void btOK_Click(object sender, System.EventArgs e) { string s; StringCollection scGroup = new StringCollection(); FieldList flds = new FieldList(); qry.GroupBy = ""; FieldList fl = qry.Fields; for (int i = 0; i < fl.Count; i++) { s = listView1.Items[i].SubItems[1].Text.Trim(); if (!string.IsNullOrEmpty(s)) { if (string.Compare(s, "Group by", StringComparison.OrdinalIgnoreCase) == 0) { scGroup.Add(fl[i].GetFieldTextAsValue(qry.NameDelimiterBegin, qry.NameDelimiterEnd)); flds.Add(fl[i]); } else { EPField f = (EPField)fl[i].Clone(); f.FieldText = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}({1}) AS {2}{3}{4}", s, f.GetFieldTextAsValue(qry.NameDelimiterBegin, qry.NameDelimiterEnd), qry.NameDelimiterBegin, f.Name, qry.NameDelimiterEnd); flds.Add(f); } } } if (scGroup.Count == 0) { MessageBox.Show(this, Resource1.Err_group_field, this.Text, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Stop); } else { StringBuilder sg = new StringBuilder(scGroup[0]); for (int i = 1; i < scGroup.Count; i++) { sg.Append(","); sg.Append(scGroup[i]); } qry.GroupBy = sg.ToString(); qry.Fields = flds; this.DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } }
public override string ToString() { return(field.GetFieldTextAsValue(Sep1, Sep2)); }