private void BuildInsertWithUDTProcedure(DbUtilities dbConn, string dataType, DataAccessDef accessDef)
        {
            string sqlCommand = $"DROP PROCEDURE IF EXISTS spInsert{dataType}; ";

            sqlCommand = sqlCommand + $"DROP TYPE IF EXISTS[dbo].[UDT{dataType}];";
            dbConn.SQLExecute(sqlCommand);

            sqlCommand = "";
            string           sql   = accessDef.Select;
            string           table = Common.GetTable(sql);
            ColumnProperties attributeProperties = CommonDbUtilities.GetColumnSchema(dbConn, sql);

            string[] tableAttributes = Common.GetAttributes(sql);
            tableAttributes = tableAttributes.Where(w => w != "Id").ToArray();
            CreateUserDefinedTypes(dbConn, attributeProperties, sql, dataType);
            string comma      = "";
            string attributes = "";

            foreach (var word in tableAttributes)
            {
                string attribute = word.Trim();
                attributes = attributes + comma + "[" + attribute + "]";
                comma      = ",";
            }
            sqlCommand = sqlCommand + $"CREATE PROCEDURE [dbo].[spInsert{dataType}] @rules UDT{dataType} readonly " +
                         " AS BEGIN " +
                         $" INSERT INTO dbo.{table}({attributes}) " +
                         $" SELECT {attributes} FROM @rules;" +
                         " END";
            dbConn.SQLExecute(sqlCommand);
        }
예제 #2
0
            private static void ResetPropertyOnAllColumns(ColumnProperties property)
            {
                for (int i = 0; i < Owner.Columns.Count; i++)
                {
                    DataGridViewColumn c = Owner.Columns[i];
                    switch (property)
                    {
                    case ColumnProperties.Visible:
                        MakeColumnVisible(c, true);
                        break;

                    case ColumnProperties.DisplayIndex:
                        c.DisplayIndex = c.Index;
                        break;

                    case ColumnProperties.Width:
                        if (c.Resizable == DataGridViewTriState.True)
                        {
                            c.Width = Defaults.ColumnWidth;
                        }
                        break;
                    }

                    Owner.SelectProperly();

                    SetColumnChecked(c.Index, c.Visible);
                }
            }
예제 #3
0
        public DialogTeachingHistory(DataGridViewRow row)
        {
            InitializeComponent();

            currentSemester = new SemesterKey(cmd.GetCurrentSemesterKey());
            string email = row.Cells["Email"].Value.ToString();
            string name  = row.Cells["FirstName"].Value.ToString() + " " + row.Cells["LastName"].Value.ToString();

            ColumnProperties columnProperties = new ColumnProperties();
            BuildView        historyView      = new BuildView()
            {
                GridView            = DGV_DialogTeachingHistory,
                TabledData          = cmd.TeacherHistory(email),
                DataGridViewColumns = new DataGridViewColumn[] {
                    columnProperties.courseCode,
                    columnProperties.courseName,
                    columnProperties.subjectName,
                    columnProperties.collegeName,
                    columnProperties.semesterName,
                    columnProperties.period,
                    columnProperties.teacherEmail_Hidden,
                    columnProperties.teacherFullName_Hidden,
                    columnProperties.semesterKey
                }
            };

            historyView.Create();
            historyView.GridView.MultiSelect = true;

            SetPeriod();
            LBL_TeachingHistory_Name.Text        = name;
            LBL_DialogTeacherHistoryResults.Text = string.Format("{0} Course(s)", historyView.ResultCount.ToString());
        }
 public XMLColumnModel(CT_Col col, int number)
 {
     _col            = col;
     _colnumber      = number;
     _interface      = new ColumnProperties(this);
     _col.Width_Attr = 9.140625;
 }
예제 #5
0
        // "form" currently unused - keeping dialog constructor params consistant
        public DialogCourseUnit(MainForm form, DataGridViewRow row)
        {
            InitializeComponent();

            mainForm   = form;
            courseCode = row.Cells["CourseCode"].Value.ToString();
            courseName = row.Cells["CourseName"].Value.ToString();

            ColumnProperties columnProperties = new ColumnProperties();

            courseUnitView = new BuildView()
            {
                GridView            = DGV_DialogCourseUnit,
                TabledData          = cmd.DialogCourseUnitPopulateUnit(courseCode, ""),
                DataGridViewColumns = new DataGridViewColumn[] {
                    columnProperties.unitCode,
                    columnProperties.unitDescription,
                    columnProperties.core_CheckBox,
                    columnProperties.select_CheckBox
                },
                EditMode = DataGridViewEditMode.EditOnEnter
            };
            courseUnitView.Create();
            totalCount  = courseUnitView.ResultCount;
            resultCount = courseUnitView.ResultCount;

            GetLoadedUnits();
            SetResultLabel();
            LBL_DialogCourseUnit.Text = string.Format("{0} - {1}", courseCode, courseName);
        }
        public DialogColumnPropertiesViewModel(MemberModifierFactory memberModifierFactory,
                                               ColumnProperties localColumnProperties,
                                               ColumnProperties globaColumnProperties,
                                               ColumnValuesGetter columnValuesGetter
                                               )
        {
            PositionRotationComboBox = new List <string>()
            {
                "TOP"
            };
            PositionVerticalComboBox = new List <string>()
            {
                "DOWN", "MIDDLE", "UP"
            };
            PositionHorizontalComboBox = new List <string>()
            {
                "LEFT", "MIDDLE", "RIGHT"
            };

            SelectedDataInPositionVerticalComboBox   = PositionVerticalComboBox[0];
            SelectedDataInPositionRotationComboBox   = PositionRotationComboBox[0];
            SelectedDataInPositionHorizontalComboBox = PositionHorizontalComboBox[0];

            InitCommand();
            this.modifierFactory       = memberModifierFactory;
            this.globaColumnProperties = globaColumnProperties;
            this.columnValuesGetter    = columnValuesGetter;
            UpdateViewModel(localColumnProperties);
        }
 private void UpdateNumberingData(ColumnProperties columnProperties)
 {
     NumberingSeriesPartPrefixText          = columnProperties.NumberingSeriesPartPrefixText;
     NumberingSeriesPartStartNumberText     = columnProperties.NumberingSeriesPartStartNumberText;
     NumberingSeriesAssemblyPrefixText      = columnProperties.NumberingSeriesAssemblyPrefixText;
     NumberingSeriesAssemblyStartNumberText = columnProperties.NumberingSeriesAssemblyStartNumberText;
 }
예제 #8
0
    /// <summary>
    /// gets an idf value for numeral input
    /// </summary>
    /// <param name="columname"></param>
    /// <param name="u"></param>
    /// <returns></returns>
    public static double GetNumeralIdf(string columname, double u)
    {
        DataTable column = connection.QueryForDataTable("SELECT " + columname + " FROM autompg  ORDER BY " + columname + " ASC;");

        ColumnProperties properties = ColumnProperties[columname];

        //idf(t) = log (n / d) = log(n) - log(d)
        //d = sum of e ^ (-0,5*f) ^ 2
        //f = (ti -u ) / h
        // where (i is the counter of the sum) AND (i E [0,...n]) AND h is the total bandwith

        double d = 0;

        foreach (DataRow row in column.Rows)
        {
            //f = (ti -u ) / h
            //f = afstand / max mogelijke afstand
            double f = (Convert.ToDouble(row[columname]) - u) / (properties.max - properties.min);

            //d = sum of e ^ (-0,5*f) ^ 2
            double g = Math.Pow(Math.E, (-0.5 * Math.Pow(f, 2)));
            d += g;
        }

        //idf(t) = log (n / d)
        double idf = Math.Abs(10 * (Math.Log(column.Rows.Count / d, Math.E)));  //TODO: testen of je niet moet delen door log10*columns.rows.count om scalar te krijgen

        return(idf);
    }
예제 #9
0
        private void set_Footer(int index)
        {
            if (index < Properties.Count && index >= 0)
            {
                ColumnProperties p = Properties[index];


                this.DefVal_txt.Text = p.default_Value;

                this.unique_check.Checked = p.Isunique;
                this.inc_dec_checkedList.SetItemChecked(0, p.inCrement);
                this.inc_dec_checkedList.SetItemChecked(1, p.deCrement);
                this.inc_dec_txt.Text = p.step.ToString();

                this.Exp_txt.Text = "";
                for (int i = 0; i < p.CheckCons.Count; i++)
                {
                    this.Exp_txt.Text += p.CheckCons[i];
                    if (i < p.CheckCons.Count - 1)
                    {
                        this.Exp_txt.Text += Environment.NewLine;
                    }
                }

                this.len_txt.Text  = p.Length.ToString();
                this.seed_txt.Text = p.seed.ToString();
            }
            //else if (index!=0)
            //{
            //    MessageBox.Show("index out of range ! ");
            //}
        }
예제 #10
0
        protected override void OnLoad(EventArgs e)
        {
            if (ColumnProperties.IsNullOrEmpty())
            {
                throw new ArgumentException("ColumnProperties must be set and non-empty");
            }

            foreach (var column in ColumnProperties)
            {
                // column name, precision, preview color text, visibility, data type, forecolor, backcolor
                int rowIndex = columnOptionsDGV.Rows.Add(new object[]
                {
                    column.Key,
                    column.Value.Precision.HasValue ? column.Value.Precision.Value.ToString() : column.Value.Type == typeof(float) ? "Auto" : null,
                    "Preview Text",
                    _visibilityValues.SingleOrDefault(o => o.Value == column.Value.Visible).Key,
                    column.Value.Type,
                    column.Value.ForeColor,
                    column.Value.BackColor
                });
            }

            colorColumn.DefaultCellStyle.ForeColor = DefaultForeColor ?? SystemColors.WindowText;
            colorColumn.DefaultCellStyle.BackColor = DefaultBackColor ?? SystemColors.Window;

            base.OnLoad(e);
        }
        private DataTable BuildDataTable()
        {
            foreach (CamlXmlFieldRef fieldRef in this._camlXmlQuery.ViewFields.FieldRef)
            {
                if (!this._spList.Fields.ContainsField(fieldRef.Name))
                {
                    continue;
                }

                SPField          spField = this._spList.Fields.GetField(fieldRef.Name);
                ColumnProperties column  = new ColumnProperties
                {
                    FieldName  = fieldRef.Name,
                    Caption    = spField.Title,
                    Visible    = true,
                    Type       = spField.Type.ToString(),
                    GroupIndex = -1
                };
                this._head.Heads[0].ColumnGroups[0].Columns.Add(column);
            }

            DataTable dataTable = this.GenerateData(this._camlXmlQuery.RowLimit.Value);

            return(dataTable);
        }
예제 #12
0
        /// <summary>
        /// Creates the column properties.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="propertyNode">The property node.</param>
        /// <returns></returns>
        private ColumnProperties CreateColumnProperties(IStyle style, XmlNode propertyNode)
        {
            ColumnProperties columnProperties = new ColumnProperties(style);

            columnProperties.Node = propertyNode;

            return(columnProperties);
        }
 private void UpdateViewModel(ColumnProperties columnProperties)
 {
     LoadData(columnProperties);
     UpdatePositionData(columnProperties);
     UpdateAttributesData(columnProperties);
     UpdateNumberingData(columnProperties);
     TickAllBoxes();
 }
 private void UpdateAttributesData(ColumnProperties columnProperties)
 {
     AttributesNameText     = columnProperties.AttributesNameText;
     AttributesProfileText  = columnProperties.AttributesProfileText;
     AttributesMaterialText = columnProperties.AttributesMaterialText;
     AttributesFinishText   = columnProperties.AttributesFinishText;
     AttributesClassText    = columnProperties.AttributesClassText;
 }
예제 #15
0
        /// <summary>
        /// Creates the column properties.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="propertyNode">The property node.</param>
        /// <returns></returns>
        private static ColumnProperties CreateColumnProperties(IStyle style, XElement propertyNode)
        {
            ColumnProperties columnProperties = new ColumnProperties(style)
            {
                Node = propertyNode
            };

            return(columnProperties);
        }
예제 #16
0
        /// <summary>
        /// Gets numerical similarity by determing the weight of the distance between two values
        /// </summary>
        /// <param name="value"></param>
        /// <param name="value2"></param>
        /// <param name="columname"></param>
        /// <returns></returns>
        public static double getSim(double value, double value2, string columname)
        {
            ColumnProperties properties = TableProccessor.ColumnProperties[columname];
            double           h          = properties.max - properties.min;
            double           dist       = Math.Abs(value2 - value);

            //TODO take the distribution into account
            return(1.0 - (dist / h));
        }
예제 #17
0
        public MainWindow()
        {
            InitializeComponent();
            BeamProperties prop = (new StandardBeamPropertiesFactory()).CreateStandardProperties("ABC", 0, 0, "TOP", "MIDDLE", 0, "MIDDLE", 0, "", "", "");

            DummyBeamPropertyData(prop);
            ColumnProperties propColumn = (new StandardColumnPropertiesFactory()).CreateStandardProperties("EFG", 0, 0, 1000, 0, "TOP", "MIDDLE", 0, "MIDDLE", 0, "", "", "");

            DummyColumnProprtyData(propColumn);
        }
예제 #18
0
        private void initiate()
        {
            ColumnProperties p = new ColumnProperties();

            for (int i = 0; i < dataSetTable.Columns.Count; i++)
            {
                //fills the CheckCons of the list from the ConstraintTable
                string    TableColName    = "'" + Global.Curtable + dataSetTable.Columns[i].ColumnName + "'";
                DataRow[] CheckConstraint = Global.ConstraintTable.Select("TableColName = " + TableColName);
                if (CheckConstraint.Count() > 0)
                {
                    p.CheckCons = new List <string>(CheckConstraint[0][2].ToString().Split(','));
                }
                //MessageBox.Show(p.CheckCons.Count.ToString());
                /********************/

                designTable.Rows.Add(
                    dataSetTable.Columns[i].ColumnName,
                    dataSetTable.Columns[i].AllowDBNull,
                    dataSetTable.PrimaryKey.Contains(dataSetTable.Columns[i]),
                    dataSetTable.Columns[i].DataType.ToString().Remove(0, 7)
                    );


                p.IS_primKey  = dataSetTable.PrimaryKey.Contains(dataSetTable.Columns[i]);
                p.Allow_null  = dataSetTable.Columns[i].AllowDBNull;
                p.Column_Name = dataSetTable.Columns[i].ColumnName;
                p.Data_Type   = dataSetTable.Columns[i].DataType.ToString().Remove(0, 7);
                if (dataSetTable.Columns[i].AutoIncrement)
                {
                    p.step = int.Parse(dataSetTable.Columns[i].AutoIncrementStep.ToString());
                    p.seed = int.Parse(dataSetTable.Columns[i].AutoIncrementSeed.ToString());
                    if (dataSetTable.Columns[i].AutoIncrementStep < 0)
                    {
                        p.deCrement = true;
                        p.step      = -p.step;
                    }
                    else
                    {
                        p.inCrement = true;
                    }
                }
                p.Isunique      = dataSetTable.Columns[i].Unique;
                p.Length        = dataSetTable.Columns[i].MaxLength;
                p.default_Value = dataSetTable.Columns[i].DefaultValue.ToString();
                p.index         = i;
                //p.GetAllData();

                Properties.Add(p);
                p = new ColumnProperties();
            }

            //MessageBox.Show(p.Column_Name + "   " + Properties.Count.ToString());
        }
예제 #19
0
        private void DummyColumnProprtyData(ColumnProperties prop)
        {
            prop.AttributesProfileText = "RS";
            ColumnValuesGetter columnValuesGetter     = new ColumnValuesGetterImplementation();
            DialogColumnPropertiesViewModel viewModel = new DialogColumnPropertiesViewModel(new MemberModifierFactoryDummyImplementation(), prop, prop, columnValuesGetter);

            testColumn          = new DialogColumnProperties(viewModel);
            testColumn.Closing += TestColumn_Closing;
            testColumn.Show();
            this.Hide();
        }
예제 #20
0
    /// <summary>
    /// get all numerical qfs
    /// </summary>
    /// <param name="Workload"></param>
    /// <param name="columname"></param>
    public static void GetNumericalQf(SQLQuery[] Workload, string columname)
    {
        double           size            = TableProccessor.GetIntervalSize(columname);
        ColumnProperties properties      = TableProccessor.ColumnProperties[columname];
        List <SQLQuery>  relevantQueries = new List <SQLQuery>();
        int total = 0;

        foreach (var query in Workload)
        {
            if (query.requiredValues.ContainsKey(columname))//only relevant queries are being used
            {
                relevantQueries.Add(query);
                total += query.times;
            }
        }
        Dictionary <double, double> Qfs  = new Dictionary <double, double>();
        Dictionary <double, double> RQfs = new Dictionary <double, double>();
        double RQfMax = 0;

        for (double d /*bij het ontbijt*/ = properties.min; d <= properties.max; d += size)
        {
            double qf = getNumericalQFFromU(d, relevantQueries, columname, total);
            RQfs.Add(d, qf);
            if (Math.Abs(RQfMax) < qf)//also take possible negative values into account
            {
                RQfMax = qf;
            }
        }

        foreach (var Qf in RQfs)
        {
            double d;
            if (RQfMax == 0)//never queried
            {
                d = 1;
            }
            else
            {
                d = Qf.Value / RQfMax;
            }

            if (double.IsNaN(d))
            {
                throw new Exception("value is NaN in column: " + columname);
            }

            Qfs.Add(Qf.Key, d);
        }
        MetaDbFiller.AddQfMetaTable(columname, Qfs);

        relevantQueries = null;//memory cleanup
        GC.Collect();
    }
 private void GetButtonClick(object obj)
 {
     try
     {
         ColumnProperties columnProperties = columnValuesGetter.GetColumnProperties();
         UpdateViewModel(columnProperties);
     }
     catch (NotImplementedException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #22
0
 private TableColumnData(TableData table, string columnName, DbType dbType, int maxLength, ColumnProperties columnProperties, string defaultValue, string alias, QueryColumn foreignKeyColumn, IQueryableColumn localizedColumn)
 {
     this.table            = table;
     this.localizedColumn  = localizedColumn;
     this.foreignKeyColumn = foreignKeyColumn;
     this.alias            = alias;
     this.defaultValue     = defaultValue;
     this.columnProperties = columnProperties;
     this.dbType           = dbType;
     this.maxLength        = maxLength;
     this.columnName       = columnName;
 }
예제 #23
0
        private ColumnProperties getProperties(int rowIndex)
        {//gets the properties from the form fields
            if (rowIndex >= 0 && !dataGridView1.Rows[rowIndex].IsNewRow)
            {
                /*  assum that this values is from the form   */
                ColumnProperties p = new ColumnProperties();

                p.index = dataGridView1.CurrentCellAddress.Y;

                if (Convert.ToBoolean(dataGridView1.Rows[rowIndex].Cells[2].Value) == true)
                {
                    p.Allow_null = true;
                }

                p.IS_primKey = Convert.ToBoolean(dataGridView1.Rows[rowIndex].Cells[3].Value);

                if (this.DefVal_txt.Text != "")
                {
                    p.default_Value = this.DefVal_txt.Text.ToString();       //data type
                }
                p.Isunique = this.unique_check.Checked;

                p.inCrement = this.inc_dec_checkedList.GetItemChecked(0);
                p.deCrement = this.inc_dec_checkedList.GetItemChecked(1);
                if (this.inc_dec_txt.Text != "")
                {
                    p.step = int.Parse(this.inc_dec_txt.Text.ToString());   //int
                }
                if (this.Exp_txt.Text != "")
                {
                    string[] ls = this.Exp_txt.Text.ToString().Split('\n');
                    for (int i = 0; i < ls.Count(); i++)
                    {
                        p.CheckCons.Add(ls[i]);
                    }
                }



                if (this.len_txt.Text != "")
                {
                    p.Length = int.Parse(this.len_txt.Text.ToString());         //int
                }
                if (this.seed_txt.Text != "")
                {
                    p.seed = int.Parse(seed_txt.Text);
                }
                return(p);
            }

            return(null);
        }
예제 #24
0
        public DialogNeverRun(string entity)
        {
            InitializeComponent();
            BuildView        neverRunView;
            ColumnProperties columnProperties = new ColumnProperties();
            string           name;

            if (entity.ToLower() == "course")
            {
                name         = "Course";
                neverRunView = new BuildView()
                {
                    GridView            = DGV_DialogNeverRun,
                    TabledData          = cmd.CoursesNeverRun(),
                    DataGridViewColumns = new DataGridViewColumn[] {
                        columnProperties.courseCode,
                        columnProperties.courseName,
                        columnProperties.fee
                    }
                };
            }
            else if (entity.ToLower() == "subject")
            {
                name         = "Subject";
                neverRunView = new BuildView()
                {
                    GridView            = DGV_DialogNeverRun,
                    TabledData          = cmd.SubjectsNeverRun(),
                    DataGridViewColumns = new DataGridViewColumn[] {
                        columnProperties.subjectId,
                        columnProperties.subjectName
                    }
                };
            }
            else         // unit is default (entity.ToLower() == "unit")
            {
                name         = "Unit";
                neverRunView = new BuildView()
                {
                    GridView            = DGV_DialogNeverRun,
                    TabledData          = cmd.UnitsNeverRun(),
                    DataGridViewColumns = new DataGridViewColumn[] {
                        columnProperties.unitCode,
                        columnProperties.unitDescription
                    }
                };
            }
            neverRunView.Create();
            Text = string.Format("{0}s Never Run or Assigned", name);
            GRPBOX_NeverRun.Text           = string.Format("{0}s Never Run or Assigned", name);
            LBL_DialogNeverRunResults.Text = string.Format("{0} {1}(s)", neverRunView.ResultCount.ToString(), name);
        }
예제 #25
0
    /// <summary>
    /// gets all the idfs for numerical values
    /// </summary>
    /// <param name="columname"></param>
    /// <returns></returns>
    public static Dictionary <double, double> getIdfsForNumerical(string columname)
    {
        Dictionary <double, double> idfs = new Dictionary <double, double>();
        //grouped column values so the sqlite takes over the workload, might come at hand when extending this
        ColumnProperties properties = ColumnProperties[columname];

        for (double d = properties.min; d <= properties.max; d += TryGetIntervalSize(columname))
        {
            idfs.Add(d, GetNumeralIdf(columname, d));
        }

        return(idfs);
    }
        private void UpdatePositionData(ColumnProperties columnProperties)
        {
            SelectedDataInPositionVerticalComboBox = columnProperties.SelectedDataInPositionVerticalComboBox;
            PositionVerticalText = columnProperties.PositionVerticalText.ToString();

            SelectedDataInPositionRotationComboBox = columnProperties.SelectedDataInPositionRotationComboBox;
            PositionRotationText = columnProperties.PositionRotationText.ToString();

            SelectedDataInPositionHorizontalComboBox = columnProperties.SelectedDataInPositionHorizontalComboBox;
            PositionHorizontalText = columnProperties.PositionHorizontalText.ToString();

            PositionLevelsTop    = columnProperties.PositionLevelsTopText.ToString();
            PositionLevelsBottom = columnProperties.PositionLevelsBottomText.ToString();
        }
예제 #27
0
        private TreeListColumn addColumn(ColumnProperties columnProperties)
        {
            var col = historyTreeList.Columns.Add();

            col.Caption = columnProperties.Caption;
            col.OptionsColumn.AllowEdit = !columnProperties.IsReadOnly;

            //visible index can only be set when all columns have been added!
            if (!columnProperties.IsVisible)
            {
                col.VisibleIndex = -1;
            }
            return(col);
        }
예제 #28
0
        public ColumnPropertiesForm(ColumnProperties columnProperties)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.buttonCancel.Text = Res.Get(StringId.CancelButton);
            this.groupBoxSize.Text = Res.Get(StringId.Size);
            this.buttonOK.Text     = Res.Get(StringId.OKButtonText);
            this.Text = Res.Get(StringId.ColumnProperties);

            columnWidthControl.ColumnWidth       = columnProperties.Width;
            cellPropertiesControl.CellProperties = columnProperties.CellProperties;
        }
예제 #29
0
        public static ColumnProperties GetColumnSchema(DbUtilities dbConn, string sql)
        {
            ColumnProperties colProps      = new ColumnProperties();
            string           attributeType = "";
            string           table         = Common.GetTable(sql);
            string           select        = $"Select * from INFORMATION_SCHEMA.COLUMNS ";
            string           query         = $" where TABLE_NAME = '{table}'";
            DataTable        dt            = dbConn.GetDataTable(select, query);

            if (dt.Rows.Count == 0)
            {
                throw new ArgumentException("Table does not exist");
            }

            string[] sqlAttributes = Common.GetAttributes(sql);
            dt.CaseSensitive = false;

            foreach (string attribute in sqlAttributes)
            {
                string attributeIndex = attribute.Trim();
                query = $"COLUMN_NAME = '{attributeIndex}'";
                DataRow[] dtRows = dt.Select(query);
                if (dtRows.Length == 1)
                {
                    attributeType = dtRows[0]["DATA_TYPE"].ToString();
                    if (attributeType == "nvarchar")
                    {
                        string charLength = dtRows[0]["CHARACTER_MAXIMUM_LENGTH"].ToString();
                        attributeType = attributeType + "(" + charLength + ")";
                    }
                    else if (attributeType == "numeric")
                    {
                        string numericPrecision = dtRows[0]["NUMERIC_PRECISION"].ToString();
                        string numericScale     = dtRows[0]["NUMERIC_SCALE"].ToString();
                        attributeType = attributeType + "(" + numericPrecision + "," + numericScale + ")";
                    }
                }
                else
                {
                    //Console.WriteLine("Warning: attribute not found");
                }

                colProps[attributeIndex] = attributeType;
            }

            return(colProps);
        }
예제 #30
0
        // From Student Enrolments
        public DialogRegister(MainForm form, DataGridViewRow row)
        {
            InitializeComponent();

            // Add values to variables
            mainForm     = form;
            college      = row.Cells["CollegeName"].Value.ToString();
            semesterName = row.Cells["SemesterName"].Value.ToString();
            semesterKey  = new SemesterKey((int)row.Cells["SemesterKey"].Value);
            collegeId    = (int)row.Cells["CollegeId"].Value;

            LBL_DialogRegister_Name.Text             = "College:";
            LBL_DialogRegister_Value.Text            = college;
            LBL_DialogRegister_Semester.Text         = "Semester:";
            LBL_DialogRegister_SemesterValue.Text    = semesterName;
            LBL_DialogRegister_Semester.Visible      = true;
            LBL_DialogRegister_SemesterValue.Visible = true;

            // Create DataGridView
            ColumnProperties columnProperties = new ColumnProperties();
            BuildView        registerView     = new BuildView()
            {
                GridView            = DGV_DialogRegister,
                TabledData          = cmd.AllExceptRegisteredStudents(semesterKey.Key, collegeId),
                DataGridViewColumns = new DataGridViewColumn[] {
                    columnProperties.studentFirstName_Dialog,
                    columnProperties.studentLastName_Dialog,
                    columnProperties.studentEmail
                }
            };

            registerView.Create();

            // Sundry functions

            if (form.currentSemester.Key >= semesterKey.Key)
            {
                BTN_DialogRegisterAdd.Enabled  = false;
                LBL_DialogRegisterResults.Text = string.Format("Cannot register in the past {0} unregistered students(s)", registerView.ResultCount.ToString());
            }
            else
            {
                LBL_DialogRegisterResults.Text = string.Format("Select a student from {0} unregistered students(s)", registerView.ResultCount.ToString());
            }
        }
 public ColumnDefinition(string columnName, Type type, ColumnProperties columnProperties)
 {
     this.Name = columnName;
     this.Type = type;
     this.ColumnProperties = columnProperties;
 }
예제 #32
0
        private DataGridViewColumn GetNewColumnTemplate(ColumnProperties cp)
        {
            DataGridViewColumn c = (DataGridViewColumn)
                (_columnsDictionary[cp.TemplateID]).Clone();

            c.DisplayIndex = cp.DisplayIndex;
            c.DataPropertyName = cp.DataPropertyName;
            c.Name = cp.Name ?? cp.DataPropertyName;
            c.HeaderText = cp.HeaderText;
            c.DefaultCellStyle = DefaultCellStyle;
            c.HeaderCell.Style = ColumnHeadersDefaultCellStyle;
            return c;
        }
예제 #33
0
        public void SetDataSource(DataSet ds, string tableName, ColumnProperties[] columnProperties)
        {
            DataSource = ds;
            DataMember = tableName;

            SetColumnProperties(columnProperties);
        }
예제 #34
0
 private DataGridViewColumn AddNewColumnTemplate(ColumnProperties cp)
 {
     DataGridViewColumn newColumn = GetNewColumnTemplate(cp);
     Columns.Add(newColumn);
     return newColumn;
 }
예제 #35
0
        public void SetColumnProperties(ColumnProperties[] columnProperties)
        {
            foreach (DataGridViewColumn column in Columns)
            {
                column.Visible = false;
            }
            
            foreach (ColumnProperties cp in columnProperties)
            {

                DataGridViewColumn column = AddNewColumnTemplate(cp);
                
                if (Columns[cp.DataPropertyName].IsDataBound)
                    column.ValueType = Columns[cp.DataPropertyName].ValueType;

                column.Visible = true;
            }
        }
예제 #36
0
 public TableDefinition AddColumn(string columnName, Type type, ColumnProperties properties)
 {
     AddColumn(new ColumnDefinition(columnName, type, properties));
     return this;
 }