private void AdjectLabelEditPos(TStringList EditList, TStringList LabelList) { int MaxLabelWidth = 0; System.Windows.Forms.Label label = null; System.Windows.Forms.TextBox textbox = null; for (int I = 0; I < LabelList.Count; I++) { label = (System.Windows.Forms.Label)LabelList[I]; if (label.Width > MaxLabelWidth) MaxLabelWidth = label.Width; } if (MaxLabelWidth >= 105) { int EditOffSet = MaxLabelWidth - 105 + 5; for (int I = 0; I < EditList.Count; I++) { textbox = (System.Windows.Forms.TextBox)EditList[I]; textbox.Left = 110 + EditOffSet; } for (int I = 0; I < LabelList.Count; I++) { label = (System.Windows.Forms.Label)LabelList[I]; label.Left = 110 - label.Width - 5 + EditOffSet; } } if (EditList.Count == 0) return; int ColumnIndex = 0; int ColumnControlCount = EditList.Count / FClientData.ColumnCount; int ColumnWidth = ((System.Windows.Forms.TextBox)EditList[0]).Left + ((System.Windows.Forms.TextBox)EditList[0]).Width; int TopOffset = 10; int ColumnControlIndex = 0; for (int I = 0; I < EditList.Count; I++) { if (I % ColumnControlCount == 0) { if (I + 1 >= ColumnControlCount) { ColumnControlIndex = 0; ColumnIndex++; } } label = (System.Windows.Forms.Label)LabelList[I]; textbox = (System.Windows.Forms.TextBox)EditList[I]; textbox.Left = textbox.Left + ColumnWidth * ColumnIndex; textbox.Top = TopOffset + (textbox.Height + 5) * ColumnControlIndex; label.Left = label.Left + ColumnWidth * ColumnIndex; label.Top = textbox.Top + (textbox.Height - label.Height) / 2; ColumnControlIndex++; } }
private void LoadDBString() { try { cbEEPAlias.Items.Clear(); FAlias = new TStringList(); List<string> list1 = new List<string>(); string text3 = SystemFile.DBFile; XmlDocument document1 = new XmlDocument(); document1.Load(text3); foreach (XmlNode node1 in document1.FirstChild.FirstChild.ChildNodes) { list1.Add((string)node1.Name); cbEEPAlias.Items.Add(node1.Name); string text1 = node1.Attributes["String"].Value.Trim(); string text2 = WzdUtils.GetPwdString(node1.Attributes["Password"].Value.Trim()); if ((text1.Length > 0) && (text2.Length > 0) && text2 != String.Empty) { if (text1[text1.Length - 1] != ';') { text1 = text1 + ";Password="******"Password="******"Please setup <DB Manager> of EEPNetServer at first !"); } }
private void GetFieldList(string DatabaseName, string TableName, TStringList FieldNameList) { String Owner = ""; if (TableName.IndexOf('.') > -1) { Owner = WzdUtils.GetToken(ref TableName, new char[] { '.' }); } string[] S = new string[4]; S[1] = Owner; S[2] = TableName; String SortName = "ORDINAL_POSITION"; if (FServerData.DatabaseType == ClientType.ctOracle) { String UserID = WzdUtils.GetFieldParam(FServerData.ConnectionString, "User ID"); S = new String[] { UserID.ToUpper(), TableName }; SortName = "ID"; } DataTable D = FServerData.Owner.GlobalConnection.GetSchema("Columns", S); DataRow[] DRs = D.Select("", SortName + " ASC"); foreach (DataRow DR in DRs) FieldNameList.Add(DR["COLUMN_NAME"].ToString()); }
private void GenTextBoxControl(TBlockItem BlockItem) { DataTable aTable = FindDataTable(BlockItem.BindingSource, BlockItem.ProviderName); TStringList aLabelList = new TStringList(); TStringList aEditList = new TStringList(); TBlockFieldItem aFieldItem; System.Windows.Forms.Label l = null; int TopOffset = 10; int LeftOffst = 100; InfoTextBox aInfoTextBox = null; InfoRefvalBox aInfoRefValBox = null; InfoDateTimePicker aInfoDateTimePicker = null; InfoRefVal aRefVal = null; InfoComboBox aComboBox = null; CheckBox aCheckBox = null; for (int I = 0; I < BlockItem.BlockFieldItems.Count; I++) { aFieldItem = BlockItem.BlockFieldItems[I] as TBlockFieldItem; aInfoTextBox = null; aInfoRefValBox = null; aInfoDateTimePicker = null; aRefVal = null; aComboBox = null; aCheckBox = null; if ((aFieldItem.RefValNo != null && aFieldItem.RefValNo != "") || aFieldItem.RefField != null) { aRefVal = GenRefVal(aFieldItem, BlockItem.ProviderName); aInfoRefValBox = FDesignerHost.CreateComponent(typeof(InfoRefvalBox)) as InfoRefvalBox; aInfoRefValBox.Parent = FindContainer(FRootForm, BlockItem.ContainerName); aInfoRefValBox.Top = TopOffset + (aInfoRefValBox.Height + 5) * I; aInfoRefValBox.Left = LeftOffst; aInfoRefValBox.Width = 150; aInfoRefValBox.Text = aFieldItem.DataField; //aInfoRefValBox.Name = "tb" + aFieldItem.DataField; aInfoRefValBox.Name = aFieldItem.DataField + "InfoRefValBox"; aInfoRefValBox.DataBindings.Add(new Binding("Text", BlockItem.BindingSource, aFieldItem.DataField, true)); aInfoRefValBox.DataBindings[0].FormatString = aFieldItem.EditMask; aInfoRefValBox.RefVal = aRefVal; aInfoRefValBox.TextBoxBindingSource = BlockItem.BindingSource; aInfoRefValBox.TextBoxBindingMember = aFieldItem.DataField; //aInfoRefValBox.MaxLength = FieldItem.Length; aEditList.Add(aInfoRefValBox); } else if (aFieldItem.ControlType == "ComboBox") { string type = FindSystemDBType("SystemDB"); aComboBox = FDesignerHost.CreateComponent(typeof(InfoComboBox)) as InfoComboBox; //aComboBox.Name = "icb" + aFieldItem.DataField; aComboBox.Name = aFieldItem.DataField + "ComboBox"; aComboBox.Parent = FindContainer(FRootForm, BlockItem.ContainerName); aComboBox.Top = TopOffset + (aComboBox.Height + 5) * I; aComboBox.Left = LeftOffst; aComboBox.Width = 150; aComboBox.SelectAlias = FClientData.Owner.SelectedAlias; if (aFieldItem.ComboEntityName != null && aFieldItem.ComboTextField != null && aFieldItem.ComboValueField != null) { if (type == "1") aComboBox.SelectCommand = String.Format("Select [{0}].[{1}], [{0}].[{2}] from [{0}]", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField); else if (type == "2") aComboBox.SelectCommand = String.Format("Select [{0}].[{1}], [{0}].[{2}] from [{0}]", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField); else if (type == "3") aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField); else if (type == "4") aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField); else if (type == "5") aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField); else if (type == "6") aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField); else if (type == "7") aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField); } aComboBox.DisplayMember = aFieldItem.ComboTextField; aComboBox.ValueMember = aFieldItem.ComboValueField; aComboBox.DataBindings.Add(new Binding("Text", BlockItem.BindingSource, aFieldItem.DataField, true)); //if (dsColdef.Tables[0].Rows.Count > 0) // for (int j = 0; j < dsColdef.Tables[0].Rows.Count; j++) // if (dsColdef.Tables[0].Rows[j]["FIELD_NAME"].ToString() == aFieldItem.DataField && dsColdef.Tables[0].Rows[j]["EDITMASK"] != null) // aComboBox.DataBindings[0].FormatString = dsColdef.Tables[0].Rows[j]["EDITMASK"].ToString(); aComboBox.DataBindings[0].FormatString = aFieldItem.EditMask; aEditList.Add(aComboBox); } else if (aFieldItem.ControlType == "CheckBox") { aCheckBox = FDesignerHost.CreateComponent(typeof(CheckBox)) as CheckBox; aCheckBox.Name = aFieldItem.DataField + "CheckBox"; aCheckBox.Site.Name = aFieldItem.DataField + "CheckBox"; aCheckBox.Parent = FindContainer(FRootForm, BlockItem.ContainerName); aCheckBox.Height = 22; aCheckBox.Top = TopOffset + (aCheckBox.Height + 5) * I; aCheckBox.Left = LeftOffst; aCheckBox.Width = 150; aCheckBox.DataBindings.Add(new Binding("Checked", BlockItem.BindingSource, aFieldItem.DataField, true)); aEditList.Add(aCheckBox); } else { if (aTable.Columns[aFieldItem.DataField].DataType == typeof(DateTime) || (aFieldItem.ControlType != null && aFieldItem.ControlType.ToUpper() == "DATETIMEBOX")) { aInfoDateTimePicker = FDesignerHost.CreateComponent(typeof(InfoDateTimePicker)) as InfoDateTimePicker; aInfoDateTimePicker.Parent = FindContainer(FRootForm, BlockItem.ContainerName); aInfoDateTimePicker.Top = TopOffset + (aInfoDateTimePicker.Height + 5) * I; aInfoDateTimePicker.Left = LeftOffst; aInfoDateTimePicker.Width = 150; //aInfoDateTimePicker.Name = "dtp" + aFieldItem.DataField; aInfoDateTimePicker.Site.Name = aFieldItem.DataField + "InfoDateTimePicker"; aInfoDateTimePicker.DataBindings.Add(new Binding("Text", BlockItem.BindingSource, aFieldItem.DataField, true)); //if (dsColdef.Tables[0].Rows.Count > 0) // for (int j = 0; j < dsColdef.Tables[0].Rows.Count; j++) // if (dsColdef.Tables[0].Rows[j]["FIELD_NAME"].ToString() == aFieldItem.DataField && dsColdef.Tables[0].Rows[j]["EDITMASK"] != null) // aInfoDateTimePicker.DataBindings[0].FormatString = dsColdef.Tables[0].Rows[j]["EDITMASK"].ToString(); aInfoDateTimePicker.DataBindings[0].FormatString = aFieldItem.EditMask; aEditList.Add(aInfoDateTimePicker); } else { aInfoTextBox = FDesignerHost.CreateComponent(typeof(InfoTextBox)) as InfoTextBox; aInfoTextBox.Parent = FindContainer(FRootForm, BlockItem.ContainerName); aInfoTextBox.Top = TopOffset + (aInfoTextBox.Height + 5) * I; aInfoTextBox.Left = LeftOffst; aInfoTextBox.Width = 150; aInfoTextBox.Text = aFieldItem.DataField; //aInfoTextBox.Name = "tb" + aFieldItem.DataField; aInfoTextBox.Site.Name = aFieldItem.DataField + "InfoTextBox"; aInfoTextBox.DataBindings.Add(new Binding("Text", BlockItem.BindingSource, aFieldItem.DataField, true)); //if (dsColdef.Tables[0].Rows.Count > 0) // for (int j = 0; j < dsColdef.Tables[0].Rows.Count; j++) // if (dsColdef.Tables[0].Rows[j]["FIELD_NAME"].ToString() == aFieldItem.DataField && dsColdef.Tables[0].Rows[j]["EDITMASK"] != null) // aInfoTextBox.DataBindings[0].FormatString = dsColdef.Tables[0].Rows[j]["EDITMASK"].ToString(); aInfoTextBox.DataBindings[0].FormatString = aFieldItem.EditMask; aInfoTextBox.MaxLength = aFieldItem.Length; aEditList.Add(aInfoTextBox); } } CreateQueryField(aFieldItem, "", aRefVal, BlockItem.BindingSource); l = FDesignerHost.CreateComponent(typeof(System.Windows.Forms.Label)) as Label; l.Parent = FindContainer(FRootForm, BlockItem.ContainerName); l.AutoSize = true; l.Text = aFieldItem.Description; if (l.Text == "") l.Text = aFieldItem.DataField; l.Left = LeftOffst - l.Width - 5; if (aInfoTextBox != null) { l.Top = aInfoTextBox.Top + (aInfoTextBox.Height - l.Height) / 2; } if (aInfoDateTimePicker != null) { l.Top = aInfoDateTimePicker.Top + (aInfoDateTimePicker.Height - l.Height) / 2; } aLabelList.Add(l); } AdjectLabelEditPos(aEditList, aLabelList); }
private void GetTableCaptionFromCOLDEF(TStringList aTableNameCaptionList) { //int I; //DataRow DR; //InfoCommand aInfoCommand = new InfoCommand(FDatabaseType); //aInfoCommand.Connection = FConnection; //aInfoCommand.CommandText = "Select TABLE_NAME, CAPTION from COLDEF where FIELD_NAME = '' or FIELD_NAME is null order by TABLE_NAME"; //IDbDataAdapter DA = DBUtils.CreateDbDataAdapter(aInfoCommand); //DataSet D = new DataSet(); //WzdUtils.FillDataAdapter(FDatabaseType, DA, D, "COLDEF"); //aTableNameCaptionList.Clear(); //for (I = 0; I < D.Tables[0].Rows.Count; I++) //{ // DR = D.Tables[0].Rows[I]; // if (DR["TABLE_NAME"].ToString().Trim() != "" && DR["CAPTION"].ToString().Trim() != "") // aTableNameCaptionList.Add(DR["TABLE_NAME"].ToString().Trim() + "=" + DR["CAPTION"].ToString().Trim()); //} }
private void GetTableNames(ListView LV) { int I; ListViewItem lvi; TStringList aTableCaptionList = new TStringList(); TStringList aTableList = new TStringList(); String[] Params = null; String ViewFieldName = "TABLE_NAME"; if (FServerData.DatabaseType == ClientType.ctOracle) { String UserID = WzdUtils.GetFieldParam(FServerData.ConnectionString.ToLower(), "user id"); Params = new String[] { UserID }; ViewFieldName = "VIEW_NAME"; } if (FServerData != null) { aTableCaptionList = FServerData.TableNameCaptionList; aTableList = FServerData.TableNameList; } else { if (FConnection.GetType().FullName != "IBM.Data.Informix.IfxConnection") { GetTableCaptionFromCOLDEF(aTableCaptionList); DataTable D = FConnection.GetSchema("Tables", Params); D.Select("", "TABLE_NAME DESC"); for (I = 0; I < D.Rows.Count; I++) aTableList.Add(D.Rows[I]["TABLE_NAME"].ToString()); DataTable T = FConnection.GetSchema("Views", Params); DataRow[] dr = T.Select("", "VIEW_NAME ASC"); foreach (DataRow DR in dr) { aTableList.Add(DR["VIEW_NAME"].ToString()); } } else { List<String> allTables = WzdUtils.GetAllTablesList(FConnection, ClientType.ctInformix); allTables.Sort(); foreach (String str in allTables) aTableList.Add(str); } } //if (FConnection.GetType().FullName != "IBM.Data.Informix.IfxConnection") //{ // DataTable D1 = FConnection.GetSchema("Views", Params); // D1.Select("", ViewFieldName + " DESC"); // foreach (DataRow DR in D1.Rows) // { // if (aTableList.IndexOf(DR[ViewFieldName].ToString()) < 0) // aTableList.Add(DR[ViewFieldName].ToString()); // } //} LV.Items.Clear(); if (aTableList.Count > 0) { LV.BeginUpdate(); for (I = 0; I < aTableList.Count; I++) { lvi = new ListViewItem(); lvi.Text = aTableList[I].ToString(); //lvi.SubItems[""] = ""; LV.Items.Add(lvi); String tableName = lvi.Text; if (tableName.Contains(".")) tableName = tableName.Split('.')[1]; lvi.SubItems.Add(aTableCaptionList.Values(tableName)); lvi.Selected = lvi.Text.CompareTo(FTableName) == 0; } LV.EndUpdate(); } LV.Sort(); }
private void LoadDBString() { cbEEPAlias.Items.Clear(); FAlias = new TStringList(); List<string> list1 = new List<string>(); string text3 = SystemFile.DBFile; XmlDocument document1 = new XmlDocument(); document1.Load(text3); foreach (XmlNode node1 in document1.FirstChild.FirstChild.ChildNodes) { list1.Add((string)node1.Name); cbEEPAlias.Items.Add(node1.Name); FServerData.DatabaseType = (ClientType)int.Parse(node1.Attributes["Type"].Value); string text1 = node1.Attributes["String"].Value.Trim(); string text2 = WzdUtils.GetPwdString(node1.Attributes["Password"].Value.Trim()); if ((text1.Length > 0) && (text2.Length > 0) && text2 != String.Empty) { if (text1[text1.Length - 1] != ';') { text1 = text1 + ";Password="******"Password=" + text2; } } FAlias.AddObject(node1.Name, text1); } }
private void GetFieldNamesEx(TDatasetItem aDatasetItem, string DatabaseName, string TableName, String DataSetName, ListView SrcListView, ListView DestListView) { int I, J = 0; bool Found = false; ListViewItem lvi = null; //TFieldAttrItem tai; TStringList aPhysFieldNameList = new TStringList(); TStringList aFieldCaptionList = new TStringList(); if (aDatasetItem != null) { aPhysFieldNameList = aDatasetItem.FieldList; aFieldCaptionList = aDatasetItem.FieldCaptionList; } else { GetFieldList(DatabaseName, TableName, aPhysFieldNameList); } /* for (I = 0; I < DestListView.Items.Count - 1; I++) { lvi = DestListView.Items[I]; if (aPhysFieldNameList.IndexOf(lvi.Text) < 0) { tai = (TFieldAttrItem)lvi.Tag; } } */ SrcListView.Items.Clear(); for (I = 0; I < aPhysFieldNameList.Count; I++) { Found = false; for (J = 0; J < DestListView.Items.Count; J++) { lvi = DestListView.Items[J]; if (string.Compare(aPhysFieldNameList[I].ToString(), lvi.Text, false) == 0) { Found = true; break; } } if (Found == false) { lvi = SrcListView.Items.Add(aPhysFieldNameList[I].ToString()); lvi.SubItems.Add(aFieldCaptionList.Values(lvi.Text)); } } if (SrcListView.Items.Count > 0) SrcListView.Items[0].Selected = true; }
public fmSelDetail() { InitializeComponent(); FDetailList = new TStringList(); }