public void OnPreview(object sender, EventArgs e) { try { previewer = new frmClientQuery((ClientQuery)this.Component,true); } catch { MessageBox.Show("Preview encounter an error\ncheck ClientQuery's property"); return; } previewer.btnCancel.Enabled = false; previewer.btnOk.Enabled = false; previewer.ShowDialog(); previewer.Dispose(); }
public string Execute(bool ExecuteSQL) { string strwhere = null; if (fcq == null || !KeepCondition) { fcq = new frmClientQuery(this, false); } if (fcq.ShowDialog() == DialogResult.OK) { if (ExecuteSQL) { Execute(fcq.splitContainer1.Panel1); } else { strwhere = GetWhere(fcq.splitContainer1.Panel1); } } return strwhere; }
private void btnPreview_Click(object sender, EventArgs e) { int columncount = dgvClientQuery.Rows.Count; QueryColumns[] qc = new QueryColumns[columncount]; InfoRefVal[] refval = new InfoRefVal[columncount]; for (int i = 0; i < columncount - 1; i++) { for (int j = 0; j < 8; j++) { if (dgvClientQuery.Rows[i].Cells[j].Value == null) { if (dgvClientQuery.Columns[j].Name != "DefaultValue") { MessageBox.Show(string.Format("Record {0}: Can't be null in {1}", i + 1, dgvClientQuery.Columns[j].HeaderText)); return; } } } if (dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value != null && dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString() != "(None)") { if ((dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString() != "ClientQueryComboBoxColumn") && (dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString() != "ClientQueryRefValColumn")) { MessageBox.Show(string.Format("Record {0} :\nInfoRefval can be set only when\ncolumntype is combobox & refval.", i + 1)); return; } else { try { refval[i] = (InfoRefVal)ict.Components[dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString()]; } catch { MessageBox.Show(string.Format("InfoRefVal {0} doesn't exist", dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString())); return; } } } } try { cqpreivewer.BindingSource = (InfoBindingSource)ict.Components[cmbbindingsource.Text]; cqpreivewer.Columns.Clear(); } catch { } for (int i = 0; i < columncount - 1; i++) { qc[i] = new QueryColumns(); qc[i].setcolumn(dgvClientQuery.Rows[i].Cells["Column"].Value.ToString()); qc[i].Caption = dgvClientQuery.Rows[i].Cells["Caption"].Value.ToString(); if (dgvClientQuery.Rows[i].Cells["DefaultValue"].Value != null) { qc[i].DefaultValue = dgvClientQuery.Rows[i].Cells["DefaultValue"].Value.ToString(); } else { qc[i].DefaultValue = ""; } qc[i].ColumnType = dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString(); qc[i].Condition = dgvClientQuery.Rows[i].Cells["Condition"].Value.ToString(); qc[i].Operator = dgvClientQuery.Rows[i].Cells["Operator"].Value.ToString(); qc[i].NewLine = Boolean.Parse(dgvClientQuery.Rows[i].Cells["NewLine"].Value.ToString()); qc[i].TextAlign = dgvClientQuery.Rows[i].Cells["TextAlign"].Value.ToString(); try { qc[i].Width = int.Parse(dgvClientQuery.Rows[i].Cells["TextWidth"].Value.ToString()); if (qc[i].Width <= 0) { MessageBox.Show(string.Format("Record {0}: Width should be an positive integer", i + 1)); return; } } catch { MessageBox.Show(string.Format("Record {0}: Width should be an positive integer", i + 1)); return; } if (dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value != null && dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString() != "(None)") { qc[i].InfoRefVal = refval[i]; } cqpreivewer.Columns.Add(qc[i]); } cqpreivewer.Caption = cqold.Caption; cqpreivewer.Margin = cqold.Margin; cqpreivewer.Font = cqold.Font; cqpreivewer.ForeColor = cqold.ForeColor; cqpreivewer.TextColor = cqold.TextColor; fcq = new frmClientQuery(cqpreivewer,true); fcq.btnOk.Enabled = false; fcq.btnCancel.Enabled = false; fcq.ShowDialog(); }