コード例 #1
0
        //helper method to update the data grid view
        private void UpdateDataGrid()
        {
            dataAdapter   = new SqlDataAdapter();
            dataTable     = new DataTable();
            bindingSource = new BindingSource();

            //call dal layer for records to update dgv
            DatagridDALProcessing dgvRecordCall = new DatagridDALProcessing();
            SqlCommand            cmd           = dgvRecordCall.GetDataDGBaseRecords();

            dataAdapter.SelectCommand = cmd;
            dataAdapter.Fill(dataTable);
            bindingSource.DataSource      = dataTable;
            dgvViewStudentList.DataSource = bindingSource;
        }
コード例 #2
0
 /*
  * Button (Delete) - Code behind for deleting a student of the Linking Table StudentCourseLT
  */
 private void btnDeleteStudent_Click(object sender, EventArgs e)
 {
     try
     {
         int delRecordid = (int)dgvViewStudentList.SelectedRows[0].Cells[0].Value;
         //call DAL processing class for the DB Delete
         DatagridDALProcessing delStudent = new DatagridDALProcessing();
         SqlCommand            cmd        = delStudent.DeleteEnrolledStudent(delRecordid);
         UpdateDataGrid();
     }
     catch (ArgumentOutOfRangeException ae)
     {
         MessageBox.Show("Please select a line to delete by clicking on it - No records to Delete until line is Selected", "System Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (FormatException fe)
     {
         MessageBox.Show("Something went wrong with the selection - Make Sure You Click on Record before clicking OK", "System Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #3
0
        /*
         * Load event from the dgv - student details for editing through vars to event
         * are taken by dgv student number, queried to DB and returned record passed to form
         */
        private void EditStudent_Load(object sender, EventArgs e)
        {
            int studentID = SearchStudentID;

            dataAdapter = new SqlDataAdapter();
            dataTable   = new DataTable();

            DatagridDALProcessing editRecord = new DatagridDALProcessing();
            SqlCommand            cmd        = editRecord.RetreiveStudentRecord(SearchStudentID);

            dataAdapter.SelectCommand = cmd;
            dataAdapter.Fill(dataTable);

            int    studentNumber = int.Parse(dataTable.Rows[0][0].ToString());
            string firstName     = dataTable.Rows[0][1].ToString();
            string lastName      = dataTable.Rows[0][2].ToString();
            string email         = dataTable.Rows[0][3].ToString();
            string phone         = dataTable.Rows[0][4].ToString();
            string addressLine1  = dataTable.Rows[0][5].ToString();
            string addressLine2  = dataTable.Rows[0][6].ToString();
            string city          = dataTable.Rows[0][7].ToString();
            string county        = dataTable.Rows[0][8].ToString();
            string level         = dataTable.Rows[0][9].ToString();

            ucUpdateRecordControl1.DisplayEditRecord.StudentNumber = studentID;
            ucUpdateRecordControl1.DisplayEditRecord.FirstName     = firstName;
            ucUpdateRecordControl1.DisplayEditRecord.Surname       = lastName;
            ucUpdateRecordControl1.DisplayEditRecord.Email         = email;
            ucUpdateRecordControl1.DisplayEditRecord.Phone         = phone;
            ucUpdateRecordControl1.DisplayEditRecord.AddressLine1  = addressLine1;
            ucUpdateRecordControl1.DisplayEditRecord.AddressLine2  = addressLine2;
            ucUpdateRecordControl1.DisplayEditRecord.City          = city;
            ucUpdateRecordControl1.DisplayEditRecord.County        = county;
            ucUpdateRecordControl1.DisplayEditRecord.Level         = level;
            //call LoadEditForm helper method
            LoadEditForm(studentID, firstName, lastName, addressLine1, addressLine2, email, phone, city, county, level);
        }