Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
 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());
     }
 }