protected void CbDosen_CheckedChanged(object sender, EventArgs e) { // Get Kode Mata Kuliah dan Mata Kuliah for (int i = 0; i < this.GVDosen.Rows.Count; i++) { CheckBox ch = (CheckBox)this.GVDosen.Rows[i].FindControl("CbDosen"); if (ch.Checked == true) { this.LbDosen.Text = this.GVDosen.Rows[i].Cells[2].Text; this.LbNidn.Text = this.GVDosen.Rows[i].Cells[1].Text; string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlCommand CmdJadwal = new SqlCommand("SPPesertaMakulDosen", con); CmdJadwal.CommandType = System.Data.CommandType.StoredProcedure; CmdJadwal.Parameters.AddWithValue("@dosen", this.GVDosen.Rows[i].Cells[2].Text); CmdJadwal.Parameters.AddWithValue("@nidn", this.GVDosen.Rows[i].Cells[1].Text); CmdJadwal.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue.ToString() + this.DlSemester.SelectedItem.Text); DataTable TableJadwal = new DataTable(); TableJadwal.Columns.Add("No Jadwal"); TableJadwal.Columns.Add("Kode"); TableJadwal.Columns.Add("Mata Kuliah"); TableJadwal.Columns.Add("Mengampu"); TableJadwal.Columns.Add("Kelas"); TableJadwal.Columns.Add("Jenis Kelas"); TableJadwal.Columns.Add("SKS"); TableJadwal.Columns.Add("Peserta"); using (SqlDataReader rdr = CmdJadwal.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { DataRow datarow = TableJadwal.NewRow(); datarow["No Jadwal"] = Convert.ToString(rdr["no_jadwal"]); datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["Mengampu"] = rdr["prog_study"]; datarow["Kelas"] = rdr["kelas"]; datarow["Jenis Kelas"] = rdr["jenis_kelas"]; datarow["SKS"] = rdr["sks"]; datarow["Peserta"] = rdr["jumlah"]; TableJadwal.Rows.Add(datarow); } //Fill Gridview this.GVAjar.DataSource = TableJadwal; this.GVAjar.DataBind(); } else { //clear Gridview TableJadwal.Rows.Clear(); TableJadwal.Clear(); GVAjar.DataSource = TableJadwal; GVAjar.DataBind(); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Jadwal Tidak Ditemukan');", true); } } } } } // Clear selected checkbox for (int i = 0; i < this.GVDosen.Rows.Count; i++) { CheckBox ch = (CheckBox)this.GVDosen.Rows[i].FindControl("CbDosen"); ch.Checked = false; } //Select Drop Down List to Default this.DLProdiDosen.SelectedIndex = 0; //hide panel this.PanelDetailDosen.Enabled = false; this.PanelDetailDosen.Visible = false; }
protected void DLProdiDosen_SelectedIndexChanged(object sender, EventArgs e) { if (this.DlSemester.SelectedValue == "Semester") { this.DLProdiDosen.SelectedIndex = 0; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Semester');", true); return; } string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlCommand CmdDosen = new SqlCommand("SpGetDosen", con); CmdDosen.CommandType = System.Data.CommandType.StoredProcedure; CmdDosen.Parameters.AddWithValue("@id_prodi", this.DLProdiDosen.SelectedValue); DataTable TableDosen = new DataTable(); TableDosen.Columns.Add("NIDN"); TableDosen.Columns.Add("Nama"); using (SqlDataReader rdr = CmdDosen.ExecuteReader()) { if (rdr.HasRows) { this.PanelDetailDosen.Enabled = true; this.PanelDetailDosen.Visible = true; while (rdr.Read()) { DataRow datarow = TableDosen.NewRow(); datarow["NIDN"] = rdr["nidn"]; datarow["Nama"] = rdr["nama"]; TableDosen.Rows.Add(datarow); } //Fill Gridview this.GVDosen.DataSource = TableDosen; this.GVDosen.DataBind(); //clear GVAjar TableDosen.Rows.Clear(); TableDosen.Clear(); GVAjar.DataSource = TableDosen; GVAjar.DataBind(); } else { //clear Gridview TableDosen.Rows.Clear(); TableDosen.Clear(); GVDosen.DataSource = TableDosen; GVDosen.DataBind(); this.PanelDetailDosen.Enabled = true; this.PanelDetailDosen.Visible = true; } } } }