Пример #1
0
        private void FormShowData_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'studentManageDataSet1.student' table. You can move, or remove it, as needed.
            this.studentTableAdapter.Fill(this.studentManageDataSet1.student);
            this.studentTableAdapter.Fill(this.studentManageDataSet1.student);
            SqlCommand command = new SqlCommand("SELECT * FROM student");

            dataGridView1.ReadOnly = true;
            DataGridViewImageColumn picCol = new DataGridViewImageColumn();

            dataGridView1.RowTemplate.Height = 80;
            dataGridView1.DataSource         = stuf.getStudents(command);
            picCol             = (DataGridViewImageColumn)dataGridView1.Columns[7];
            picCol.ImageLayout = DataGridViewImageCellLayout.Stretch;
            dataGridView1.AllowUserToAddRows = false;
        }
 public void LoadGridByKey()
 {
     if (id_rabtn.Checked == true)
     {
         SqlCommand sqlcommand = new SqlCommand("Select * from student where StudentID LIKE '%" + SearchBar_txt.Text + "%'");
         show_datagv.DataSource = stuf.getStudents(sqlcommand);
     }
     else if (fName_rabtn.Checked == true)
     {
         SqlCommand sqlcommand = new SqlCommand("Select * from student where FirstName LIKE '%" + SearchBar_txt.Text + "%'");
         show_datagv.DataSource = stuf.getStudents(sqlcommand);
     }
     else
     {
         SqlCommand sqlcommand = new SqlCommand("Select * from student where LastName LIKE '%" + SearchBar_txt.Text + "%'");
         show_datagv.DataSource = stuf.getStudents(sqlcommand);
     }
 }
Пример #3
0
 // check điều kiện của radio button để load dữ liệu lên data grid view
 public void LoadByGender()
 {
     if (yes_rbtn.Checked)
     {
         DateTime start = time1_tp.Value;
         DateTime end   = time2_tp.Value;
         if (start > end)
         {
             DateTime temp = start;
             start = end;
             end   = temp;
         }
         if (male_rbtn.Checked)
         {
             SqlCommand command = new SqlCommand("SELECT * from student where DateOfBirth between @start and @end and gender = 'Male'");
             command.Parameters.Add("@start", SqlDbType.DateTime).Value = start;
             command.Parameters.Add("@end", SqlDbType.DateTime).Value   = end;
             info_dgv.DataSource = stuf.getStudents(command);
         }
         else if (fMale_rbtn.Checked)
         {
             SqlCommand command = new SqlCommand("SELECT * from student where DateOfBirth between @start and @end and gender = 'Female'");
             command.Parameters.Add("@start", SqlDbType.DateTime).Value = start;
             command.Parameters.Add("@end", SqlDbType.DateTime).Value   = end;
             info_dgv.DataSource = stuf.getStudents(command);
         }
         else
         {
             SqlCommand command = new SqlCommand("SELECT * from student where DateOfBirth between @start and @end");
             command.Parameters.Add("@start", SqlDbType.DateTime).Value = start;
             command.Parameters.Add("@end", SqlDbType.DateTime).Value   = end;
             info_dgv.DataSource = stuf.getStudents(command);
         }
     }
     else
     {
         if (allGender_rbtn.Checked)
         {
             SqlCommand command = new SqlCommand("SELECT * from student");
             info_dgv.DataSource = stuf.getStudents(command);
         }
         else if (fMale_rbtn.Checked)
         {
             SqlCommand command = new SqlCommand("SELECT * from student where gender = 'female'");
             info_dgv.DataSource = stuf.getStudents(command);
         }
         else
         {
             SqlCommand command = new SqlCommand("SELECT * from student where gender = 'male'");
             info_dgv.DataSource = stuf.getStudents(command);
         }
     }
 }