public frmAnyQuery(AnyQuery aq, InfoNavigator infoN, bool executeSQL) { aInfoNavigator = infoN; innerAnyQuery = aq; isExecute = executeSQL; InitializeComponent(); Create(); }
private AnyQuery CopyAnyQueryFileds() { AnyQuery aAnyQuery = new AnyQuery(); Control baseForm = this.Parent; while (baseForm != null) { if (baseForm is InfoForm) { aAnyQuery.OwnerComp = baseForm as InfoForm; break; } else { baseForm = baseForm.Parent; } } aAnyQuery.ValueControlEnter += new EventHandler(aq_ValueControlEnter); InfoBindingSource ibs = null; if (this.ViewBindingSource != null && this.DetailBindingSource == null) { ibs = this.ViewBindingSource; } else if (this.BindingSource != null) { ibs = this.BindingSource; } if (ibs == null) { throw new Exception("Can't find InfoBindingSource"); } aAnyQuery.BindingSource = ibs; foreach (QueryField qf in this.QueryFields) { AnyQueryColumns qc = new AnyQueryColumns(qf.Name, qf.FieldName, qf.Caption, 120); qc.DefaultValue = qf.DefaultValue; if (qf.Mode == "") { qc.ColumnType = "AnyQueryTextBoxColumn"; } else { qc.ColumnType = "AnyQuery" + qf.Mode + "Column"; } if (qf.Condition == "" && (ibs.GetDataSource() as InfoDataSet).RealDataSet.Tables[ibs.DataMember].Columns[qf.FieldName] != null) { 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.InfoRefVal = qf.RefVal; qc.InfoRefButtonAutoPanel = qf.RefButtonAutoPanel; qc.InfoRefButtonPanel = qf.RefButtonPanel; qc.Enabled = qf.Enabled; qc.AutoSelect = qf.AutoSelect; qc.Items = qf.Items; qc.DateConver = qf.DateConver; qc.Width = qf.Width; qc.ColumnWidth = qf.ColumnWidth; qc.IsNvarChar = qf.IsNvarChar; aAnyQuery.Columns.Add(qc); } if (this.AnyQueryID == String.Empty) aAnyQuery.PackageForm = (this.Parent as InfoForm).PackageName + "." + (this.Parent as InfoForm).FormName; aAnyQuery.AnyQueryID = this.AnyQueryID; aAnyQuery.AutoDisableColumns = this.AutoDisableColumns; aAnyQuery.MaxColumnCount = this.MaxColumnCount; aAnyQuery.QueryColumnMode = this.QueryColumnMode; aAnyQuery.DetailBindingSource = this.DetailBindingSource; aAnyQuery.MasterDetailField = this.MasterDetailField; aAnyQuery.DetailKeyField = this.DetailKeyField; aAnyQuery.KeepCondition = this.QueryKeepCondition; aAnyQuery.DisplayAllOperator = this.DisplayAllOperator; return aAnyQuery; }
public frmAnyQuery(AnyQuery aq) { innerAnyQuery = aq; InitializeComponent(); Create(); }
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"); }