public frmRefButtonQuery(string[] colName, String[] colCaption, InfoBindingSource bs, string OrignFilter, InfoRefVal refval) { InitializeComponent(); int i = colName.Length; colNum = i; this.strColName = colName; this.strColCaption = colCaption; this.infoBs = bs; this.strOrignFilter = OrignFilter; this.infoRefVal = refval; InitializeQueryConditionItem(); }
private void CreateQueryField(TBlockFieldItem aFieldItem, String Range, InfoRefVal aRefVal, InfoBindingSource ibs) { if (aFieldItem.QueryMode == null) return; InfoNavigator navigator1 = FRootForm.Controls["infoNavigator1"] as InfoNavigator; if (navigator1 != null) { if (aFieldItem.QueryMode.ToUpper() == "NORMAL" || aFieldItem.QueryMode.ToUpper() == "RANGE") { QueryField qField = new QueryField(); qField.FieldName = aFieldItem.DataField; qField.Caption = aFieldItem.Description; if (qField.Caption == "") qField.Caption = aFieldItem.DataField; if (aFieldItem.QueryMode.ToUpper() == "NORMAL") { if (aFieldItem.DataType == typeof(DateTime)) qField.Condition = "="; if (aFieldItem.DataType == typeof(int) || aFieldItem.DataType == typeof(float) || aFieldItem.DataType == typeof(double) || aFieldItem.DataType == typeof(Int16)) qField.Condition = "="; if (aFieldItem.DataType == typeof(String)) qField.Condition = "%"; } if (aFieldItem.QueryMode.ToUpper() == "RANGE") { qField.Condition = "And"; if (Range == "") { qField.Condition = "<="; CreateQueryField(aFieldItem, ">=", aRefVal, null); } else { qField.Condition = Range; } } switch (aFieldItem.ControlType.ToUpper()) { case "TEXTBOX": qField.Mode = "TextBox"; break; case "COMBOBOX": qField.Mode = "ComboBox"; qField.RefVal = aRefVal; break; case "REFVALBOX": qField.Mode = "RefVal"; qField.RefVal = aRefVal; break; case "DATETIMEBOX": qField.Mode = "Calendar"; break; } navigator1.QueryFields.Add(qField); } } ClientQuery aClientQuery = FRootForm.Container.Components["clientQuery1"] as ClientQuery; if (aClientQuery != null) { if (ibs != null && aClientQuery != null) aClientQuery.BindingSource = ibs; if (aFieldItem.QueryMode.ToUpper() == "NORMAL" || aFieldItem.QueryMode.ToUpper() == "RANGE") { QueryColumns qColumn = new QueryColumns(); qColumn.Column = aFieldItem.DataField; qColumn.Caption = aFieldItem.Description; if (qColumn.Caption == "") qColumn.Caption = aFieldItem.DataField; if (aFieldItem.QueryMode.ToUpper() == "NORMAL") { if (aFieldItem.DataType == typeof(DateTime)) qColumn.Operator = "="; if (aFieldItem.DataType == typeof(int) || aFieldItem.DataType == typeof(float) || aFieldItem.DataType == typeof(double) || aFieldItem.DataType == typeof(Int16)) qColumn.Operator = "="; if (aFieldItem.DataType == typeof(String)) qColumn.Operator = "%"; } if (aFieldItem.QueryMode.ToUpper() == "RANGE") { qColumn.Condition = "And"; if (Range == "") { qColumn.Operator = "<="; CreateQueryField(aFieldItem, ">=", aRefVal, null); } else { qColumn.Operator = Range; //qColumn.Condition = Range; } } switch (aFieldItem.ControlType.ToUpper()) { case "TEXTBOX": qColumn.ColumnType = "ClientQueryTextBoxColumn"; break; case "COMBOBOX": qColumn.ColumnType = "ClientQueryComboBoxColumn"; qColumn.InfoRefVal = aRefVal; break; case "REFVALBOX": qColumn.ColumnType = "ClientQueryRefValColumn"; qColumn.InfoRefVal = aRefVal; break; case "DATETIMEBOX": qColumn.ColumnType = "ClientQueryCalendarColumn"; break; case "CHECKBOX": qColumn.ColumnType = "ClientQueryCheckBoxColumn"; break; } aClientQuery.Columns.Add(qColumn); } } }
private String CreateColumns(InfoDataSet ids, XmlNode xn, List<Panel> panels) { int columnWidth = Convert.ToInt16(xn.Attributes["ColumnWidth"].Value); int ColumnsCount = Count; if (120 + ColumnsCount * 30 > this.Height) this.Height += 30; int standard = 40; CheckBox cbActive = new CheckBox(); cbActive.Name = ColumnsCount + "AnyQueryActiveCheckBox"; if (xn.Attributes["IsActive"].Value == "1") cbActive.Checked = true; cbActive.Width = 15; cbActive.Location = new Point(standard, 13 + ColumnsCount * 30); cbActive.CheckedChanged += new EventHandler(cbActive_CheckedChanged); this.panel2.Controls.Add(cbActive); //standard += 30; //Label labelCondition = new Label(); //labelCondition.Name = ColumnsCount + "AnyQueryConditionLabel"; //labelCondition.Width = 50; //labelCondition.Text = xn.Attributes["Condition"].Value; //labelCondition.Location = new Point(standard, 17 + ColumnsCount * 30); //labelCondition.Click += new EventHandler(labelCondition_Click); //this.panel2.Controls.Add(labelCondition); standard += 30; ComboBox cbColumn = new ComboBox(); cbColumn.Name = ColumnsCount + "AnyQueryColumnComboBox"; this.panel2.Controls.Add(cbColumn); DataView dvColumn = CreateDataViewColumn(ids); cbColumn.DataSource = dvColumn; cbColumn.DisplayMember = "CAPTION"; cbColumn.ValueMember = "FIELDNAME"; cbColumn.DropDownStyle = ComboBoxStyle.DropDownList; cbColumn.Width = columnWidth; cbColumn.Location = new Point(standard, 15 + ColumnsCount * 30); cbColumn.Text = xn.Attributes["Caption"].Value; cbColumn.SelectedIndexChanged += new EventHandler(cbColumn_SelectedIndexChanged); standard += cbColumn.Width + 5; ComboBox cbOperator = new ComboBox(); Type cbType = GetDataType(CaptionToColumn(xn.Attributes["Caption"].Value, innerAnyQuery.BindingSource)); List<String> op = new List<string>(); op.AddRange(new String[] { "=", "!=", ">", "<", ">=", "<=", "%**", "**%", "%%", "!%%", "<->", "!<->", "IN", "NOT IN" }); if (!innerAnyQuery.DisplayAllOperator) { if (cbType == typeof(Char) || cbType == typeof(String)) { op.Clear(); //op.AddRange(new String[] { "=", "!=", "%**", "**%", "%%", "!%%", "IN", "NOT IN" }); op.AddRange(new String[] { "=", "!=", "%**", "**%", "%%", "!%%" }); } else if (cbType != null && (cbType == typeof(int) || cbType == typeof(float) || cbType == typeof(double) || cbType == typeof(DateTime) || cbType.FullName == "System.Decimal" || cbType == typeof(Int16) || cbType == typeof(Int64))) { op.Clear(); //op.AddRange(new String[] { "=", "!=", "<", ">", "<=", ">=", "<->", "!<->", "IN", "NOT IN" }); op.AddRange(new String[] { "=", "!=", "<", ">", "<=", ">=", "<->", "!<->" }); } } cbOperator.Items.AddRange(op.ToArray()); cbOperator.DropDownStyle = ComboBoxStyle.DropDownList; cbOperator.Name = ColumnsCount + "AnyQueryOperatorComboBox"; cbOperator.Width = 65; cbOperator.Location = new Point(standard, 15 + ColumnsCount * 30); SetOperatorHelp(cbOperator); cbOperator.SelectedIndexChanged += new EventHandler(cbOperator_SelectedIndexChanged); this.panel2.Controls.Add(cbOperator); standard += cbOperator.Width + 5; switch (xn.Attributes["ValueType"].Value) { case "AnyQueryTextBoxColumn": TextBox tbValue = new TextBox(); tbValue.Name = ColumnsCount + "AnyQueryValue1TextBox" + xn.Attributes["ValueEnabled"].Value; tbValue.Text = xn.Attributes["Value1"].Value; tbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); tbValue.Location = new Point(standard, 15 + ColumnsCount * 30); tbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); tbValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(tbValue); break; case "AnyQueryComboBoxColumn": cbOperator.Items.Clear(); op.Clear(); op.AddRange(new String[] { "=", "!=" }); cbOperator.Items.AddRange(op.ToArray()); InfoComboBox icbValue = new InfoComboBox(); if (xn.Attributes["SelectAlias"].Value == String.Empty || xn.Attributes["SelectCommand"].Value == String.Empty) { if (xn.Attributes["RemoteName"].Value == String.Empty) { String[] temp = xn.Attributes["Items"].Value.Split(';'); foreach (String str in temp) { if (str != String.Empty) icbValue.Items.Add(str); } } else { InfoDataSet idsComboBox = new InfoDataSet(); idsComboBox.RemoteName = xn.Attributes["RemoteName"].Value; idsComboBox.Active = true; InfoBindingSource ibsComboBox = new InfoBindingSource(); ibsComboBox.DataSource = idsComboBox; ibsComboBox.DataMember = idsComboBox.RealDataSet.Tables[0].TableName; icbValue.DataSource = ibsComboBox; icbValue.DisplayMember = xn.Attributes["DisplayMember"].Value; icbValue.ValueMember = xn.Attributes["ValueMember"].Value; icbValue.EndInit(); } } else { icbValue.SelectAlias = xn.Attributes["SelectAlias"].Value; icbValue.SelectCommand = xn.Attributes["SelectCommand"].Value; icbValue.DisplayMember = xn.Attributes["DisplayMember"].Value; icbValue.ValueMember = xn.Attributes["ValueMember"].Value; icbValue.EndInit(); } icbValue.DisplayMemberOnly = Convert.ToBoolean(xn.Attributes["DisplayMemberOnly"].Value); icbValue.Name = ColumnsCount + "AnyQueryValue1InfoComboBox" + xn.Attributes["ValueEnabled"].Value; icbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); icbValue.Location = new Point(standard, 15 + ColumnsCount * 30); icbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); icbValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(icbValue); icbValue.SelectedValue = xn.Attributes["Value1"].Value; icbValue.Text = xn.Attributes["ValueReal"].Value; break; case "AnyQueryCheckBoxColumn": cbOperator.Items.Clear(); op.Clear(); op.AddRange(new String[] { "=", "!=" }); cbOperator.Items.AddRange(op.ToArray()); CheckBox cbValue = new CheckBox(); cbValue.Name = ColumnsCount + "AnyQueryValue1CheckBox" + xn.Attributes["ValueEnabled"].Value; if (xn.Attributes["Value1"].Value == "1") cbValue.Checked = true; cbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); cbValue.Location = new Point(standard, 15 + ColumnsCount * 30); cbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); cbValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(cbValue); break; case "AnyQueryRefValColumn": cbOperator.Items.Clear(); op.Clear(); op.AddRange(new String[] { "=", "!=", "IN", "NOT IN" }); cbOperator.Items.AddRange(op.ToArray()); if (xn.Attributes["Operator"].Value == "IN" || xn.Attributes["Operator"].Value == "NOT IN") { InfoDataSet idsRefButton = new InfoDataSet(); idsRefButton.RemoteName = "GLModule.cmdRefValUse"; idsRefButton.Execute(xn.Attributes["SelectCommand"].Value, CliUtils.fLoginDB, true); InfoBindingSource ibsRefButton = new InfoBindingSource(); ibsRefButton.DataSource = idsRefButton; ibsRefButton.DataMember = "cmdRefValUse"; InfoTranslate it = new InfoTranslate(); it.BindingSource = ibsRefButton; TranslateRefReturnFields trrf = new TranslateRefReturnFields(); trrf.ColumnName = xn.Attributes["ValueMember"].Value; trrf.DisplayColumnName = xn.Attributes["DisplayMember"].Value; it.RefReturnFields.Add(trrf); InfoRefbuttonBox aInfoRefbuttonBox = new InfoRefbuttonBox(); aInfoRefbuttonBox.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value; aInfoRefbuttonBox.Text = xn.Attributes["Value1"].Value; aInfoRefbuttonBox.RealValue = xn.Attributes["ValueReal"].Value; aInfoRefbuttonBox.Location = new Point(standard, 15 + ColumnsCount * 30); aInfoRefbuttonBox.Width = Convert.ToInt16(xn.Attributes["Width"].Value); ; aInfoRefbuttonBox.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); aInfoRefbuttonBox.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(aInfoRefbuttonBox); //TextBox tbRefButton = new TextBox(); //tbRefButton.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value; //tbRefButton.Text = xn.Attributes["Value1"].Value; //tbRefButton.AccessibleName = xn.Attributes["ValueReal"].Value; //tbRefButton.Width = Convert.ToInt16(xn.Attributes["Width"].Value); //tbRefButton.Location = new Point(standard, 15 + ColumnsCount * 30); //tbRefButton.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); //tbRefButton.Enter += new EventHandler(tbValue_Enter); //this.panel2.Controls.Add(tbRefButton); InfoRefButton ifb = new InfoRefButton(); ifb.autoPanel = true; ifb.infoTranslate = it; RefButtonMatch rbm = new RefButtonMatch(); rbm.matchColumnName = aInfoRefbuttonBox.Name; ifb.refButtonMatchs.Add(rbm); ifb.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + xn.Attributes["ValueEnabled"].Value; ifb.Text = "..."; ifb.Width = 20; ifb.Location = new Point(aInfoRefbuttonBox.Location.X + aInfoRefbuttonBox.Width + 2, 15 + ColumnsCount * 30); //ifb.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); this.panel2.Controls.Add(ifb); } else { cbOperator.Items.Remove("IN"); cbOperator.Items.Remove("NOT IN"); InfoRefvalBox irbValue = new InfoRefvalBox(); InfoRefVal aInfoRefVal = new InfoRefVal(); if (xn.Attributes["SelectAlias"].Value != String.Empty && xn.Attributes["SelectCommand"].Value != String.Empty) { aInfoRefVal.SelectAlias = xn.Attributes["SelectAlias"].Value; aInfoRefVal.SelectCommand = xn.Attributes["SelectCommand"].Value; } else { InfoDataSet idsRefVal = new InfoDataSet(); idsRefVal.RemoteName = xn.Attributes["RemoteName"].Value; idsRefVal.Active = true; InfoBindingSource ibsRefVal = new InfoBindingSource(); ibsRefVal.DataSource = idsRefVal; ibsRefVal.DataMember = idsRefVal.RealDataSet.Tables[0].TableName; aInfoRefVal.DataSource = ibsRefVal; } aInfoRefVal.DisplayMember = xn.Attributes["DisplayMember"].Value; aInfoRefVal.ValueMember = xn.Attributes["ValueMember"].Value; aInfoRefVal.EndInit(); irbValue.Name = ColumnsCount + "AnyQueryValue1InfoRefvalBox" + xn.Attributes["ValueEnabled"].Value; irbValue.RefVal = aInfoRefVal; irbValue.TextBoxText = xn.Attributes["Value1"].Value; irbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); irbValue.Location = new Point(standard, 15 + ColumnsCount * 30); irbValue.TextBoxEnabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); irbValue.TextBoxSelectedValue = xn.Attributes["ValueReal"].Value; irbValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(irbValue); } break; case "AnyQueryCalendarColumn": InfoDateTimePicker idtpValue = new InfoDateTimePicker(); idtpValue.BeginInit(); idtpValue.Name = ColumnsCount + "AnyQueryValue1InfoDateTimePicker" + xn.Attributes["ValueEnabled"].Value; idtpValue.Text = xn.Attributes["Value1"].Value; idtpValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); idtpValue.Location = new Point(standard, 15 + ColumnsCount * 30); idtpValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); idtpValue.Format = DateTimePickerFormat.Long; idtpValue.EndInit(); idtpValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(idtpValue); break; case "AnyQueryRefButtonColumn": cbOperator.Items.Clear(); op.Clear(); op.AddRange(new String[] { "IN", "NOT IN" }); cbOperator.Items.AddRange(op.ToArray()); InfoDataSet idsRefButton2 = new InfoDataSet(); if (xn.Attributes["RemoteName"].Value == "GLModule.cmdRefValUse") { idsRefButton2.RemoteName = "GLModule.cmdRefValUse"; idsRefButton2.Execute(xn.Attributes["SelectCommand"].Value, CliUtils.fLoginDB, true); } else { idsRefButton2.RemoteName = xn.Attributes["RemoteName"].Value; idsRefButton2.Active = true; } InfoBindingSource ibsRefButton2 = new InfoBindingSource(); ibsRefButton2.DataSource = idsRefButton2; if (xn.Attributes["RemoteName"].Value != null) ibsRefButton2.DataMember = idsRefButton2.RealDataSet.Tables[0].TableName; else ibsRefButton2.DataMember = "cmdRefValUse"; InfoTranslate it2 = new InfoTranslate(); it2.BindingSource = ibsRefButton2; TranslateRefReturnFields trrf2 = new TranslateRefReturnFields(); trrf2.ColumnName = xn.Attributes["ValueMember"].Value; trrf2.DisplayColumnName = xn.Attributes["DisplayMember"].Value; it2.RefReturnFields.Add(trrf2); InfoRefbuttonBox aInfoRefbuttonBox2 = new InfoRefbuttonBox(); aInfoRefbuttonBox2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value; aInfoRefbuttonBox2.Text = xn.Attributes["Value1"].Value; aInfoRefbuttonBox2.RealValue = xn.Attributes["ValueReal"].Value; aInfoRefbuttonBox2.Location = new Point(standard, 15 + ColumnsCount * 30); aInfoRefbuttonBox2.Width = Convert.ToInt16(xn.Attributes["Width"].Value); ; aInfoRefbuttonBox2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); aInfoRefbuttonBox2.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(aInfoRefbuttonBox2); //TextBox tbRefButton2 = new TextBox(); //tbRefButton2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value; //tbRefButton2.Text = xn.Attributes["Value1"].Value; //tbRefButton2.AccessibleName = xn.Attributes["ValueReal"].Value; //tbRefButton2.Width = Convert.ToInt16(xn.Attributes["Width"].Value); //tbRefButton2.Location = new Point(standard, 15 + ColumnsCount * 30); //tbRefButton2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); //tbRefButton2.Enter += new EventHandler(tbValue_Enter); //this.panel2.Controls.Add(tbRefButton2); InfoRefButton ifb2 = new InfoRefButton(); ifb2.autoPanel = Convert.ToBoolean(xn.Attributes["AutoPanel"].Value); if (!ifb2.autoPanel) { Control[] innerPanel = (this.innerAnyQuery.OwnerComp as InfoForm).Controls.Find(xn.Attributes["Panel"].Value, true); if (innerPanel.Length > 0) { ifb2.panel = innerPanel[0] as Panel; } if (ifb2.panel == null) { for (int i = 0; i < panels.Count; i++) { if (panels[i] == null) continue; ifb2.panel = panels[i]; } if (ifb2.panel == null) { MessageBox.Show("Can not find the Panel '" + xn.Attributes["Panel"].Value + "' in your Form."); return "AND"; } } } ifb2.infoTranslate = it2; RefButtonMatch rbm2 = new RefButtonMatch(); rbm2.matchColumnName = aInfoRefbuttonBox2.Name; ifb2.refButtonMatchs.Add(rbm2); ifb2.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + xn.Attributes["ValueEnabled"].Value; ifb2.Text = "..."; ifb2.Width = 20; ifb2.Location = new Point(aInfoRefbuttonBox2.Location.X + aInfoRefbuttonBox2.Width + 2, 15 + ColumnsCount * 30); //ifb2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); this.panel2.Controls.Add(ifb2); break; } cbOperator.SelectedIndexChanged -= new EventHandler(cbOperator_SelectedIndexChanged); cbOperator.Text = xn.Attributes["Operator"].Value; cbOperator.SelectedIndexChanged += new EventHandler(cbOperator_SelectedIndexChanged); if (xn.Attributes["Operator"].Value == "<->" || xn.Attributes["Operator"].Value == "!<->") { standard += Convert.ToInt16(xn.Attributes["Width"].Value) + 5; Label aLabel = new Label(); aLabel.Name = ColumnsCount + "AnyQueryValue1to2Label"; aLabel.Text = "~"; aLabel.Width = 10; aLabel.Location = new Point(standard, 15 + ColumnsCount * 30); this.panel2.Controls.Add(aLabel); standard += aLabel.Width + 5; switch (xn.Attributes["ValueType"].Value) { case "AnyQueryTextBoxColumn": TextBox tbValue = new TextBox(); tbValue.Name = ColumnsCount + "AnyQueryValue2TextBox2" + xn.Attributes["ValueEnabled"].Value; tbValue.Text = xn.Attributes["Value2"].Value; tbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); tbValue.Location = new Point(standard, 15 + ColumnsCount * 30); tbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); tbValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(tbValue); break; case "AnyQueryComboBoxColumn": InfoComboBox icbValue = new InfoComboBox(); icbValue.DisplayMemberOnly = true; if (xn.Attributes["SelectAlias"].Value == String.Empty || xn.Attributes["SelectCommand"].Value == String.Empty) { if (xn.Attributes["DataSource"].Value == String.Empty) { String[] temp = xn.Attributes["Items"].Value.Split(';'); foreach (String str in temp) { if (str != String.Empty) icbValue.Items.Add(str); } } else { InfoDataSet idsComboBox = new InfoDataSet(); idsComboBox.RemoteName = xn.Attributes["RemoteName"].Value; idsComboBox.Active = true; InfoBindingSource ibsComboBox = new InfoBindingSource(); ibsComboBox.DataSource = idsComboBox; ibsComboBox.DataMember = idsComboBox.RealDataSet.Tables[0].TableName; icbValue.DataSource = ibsComboBox; icbValue.DisplayMember = xn.Attributes["DisplayMember"].Value; icbValue.ValueMember = xn.Attributes["ValueMember"].Value; icbValue.EndInit(); } } else { icbValue.SelectAlias = xn.Attributes["SelectAlias"].Value; icbValue.SelectCommand = xn.Attributes["SelectCommand"].Value; icbValue.DisplayMember = xn.Attributes["DisplayMember"].Value; icbValue.ValueMember = xn.Attributes["ValueMember"].Value; icbValue.EndInit(); } icbValue.Name = ColumnsCount + "AnyQueryValue1InfoComboBox" + xn.Attributes["ValueEnabled"].Value; icbValue.Text = xn.Attributes["Value1"].Value; icbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); icbValue.Location = new Point(standard, 15 + ColumnsCount * 30); icbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); icbValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(icbValue); break; case "AnyQueryCheckBoxColumn": break; case "AnyQueryRefValColumn": InfoRefvalBox irbValue = new InfoRefvalBox(); InfoRefVal aInfoRefVal = new InfoRefVal(); aInfoRefVal.SelectAlias = xn.Attributes["SelectAlias"].Value; aInfoRefVal.SelectCommand = xn.Attributes["SelectCommand"].Value; aInfoRefVal.DisplayMember = xn.Attributes["DisplayMember"].Value; aInfoRefVal.ValueMember = xn.Attributes["ValueMember"].Value; aInfoRefVal.EndInit(); irbValue.Name = ColumnsCount + "AnyQueryValue2InfoRefvalBox2" + xn.Attributes["ValueEnabled"].Value; irbValue.RefVal = aInfoRefVal; irbValue.TextBoxText = xn.Attributes["Value2"].Value; irbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); irbValue.Location = new Point(standard, 15 + ColumnsCount * 30); irbValue.TextBoxEnabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); irbValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(irbValue); break; case "AnyQueryCalendarColumn": InfoDateTimePicker idtpValue = new InfoDateTimePicker(); idtpValue.BeginInit(); idtpValue.Name = ColumnsCount + "AnyQueryValue2InfoDateTimePicker2" + xn.Attributes["ValueEnabled"].Value; idtpValue.Text = xn.Attributes["Value2"].Value; idtpValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value); idtpValue.Location = new Point(standard, 15 + ColumnsCount * 30); idtpValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); idtpValue.Format = DateTimePickerFormat.Long; idtpValue.EndInit(); idtpValue.Enter += new EventHandler(tbValue_Enter); this.panel2.Controls.Add(idtpValue); break; case "AnyQueryRefButtonColumn"://<->不会用到RefButton //InfoDataSet idsRefButton2 = new InfoDataSet(); //if (xn.Attributes["RemoteName"].Value == "GLModule.cmdRefValUse") //{ // idsRefButton2.RemoteName = "GLModule.cmdRefValUse"; // idsRefButton2.Execute(xn.Attributes["SelectCommand"].Value, xn.Attributes["SelectAlias"].Value, true); //} //else //{ // idsRefButton2.RemoteName = xn.Attributes["RemoteName"].Value; // idsRefButton2.Active = true; //} //InfoBindingSource ibsRefButton2 = new InfoBindingSource(); //ibsRefButton2.DataSource = idsRefButton2; //if (xn.Attributes["RemoteName"].Value != null) // ibsRefButton2.DataMember = idsRefButton2.RealDataSet.Tables[0].TableName; //else // ibsRefButton2.DataMember = "cmdRefValUse"; //InfoTranslate it2 = new InfoTranslate(); //it2.BindingSource = ibsRefButton2; //TranslateRefReturnFields trrf2 = new TranslateRefReturnFields(); //trrf2.ColumnName = xn.Attributes["ValueMember"].Value; //it2.RefReturnFields.Add(trrf2); //TextBox tbRefButton2 = new TextBox(); //tbRefButton2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value; //tbRefButton2.Text = xn.Attributes["Value1"].Value; //tbRefButton2.Width = Convert.ToInt16(xn.Attributes["Width"].Value); //tbRefButton2.Location = new Point(standard, 15 + ColumnsCount * 30); //tbRefButton2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); //this.panel2.Controls.Add(tbRefButton2); //InfoRefButton ifb2 = new InfoRefButton(); //ifb2.autoPanel = Convert.ToBoolean(xn.Attributes["AutoPanel"].Value); //if (!ifb2.autoPanel) //{ // Control[] innerPanel = (this.innerAnyQuery.OwnerComp as InfoForm).Controls.Find(xn.Attributes["Panel"].Value, true); // if (innerPanel.Length > 0) // { // ifb2.panel = innerPanel[0] as Panel; // } // if (ifb2.panel == null) // { // for (int i = 0; i < panels.Count; i++) // { // if (panels[i] == null) continue; // ifb2.panel = panels[i]; // } // if (ifb2.panel == null) // { // MessageBox.Show("Can not find the Panel '" + xn.Attributes["Panel"].Value + "' in your Form."); // return "AND"; // } // } //} //ifb2.infoTranslate = it2; //RefButtonMatch rbm2 = new RefButtonMatch(); //rbm2.matchColumnName = tbRefButton2.Name; //ifb2.refButtonMatchs.Add(rbm2); //ifb2.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + xn.Attributes["ValueEnabled"].Value; //ifb2.Text = "..."; //ifb2.Width = 20; //ifb2.Location = new Point(tbRefButton2.Location.X + tbRefButton2.Width + 2, 15 + ColumnsCount * 30); ////ifb2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value); //this.panel2.Controls.Add(ifb2); break; } } if (innerAnyQuery.AutoDisableColumns) { cbActive_CheckedChanged(cbActive, new EventArgs()); } return xn.Attributes["Condition"].Value; }
private void btnQuery_Click(object sender, EventArgs e) { InfoRefVal aInfoRefVal = new InfoRefVal(); aInfoRefVal.DataSource = refButton.infoTranslate.BindingSource; frmRefButtonQuery afrmRefButtonQuery = null; int i = infoDataGridView1.Columns.Count; string[] colName = new String[i]; String[] colCaption = new String[i]; for (int j = 0; j < i; j++) { colName[j] = infoDataGridView1.Columns[j].Name; colCaption[j] = infoDataGridView1.Columns[j].HeaderText; } afrmRefButtonQuery = new frmRefButtonQuery(colName, colCaption, infoDataGridView1.DataSource as InfoBindingSource, strFilter, aInfoRefVal); afrmRefButtonQuery.Font = this.Font; afrmRefButtonQuery.ShowDialog(); }
private void btnOK_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 < 9; 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 { cqeditor.BindingSource = (InfoBindingSource)ict.Components[cmbbindingsource.Text]; cqeditor.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(); qc[i].ColumnType = dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString(); qc[i].Condition = dgvClientQuery.Rows[i].Cells["Condition"].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].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]; } if (dgvClientQuery.Rows[i].Cells["ExternalRefval"].Value != null) { qc[i].ExternalRefVal = dgvClientQuery.Rows[i].Cells["ExternalRefval"].Value.ToString(); } if (dgvClientQuery.Rows[i].Cells["ColumnVisible"].Value != null) { qc[i].Visible = (bool)dgvClientQuery.Rows[i].Cells["ColumnVisible"].Value; } cqeditor.Columns.Add(qc[i]); } //MessageBox.Show(string.Format("cqeditor has {0} columns", cqeditor.Columns.Count)); //new add IComponentChangeService ComponentChangeService = this.DesignerHost.GetService(typeof(IComponentChangeService)) as IComponentChangeService; object oldValue = null; object newValue = null; //BindingSource PropertyDescriptor descBindingSource = TypeDescriptor.GetProperties(this.cqold)["BindingSource"]; ComponentChangeService.OnComponentChanging(this.cqold, descBindingSource); oldValue = cqold.BindingSource; cqold.BindingSource = cqeditor.BindingSource; newValue = cqold.BindingSource; ComponentChangeService.OnComponentChanged(this.cqold, descBindingSource, oldValue, newValue); // Columns PropertyDescriptor descColumns = TypeDescriptor.GetProperties(this.cqold)["Columns"]; ComponentChangeService.OnComponentChanging(this.cqold, descColumns); oldValue = cqold.Columns; cqold.Columns = cqeditor.Columns; newValue = cqold.Columns; ComponentChangeService.OnComponentChanged(this.cqold, descColumns, oldValue, newValue); this.Close(); }
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(); }