public void ReloadListData() { SqlCommand command = new SqlCommand("SELECT * FROM Course", data.GetConnection); ListBoxControl.DataSource = course.GetCourse(command); ListBoxControl.ValueMember = "Id"; ListBoxControl.DisplayMember = "label"; ListBoxControl.SelectedItem = null; }
public void Showlist() { My_Database dataBase = new My_Database(); SqlCommand command = new SqlCommand( "SELECT FROM Course", dataBase.GetConnection); dataBase.Openconnection(); DataTable table = course.GetCourse(command); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command; DataSet dataSet = new DataSet(); adapter.Fill(dataSet, "Course"); ID_Course.Text = table.Rows[0]["Id"].ToString(); Name_Course.Text = table.Rows[0]["lable"].ToString(); Period.Text = table.Rows[0]["period"].ToString(); Rich_Description.Text = table.Rows[0]["description"].ToString(); }
private void WindowsUIButtonPanel1_ButtonChecked(object sender, ButtonEventArgs e) { SqlCommand command = new SqlCommand("SELECT * FROM Course", data.GetConnection); Courses course = new Courses(); string tag = ((WindowsUIButton)e.Button).Tag.ToString(); switch (tag) { case "E1": pos = 0; this.Showdata(pos); WindowsUIButton e1 = new WindowsUIButton();; e1.Checked = false; break; case "E2": if (pos > 0) { pos -= 1; this.Showdata(pos); } break; case "E3": if (pos < (course.GetCourse(command).Rows.Count - 1)) { pos += 1; this.Showdata(pos); } break; case "E4": pos = course.GetCourse(command).Rows.Count - 1; this.Showdata(pos); break; } }
public bool Find() { try { if (ID_Course_tb.Text.Trim() == "") { XtraMessageBox.Show("The textbox is blank, please enter ID you want to find", "Find Course", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } else { Courses course = new Courses(); My_Database dataBase = new My_Database(); SqlCommand command = new SqlCommand( "SELECT Id, label, period, description, semester FROM Course WHERE id = @ID", dataBase.GetConnection); command.Parameters.Add("@ID", SqlDbType.NVarChar).Value = ID_Course_tb.Text; dataBase.Openconnection(); DataTable table = course.GetCourse(command); if (table.Rows.Count > 0) { SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command; DataSet dataSet = new DataSet(); adapter.Fill(dataSet, "Course"); this.Show(); ID_Course_tb.Text = table.Rows[0]["Id"].ToString(); NameCourse_tb.Text = table.Rows[0]["label"].ToString(); Period_tb.Text = table.Rows[0]["period"].ToString(); Description.Text = table.Rows[0]["description"].ToString(); CheckedComboBox.Text = table.Rows[0]["semester"].ToString(); return(true); } else { return(false); } } } catch (Exception) { XtraMessageBox.Show("Not found this course", "Find Course", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } }