Beispiel #1
0
 public frmClientQuery(ClientQuery cq, bool ispreview)
 {
     this.Text = cq.Caption;
     cqFormQuery = cq;
     isPreview = ispreview;
     InitializeComponent();
 }
 public frmClientQueryEditor(ClientQuery cq, IDesignerHost host)
 {
     InitializeComponent();
     DesignerHost = host;
     ict = host.Container;
     cqold = cq;
     InitializeColumn(cqold);
 }
Beispiel #3
0
        private ClientQuery CopyQueryFileds(int columncount)
        {
            ClientQuery cq = new ClientQuery();
            cq.OwnerComp = (IDataModule)this.FindForm();
            if (this.QueryFields.Count > 0)
            {
                InfoBindingSource ibs = null;
                if (this.ViewBindingSource != null)
                {
                    ibs = this.ViewBindingSource;
                }
                else if (this.BindingSource != null)
                {
                    ibs = this.BindingSource;
                }
                if (ibs == null)
                {
                    throw new Exception("Can't find InfoBindingSource");
                }
                cq.BindingSource = ibs;
                cq.GapVertical = 8;
                cq.KeepCondition = this.QueryKeepCondition;
                cq.Margin = this.QueryMargin;
                cq.Font = this.QueryFont;
                int columnindex = 0;
                //int index = 0;
                foreach (QueryField qf in this.QueryFields)
                {
                    QueryColumns qc = new QueryColumns(qf.Name, true, qf.FieldName, qf.Caption, 120);
                    //if (PreQueryValue.Count > 0)
                    //{
                    //    qc.Text = PreQueryValue[index];
                    //    index++;
                    //}

                    if (columnindex == columncount)
                    {
                        qc.NewLine = true;
                        columnindex = 1;
                    }
                    else
                    {
                        qc.NewLine = false;
                        columnindex++;
                    }
                    qc.DefaultValue = qf.DefaultValue;
                    if (qf.Mode == "")
                    {
                        qc.ColumnType = "ClientQueryTextBoxColumn";
                    }
                    else
                    {
                        qc.ColumnType = "ClientQuery" + qf.Mode + "Column";
                    }
                    if (qf.Condition == "")
                    {
                        Type tp = (ibs.GetDataSource() as InfoDataSet).RealDataSet.Tables[ibs.DataMember].Columns[qf.FieldName].DataType;
                        if (tp == typeof(string))
                        {
                            qc.Operator = "%";
                        }

                        else
                        {
                            qc.Operator = "=";
                        }
                    }
                    else
                    {
                        qc.Operator = qf.Condition;
                    }
                    qc.Width = qf.Width;
                    qc.InfoRefVal = qf.RefVal;
                    qc.InfoRefButtonAutoPanel = qf.RefButtonAutoPanel;
                    qc.InfoRefButtonPanel = qf.RefButtonPanel;
                    qc.IsNvarChar = qf.IsNvarChar;
                    cq.Columns.Add(qc);
                }
            }
            else
            {
                throw new Exception("No QueryFields in InfoNavigator");
            }
            return cq;
        }
Beispiel #4
0
        protected virtual void DoViewQuery()
        {
            // (3 : 1 of 2) 在Query時: SetState(Querying);
            this.SetState("Querying");
            //string strQueryFields = _QueryFields;
            InfoBindingSource bSource = new InfoBindingSource();
            if (this.ViewBindingSource != null)
            {
                bSource = this.ViewBindingSource;
            }
            else if (this.BindingSource != null && this.ViewBindingSource == null)
            {
                bSource = this.BindingSource;
            }
            this.Focus();

            if (this.QueryMode == QueryModeType.Normal)
            {
                Form frmNavQuery = new frmNavQuery(this.QueryFields, bSource, this);
                frmNavQuery.ShowDialog();
            }
            else if (this.QueryMode == QueryModeType.ClientQuery)
            {
                if (this.QueryFields.Count > 0)
                {
                    if (cqform == null)
                    {
                        cqform = CopyQueryFileds(1);
                    }
                    string strwhere = string.Empty;
                    try
                    {
                        strwhere = cqform.Execute(false);
                        NavigatorQueryWhereEventArgs args = new NavigatorQueryWhereEventArgs(strwhere);
                        OnQueryWhere(args);
                        if (!args.Cancel)
                        {
                            strwhere = args.WhereString;
                            if (strwhere != null)
                            {
                                if (this.StatusStrip != null && this.StatusStrip.ShowProgress)
                                {
                                    this.StatusStrip.ShowProgressBar();
                                }
                                ((InfoDataSet)bSource.GetDataSource()).SetWhere(strwhere);
                                if (this.StatusStrip != null && this.StatusStrip.ShowProgress)
                                {
                                    this.StatusStrip.HideProgressBar();
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
                else
                {
                    Form frmNavQuery = new frmNavQuery(this.QueryFields, bSource, this);
                    frmNavQuery.ShowDialog();
                }
            }
            else if (this.QueryMode == QueryModeType.AnyQuery)
            {
                if (aq == null)
                    aq = CopyAnyQueryFileds();
                String strwhere = aq.Execute(this, false);
                NavigatorQueryWhereEventArgs args = new NavigatorQueryWhereEventArgs(strwhere);
                OnQueryWhere(args);
                args.Cancel = !this.QuerySQLSend;

                if (!args.Cancel)
                {
                    strwhere = args.WhereString;
                    if (strwhere != null)
                    {
                        if (this.StatusStrip != null && this.StatusStrip.ShowProgress)
                        {
                            this.StatusStrip.ShowProgressBar();
                        }
                        ((InfoDataSet)bSource.GetDataSource()).SetWhere(strwhere);
                        if (this.StatusStrip != null && this.StatusStrip.ShowProgress)
                        {
                            this.StatusStrip.HideProgressBar();
                        }
                    }
                }
            }

            // (3 : 2 of 2) Query後: SetState(Browsed).
            this.SetState("Browsed");
        }
Beispiel #5
0
 public void Show(Panel pn, int Columns)
 {
     if (Columns < 1)
     {
         throw new Exception("Parameter Columns of InfoNavigator.Show() should larger than 1");
     }
     if (cqpanel == null)
     {
         cqpanel = this.CopyQueryFileds(Columns);
     }
     cqpanel.Show(pn);
 }
        private void InitializeColumn(ClientQuery cq)
        {
            cmbbindingsource.Items.Clear();

            try
            {
                cmbbindingsource.Text = cq.BindingSource.Site.Name;
            }
            catch
            {

            }

            AddInfoRefVal();

            int columncount = cq.Columns.Count;
            if (columncount > 0)
            {
                dgvClientQuery.Rows.Add(columncount);
            }
            for (int i = 0; i < columncount; i++)
            {
                dgvClientQuery.Rows[i].Cells["Caption"].Value = ((QueryColumns)cq.Columns[i]).Caption;
                dgvClientQuery.Rows[i].Cells["Column"].Value = ((QueryColumns)cq.Columns[i]).Column;
                dgvClientQuery.Rows[i].Cells["ColumnType"].Value = ((QueryColumns)cq.Columns[i]).ColumnType;
                dgvClientQuery.Rows[i].Cells["Condition"].Value = ((QueryColumns)cq.Columns[i]).Condition;
                dgvClientQuery.Rows[i].Cells["DefaultValue"].Value = ((QueryColumns)cq.Columns[i]).DefaultValue;
                dgvClientQuery.Rows[i].Cells["Operator"].Value = ((QueryColumns)cq.Columns[i]).Operator;
                dgvClientQuery.Rows[i].Cells["NewLine"].Value = (object)((QueryColumns)cq.Columns[i]).NewLine.ToString();
                dgvClientQuery.Rows[i].Cells["TextAlign"].Value = ((QueryColumns)cq.Columns[i]).TextAlign;
                dgvClientQuery.Rows[i].Cells["TextWidth"].Value = ((QueryColumns)cq.Columns[i]).Width;
                if (((QueryColumns)cq.Columns[i]).InfoRefVal != null)
                {
                    try
                    {
                        dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value = ((QueryColumns)cq.Columns[i]).InfoRefVal.Site.Name;
                    }
                    catch
                    {
                        dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value = "(None)";
                    }
                }
                else
                {
                    dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value = "(None)";
                }
                dgvClientQuery.Rows[i].Cells["ExternalRefval"].Value = ((QueryColumns)cq.Columns[i]).ExternalRefVal;
                dgvClientQuery.Rows[i].Cells["ColumnVisible"].Value = ((QueryColumns)cq.Columns[i]).Visible;
            }

            foreach (IComponent cp in ict.Components)
            {
                if (cp is InfoBindingSource)
                {
                    cmbbindingsource.Items.Add((object)cp.Site.Name);
                }
            }
        }