Пример #1
0
        /// <summary>
        /// Binds the SqlCeResultSet or DataSet to the controls in the UI
        /// </summary>
        private void BindData()
        {
            //Clear any existing bindings
            this.textBox1.DataBindings.Clear();
            this.textBox2.DataBindings.Clear();
            this.textBox3.DataBindings.Clear();
            this.textBox4.DataBindings.Clear();

            //Clear the text in the text boxes
            this.textBox1.Text = string.Empty;
            this.textBox2.Text = string.Empty;
            this.textBox3.Text = string.Empty;
            this.textBox4.Text = string.Empty;

            if (false == this.menuItemUseDataSet.Checked)
            {
                if (null == this.resultSet)
                {
                    MessageBox.Show("SQL Command has not been executed.Press execute button first");
                    return;
                }

                // Dispose previous views bound to the currently active RS
                //
                if (null != view1)
                {
                    ((IDisposable)view1).Dispose();
                }
                if (null != view2)
                {
                    ((IDisposable)view2).Dispose();
                }

                //Bind the data grid control
                this.view1 = this.resultSet.ResultSetView;

                //This array contains the ordinals of the columns displayed in the grid
                //Currently it is set to display only columns 1,3,5 and 8
                int[] ordinals = new int[] { 1, 3, 5, 8 };
                this.view1.Ordinals = ordinals;

                this.dataGrid.DataSource = view1;

                // Bind individual text boxes
                this.view2 = this.resultSet.ResultSetView;

                this.textBox1.DataBindings.Add(
                    "text", view2, resultSet.GetSqlMetaData(1).Name);

                this.textBox2.DataBindings.Add(
                    "text", view2, resultSet.GetSqlMetaData(3).Name);

                this.textBox3.DataBindings.Add(
                    "text", view2, resultSet.GetSqlMetaData(5).Name);

                this.textBox4.DataBindings.Add(
                    "text", view2, resultSet.GetSqlMetaData(8).Name);
            }
            else
            {
                if (null == this.table)
                {
                    MessageBox.Show("SQL Command has not been executed.Press execute button first");
                    return;
                }
                // Binding the DataGrid to the DefaultView of the DataTable
                this.dataGrid.DataSource = table.DefaultView;

                //Bind the individual text boxes
                this.textBox1.DataBindings.Add(
                    "text", table, table.Columns[0].ColumnName);

                this.textBox2.DataBindings.Add(
                    "text", table, table.Columns[1].ColumnName);

                this.textBox3.DataBindings.Add(
                    "text", table, table.Columns[2].ColumnName);

                this.textBox4.DataBindings.Add(
                    "text", table, table.Columns[3].ColumnName);
            }
        }
Пример #2
0
 public AttendanceController()
 {
     resultSetView = new ResultSetView();
     attendanceRepo = new AttendanceRepository();
 }