Exemple #1
0
 public static ColumnsInfo <TApi> GetInstance(string sqlString, Func <NpgsqlDataReader, TApi> getValue)
 {
     if (fieldsTypesInfo == null)
     {
         fieldsTypesInfo = new ColumnsInfo <TApi>(sqlString, getValue);
     }
     return(fieldsTypesInfo);
 }
Exemple #2
0
 public FieldsTypesInfo()
 {
     columnsInfo = ColumnsInfo <FieldType> .GetInstance(
         @"SELECT name, numb, type_field
       FROM clinic.sys_names JOIN clinic.sys_fields_types ON  id = id_name;",
         (reader) => {
         return(new FieldType(
                    reader.GetString(0),
                    reader.GetInt32(1),
                    (NpgsqlDbType)reader.GetInt32(2)
                    ));
     });
 }
Exemple #3
0
 public InputUPDColumnsInfo()
 {
     columnsInfo = ColumnsInfo <InputUPDColumn> .GetInstance(
         @"SELECT name, numb, column_name
       FROM clinic.sys_names JOIN clinic.sys_input_UPD_columns ON  id = id_name;",
         (reader) => {
         return(new InputUPDColumn(
                    reader.GetString(0),
                    reader.GetInt32(1),
                    reader.GetString(2)
                    ));
     });
 }
Exemple #4
0
        public static void GetData(ComboBox comboBox, string apiName)
        {
            var columnsInfo = ColumnsInfo <ComboBoxColumn> .GetInstance(
                @"SELECT name,  numb, column_name
                  FROM clinic.sys_names JOIN clinic.sys_comboBox_columns ON  id = id_name; ",
                (reader) => {
                return(new ComboBoxColumn(
                           reader.GetString(0),
                           reader.GetInt32(1),
                           reader.GetString(2)
                           ));
            });


            ComboBoxColumn[] comboBoxColumns = columnsInfo[apiName];

            comboBox.ValueMember   = comboBoxColumns[0].ColumnName;
            comboBox.DisplayMember = comboBoxColumns[1].ColumnName;
        }
Exemple #5
0
        public static void GetData(DataGridView dataGridView, string apiName)
        {
            var columnsInfo = ColumnsInfo <Classes.DataGridViewColumn> .GetInstance(
                @"SELECT name, numb, dataPropertyName, headerText, visible, width, readOnly, columnType
                  FROM clinic.sys_names JOIN clinic.sys_dataGridView_columns ON  id = id_name; ",
                (reader) => {
                return(new Classes.DataGridViewColumn(
                           reader.GetString(0),
                           reader.GetInt32(1),
                           reader.GetString(2),
                           reader.GetString(3),
                           reader.GetBoolean(4),
                           reader.GetInt32(5),
                           reader.GetBoolean(6),
                           reader.GetInt32(7)
                           ));
            });

            Classes.DataGridViewColumn[] dataGridViewColumns = columnsInfo[apiName];


            dataGridView.AutoGenerateColumns = false;

            foreach (var column in dataGridViewColumns)
            {
                switch (column.ColumnType)
                {
                case 1:
                    dataGridView.Columns.Add(new DataGridViewTextBoxColumn()
                    {
                        DataPropertyName = column.DataPropertyName,
                        HeaderText       = column.HeaderText,
                        Visible          = column.Visible,
                        Width            = column.Width,
                        ReadOnly         = column.ReadOnly
                    });
                    break;

                case 2:
                    dataGridView.Columns.Add(new DataGridViewComboBoxColumn()
                    {
                        DataPropertyName = column.DataPropertyName,
                        HeaderText       = column.HeaderText,
                        Visible          = column.Visible,
                        Width            = column.Width,
                        ReadOnly         = column.ReadOnly
                    });
                    break;

                case 3:
                    dataGridView.Columns.Add(new DataGridViewButtonColumn()
                    {
                        DataPropertyName            = column.DataPropertyName,
                        Text                        = column.HeaderText,
                        Visible                     = column.Visible,
                        Width                       = column.Width,
                        ReadOnly                    = column.ReadOnly,
                        HeaderText                  = "",
                        UseColumnTextForButtonValue = true
                    });
                    break;
                }
            }
        }