private void loadDataToGrid() { string temp = "SELECT Lesson.Type, Lesson.ClassRoom,Lesson.LecturerID, Lesson.CourseID,Lesson.Day,Lesson.StrtTime,Lesson.EndTime ,Courses.CourseID,Courses.Name FROM Lesson INNER JOIN Courses ON Courses.CourseID=Lesson.CourseID ORDER BY Day"; SqlCommand cmd = new SqlCommand(temp, DB.Return_Connection()); try { SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { if (LctID == read["LecturerID"].ToString().Trim()) { ListViewItem items = new ListViewItem(read["Day"].ToString()); items.SubItems.Add(read["ClassRoom"].ToString()); items.SubItems.Add(read["Type"].ToString()); items.SubItems.Add(read["CourseID"].ToString().Trim()); items.SubItems.Add(read["Name"].ToString().Trim()); items.SubItems.Add(read["StrtTime"].ToString()); items.SubItems.Add(read["EndTime"].ToString()); listView1.Items.Add(items); } } read.Close(); read.Dispose(); } catch (DataException exp) { MessageBox.Show(exp.Message); } }
private void SearchBT_Click(object sender, EventArgs e) { int flag = 0; string txt = null; SqlCommand cmd = new SqlCommand("SELECT * FROM Stud_Requests", DB.Return_Connection()); try { SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { if (Id_TB.Text == read["Id"].ToString().Trim()) { txt = read["Reason"].ToString().Trim(); flag = 1; } } read.Dispose(); read.Close(); if (flag == 1 && txt != null) { DetailsTB.Text = txt; ReadName(); Check_Detail_To_Aprrove_Or_Deny(); } if (flag == 0) { MessageBox.Show("Id not found!"); } } catch (SqlException exp) { MessageBox.Show(exp.Message); } }
private void Populate() { DeleteLessonLV.Items.Clear(); SqlCommand cmd = new SqlCommand("SELECT * FROM Lesson ORDER BY CourseID", DB.Return_Connection()); try { SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { ListViewItem items = new ListViewItem(read["Type"].ToString()); items.SubItems.Add(read["ClassRoom"].ToString()); items.SubItems.Add(read["CourseID"].ToString()); items.SubItems.Add(read["LecturerID"].ToString()); items.SubItems.Add(read["Day"].ToString()); items.SubItems.Add(read["strtTime"].ToString()); items.SubItems.Add(read["EndTime"].ToString()); items.SubItems.Add(read["Numofstud"].ToString()); DeleteLessonLV.Items.Add(items); } read.Close(); read.Dispose(); } catch (Exception exp) { MessageBox.Show(exp.Message); } }