protected void BtnJadwal_Click(object sender, EventArgs e) { //set label thn & semester this.LbSmstr.Text = ""; this.LbThn.Text = ""; //form validation //if (this.DLProdi.SelectedItem.Text == "Program Studi") //{ // this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Program Studi');", true); // return; //} if (this.DLTahun.SelectedItem.Text == "Tahun" || this.DLTahun.SelectedItem.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Tahun Akademik');", true); return; } if (this.DlSemester.SelectedItem.Text == "Semester") { 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 CmdJadwal = new SqlCommand(@" SELECT bak_jadwal.no_jadwal, bak_jadwal.id_prog_study, bak_makul.kode_makul, bak_makul.makul, bak_makul.sks, bak_jadwal.quota, bak_dosen.nama, bak_jadwal.kelas, bak_jadwal.hari, bak_jadwal.jenis_kelas, bak_dosen.nidn, bak_jadwal.jm_awal_kuliah, bak_jadwal.jm_akhir_kuliah, bak_ruang.nm_ruang FROM bak_jadwal INNER JOIN bak_dosen ON bak_jadwal.nidn = bak_dosen.nidn INNER JOIN bak_makul ON bak_jadwal.kode_makul = bak_makul.kode_makul INNER JOIN bak_prog_study ON bak_jadwal.id_prog_study = bak_prog_study.id_prog_study INNER JOIN bak_ruang ON bak_jadwal.id_rng_kuliah = bak_ruang.no WHERE (bak_jadwal.id_prog_study = @id_prodi) AND (bak_jadwal.semester = @semester) ORDER BY bak_jadwal.no_jadwal ", con); CmdJadwal.CommandType = System.Data.CommandType.Text; CmdJadwal.Parameters.AddWithValue("@id_prodi", this.Session["level"].ToString()); CmdJadwal.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue.ToString() + this.DlSemester.SelectedItem.Text); DataTable TableJadwal = new DataTable(); TableJadwal.Columns.Add("Key"); TableJadwal.Columns.Add("Kode"); TableJadwal.Columns.Add("Mata Kuliah"); TableJadwal.Columns.Add("SKS"); TableJadwal.Columns.Add("Quota"); TableJadwal.Columns.Add("Dosen"); TableJadwal.Columns.Add("Kelas"); TableJadwal.Columns.Add("Hari"); TableJadwal.Columns.Add("Mulai"); TableJadwal.Columns.Add("Selesai"); TableJadwal.Columns.Add("Ruang"); TableJadwal.Columns.Add("Jenis Kelas"); using (SqlDataReader rdr = CmdJadwal.ExecuteReader()) { if (rdr.HasRows) { this.LbSmstr.Text = this.DlSemester.SelectedItem.Text; this.LbThn.Text = this.DLTahun.SelectedItem.Text; this.LbJadwalResult.Text = ""; this.PanelJadwal.Enabled = true; this.PanelJadwal.Visible = true; while (rdr.Read()) { DataRow datarow = TableJadwal.NewRow(); datarow["Key"] = rdr["no_jadwal"]; datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["SKS"] = rdr["sks"]; datarow["Quota"] = rdr["quota"]; datarow["Dosen"] = rdr["nama"]; datarow["Kelas"] = rdr["kelas"]; datarow["Hari"] = rdr["hari"]; datarow["Mulai"] = rdr["jm_awal_kuliah"]; datarow["Selesai"] = rdr["jm_akhir_kuliah"]; datarow["Ruang"] = rdr["nm_ruang"]; datarow["Jenis Kelas"] = rdr["jenis_kelas"]; TableJadwal.Rows.Add(datarow); } //Fill Gridview this.GVJadwal.DataSource = TableJadwal; this.GVJadwal.DataBind(); // hide panel Edit Mata Kuliah this.PanelEditJadwal.Enabled = false; this.PanelEditJadwal.Visible = false; } else { this.LbJadwalResult.Text = "Jadwal Belum Ada "; this.LbJadwalResult.ForeColor = System.Drawing.Color.Blue; // hide panel Edit Mata Kuliah this.PanelEditJadwal.Enabled = false; this.PanelEditJadwal.Visible = false; //clear Gridview TableJadwal.Rows.Clear(); TableJadwal.Clear(); GVJadwal.DataSource = TableJadwal; GVJadwal.DataBind(); } } } }
protected void BtnUpdate_Click(object sender, EventArgs e) { //Form Validation if (this.lbno_jadwal.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('id jadwal does not set correctly');", true); return; } if (this.LbProdi.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Program Studi');", true); return; } if (this.LbKodeMakul.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Mata Kuliah');", true); return; } if (this.LbNidn.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Dosen Pengampu');", true); return; } if (this.DLKelas.SelectedItem.Text == "Kelas") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Pembagian Kelas Mahasiswa');", true); return; } if (this.DLHari.SelectedItem.Text == "Hari") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Hari Kuliah');", true); return; } if (this.TbMulai.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Jam Mulai Perkuliahan');", true); return; } if (this.TbSelesai.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Jam Selesai Perkuliahan');", true); return; } if (this.TbRuang.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Ruang Perkuliahan');", true); return; } if (this.DLJenisKelas.SelectedItem.Text == "Jenis Kelas") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Jenis Kelas Mahasiswa');", true); return; } if (this.TbQuota.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Quota / Kapasitas Mahasiswa');", true); return; } if (this.DLTahun.SelectedItem.Text == "Tahun" || this.DLTahun.SelectedItem.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Tahun');", true); return; } if (this.DLSemester.SelectedItem.Text == "Semester") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Semester');", true); return; } try { // SpInJadwalKuliah string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlCommand CmdInJadwal = new SqlCommand("SpUpJadwalKuliah", con); CmdInJadwal.CommandType = System.Data.CommandType.StoredProcedure; CmdInJadwal.Parameters.AddWithValue("@no_jadwal", this.lbno_jadwal.Text); CmdInJadwal.Parameters.AddWithValue("@id_prodi", this.LbProdi.Text); CmdInJadwal.Parameters.AddWithValue("@kode_makul", this.LbKodeMakul.Text); CmdInJadwal.Parameters.AddWithValue("@nidn", this.LbNidn.Text); CmdInJadwal.Parameters.AddWithValue("@kelas", this.DLKelas.SelectedItem.Text); CmdInJadwal.Parameters.AddWithValue("@jenis_kelas", this.DLJenisKelas.SelectedItem.Text); CmdInJadwal.Parameters.AddWithValue("@hari", this.DLHari.SelectedItem.Text); CmdInJadwal.Parameters.AddWithValue("@jam_mulai", this.TbMulai.Text); CmdInJadwal.Parameters.AddWithValue("@jam_selesai", this.TbSelesai.Text); CmdInJadwal.Parameters.AddWithValue("@ruang", this.TbRuang.Text); CmdInJadwal.Parameters.AddWithValue("@quota", this.TbQuota.Text); CmdInJadwal.Parameters.AddWithValue("@semester", this.DLTahun.SelectedItem.Text + this.DLSemester.SelectedItem.Text); CmdInJadwal.ExecuteNonQuery(); this.lbno_jadwal.Text = ""; //BtnJadwal_Click(this, null); //this.PanelEditJadwal.Enabled = false; //this.PanelEditJadwal.Visible = false; this.PanelUpdate.Enabled = false; this.PanelUpdate.Visible = false; this.PanelTambah.Enabled = true; this.PanelTambah.Visible = true; // ------------------ Reload DGV ------------------------ SqlCommand CmdJadwal = new SqlCommand("SpListJadwal", con); CmdJadwal.CommandType = System.Data.CommandType.StoredProcedure; CmdJadwal.Parameters.AddWithValue("@id_prodi", this.Session["level"].ToString()); CmdJadwal.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue.ToString() + this.DLSemester.SelectedItem.Text); DataTable TableJadwal = new DataTable(); TableJadwal.Columns.Add("Key"); TableJadwal.Columns.Add("Kode"); TableJadwal.Columns.Add("Mata Kuliah"); TableJadwal.Columns.Add("SKS"); TableJadwal.Columns.Add("Quota"); TableJadwal.Columns.Add("Dosen"); TableJadwal.Columns.Add("Kelas"); TableJadwal.Columns.Add("Hari"); TableJadwal.Columns.Add("Mulai"); TableJadwal.Columns.Add("Selesai"); TableJadwal.Columns.Add("Ruang"); TableJadwal.Columns.Add("Jenis Kelas"); using (SqlDataReader rdr = CmdJadwal.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { DataRow datarow = TableJadwal.NewRow(); datarow["Key"] = rdr["no_jadwal"]; datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["SKS"] = rdr["sks"]; datarow["Quota"] = rdr["quota"]; datarow["Dosen"] = rdr["nama"]; datarow["Kelas"] = rdr["kelas"]; datarow["Hari"] = rdr["hari"]; datarow["Mulai"] = rdr["jam_mulai"]; datarow["Selesai"] = rdr["jam_selesai"]; datarow["Ruang"] = rdr["ruang"]; datarow["Jenis Kelas"] = rdr["jenis_kelas"]; TableJadwal.Rows.Add(datarow); } //Fill Gridview this.GVJadwal.DataSource = TableJadwal; this.GVJadwal.DataBind(); // hide panel Edit Mata Kuliah } else { //clear Gridview TableJadwal.Rows.Clear(); TableJadwal.Clear(); GVJadwal.DataSource = TableJadwal; GVJadwal.DataBind(); } } this.PanelMakul.Enabled = true; this.PanelMakul.Visible = true; // ------------------ Clear Data ----------------- LbProdi.Text = ""; LbKodeMakul.Text = ""; LbMakul.Text = ""; DLProdiMakul.SelectedIndex = 0; LbNidn.Text = ""; LbDosen.Text = ""; DLProdiDosen.SelectedIndex = 0; DLKelas.SelectedIndex = 0; DLHari.SelectedIndex = 0; TbMulai.Text = ""; TbSelesai.Text = ""; TbRuang.Text = ""; DLJenisKelas.SelectedIndex = 0; TbQuota.Text = ""; DLTahun.SelectedIndex = 0; DLSemester.SelectedIndex = 0; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Input Berhasil');", true); } } catch (Exception ex) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('" + ex.Message.ToString() + "');", true); return; } }
protected void BtnSave_Click(object sender, EventArgs e) { //Form Validation if (this.LbProdi.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Program Studi');", true); return; } if (this.LbKodeMakul.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Mata Kuliah');", true); return; } if (this.LbNidn.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Dosen Pengampu');", true); return; } if (this.DLKelas.SelectedItem.Text == "Kelas") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Pembagian Kelas Mahasiswa');", true); return; } if (this.DLHari.SelectedItem.Text == "Hari") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Hari Kuliah');", true); return; } if (this.TbMulai.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Jam Mulai Perkuliahan');", true); return; } if (this.TbSelesai.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Jam Selesai Perkuliahan');", true); return; } //if (this.TbRuang.Text == "") //{ // this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Ruang Perkuliahan');", true); // return; //} if (this.LbRuang.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Ruang Perkuliahan');", true); return; } if (this.DLJenisKelas.SelectedItem.Text == "Jenis Kelas") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Jenis Kelas Mahasiswa');", true); return; } if (this.TbQuota.Text == "") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Quota / Kapasitas Mahasiswa');", true); return; } try { // SpInJadwalKuliah string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlCommand CmdInJadwal = new SqlCommand("SpInJadwalKuliah", con); CmdInJadwal.CommandType = System.Data.CommandType.StoredProcedure; CmdInJadwal.Parameters.AddWithValue("@id_prodi", this.LbProdi.Text); CmdInJadwal.Parameters.AddWithValue("@kode_makul", this.LbKodeMakul.Text); CmdInJadwal.Parameters.AddWithValue("@nidn", this.LbNidn.Text); CmdInJadwal.Parameters.AddWithValue("@kelas", this.DLKelas.SelectedItem.Text); CmdInJadwal.Parameters.AddWithValue("@jenis_kelas", this.DLJenisKelas.SelectedItem.Text); CmdInJadwal.Parameters.AddWithValue("@hari", this.DLHari.SelectedItem.Text); CmdInJadwal.Parameters.AddWithValue("@jam_mulai", this.TbMulai.Text); CmdInJadwal.Parameters.AddWithValue("@jam_selesai", this.TbSelesai.Text); //CmdInJadwal.Parameters.AddWithValue("@ruang", this.TbRuang.Text); CmdInJadwal.Parameters.AddWithValue("@id_ruang", this.LbNo.Text); CmdInJadwal.Parameters.AddWithValue("@quota", this.TbQuota.Text); CmdInJadwal.Parameters.AddWithValue("@semester", this.Session["Semester"].ToString().Trim()); CmdInJadwal.ExecuteNonQuery(); // ------------- Display Jadwal ---------------------------- SqlCommand CmdJadwal = new SqlCommand(@" SELECT bak_jadwal.no_jadwal, bak_jadwal.id_prog_study, bak_makul.kode_makul, bak_makul.makul, bak_makul.sks, bak_jadwal.quota, bak_dosen.nama, bak_jadwal.kelas, bak_jadwal.hari, bak_jadwal.jenis_kelas, bak_dosen.nidn, bak_jadwal.jm_awal_kuliah, bak_jadwal.jm_akhir_kuliah, bak_ruang.nm_ruang FROM bak_jadwal INNER JOIN bak_dosen ON bak_jadwal.nidn = bak_dosen.nidn INNER JOIN bak_makul ON bak_jadwal.kode_makul = bak_makul.kode_makul INNER JOIN bak_prog_study ON bak_jadwal.id_prog_study = bak_prog_study.id_prog_study INNER JOIN bak_ruang ON bak_jadwal.id_rng_kuliah = bak_ruang.no WHERE (bak_jadwal.id_prog_study = @id_prodi) AND (bak_jadwal.semester = @semester) AND (bak_makul.makul_univ = 'yes') ORDER BY bak_jadwal.no_jadwal" , con); CmdJadwal.CommandType = System.Data.CommandType.Text; CmdJadwal.Parameters.AddWithValue("@id_prodi", this.Session["level"].ToString()); CmdJadwal.Parameters.AddWithValue("@semester", this.Session["Semester"].ToString().Trim()); DataTable TableJadwal = new DataTable(); TableJadwal.Columns.Add("Key"); TableJadwal.Columns.Add("Kode"); TableJadwal.Columns.Add("Mata Kuliah"); TableJadwal.Columns.Add("SKS"); TableJadwal.Columns.Add("Quota"); TableJadwal.Columns.Add("Dosen"); TableJadwal.Columns.Add("Kelas"); TableJadwal.Columns.Add("Hari"); TableJadwal.Columns.Add("Mulai"); TableJadwal.Columns.Add("Selesai"); TableJadwal.Columns.Add("Ruang"); TableJadwal.Columns.Add("Jenis Kelas"); using (SqlDataReader rdr = CmdJadwal.ExecuteReader()) { if (rdr.HasRows) { //this.LbSmstr.Text = this.DlSemester.SelectedItem.Text; //this.LbThn.Text = this.DLTahun.SelectedItem.Text; //this.LbJadwalResult.Text = ""; //this.PanelJadwal.Enabled = true; //this.PanelJadwal.Visible = true; while (rdr.Read()) { DataRow datarow = TableJadwal.NewRow(); datarow["Key"] = rdr["no_jadwal"]; datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["SKS"] = rdr["sks"]; datarow["Quota"] = rdr["quota"]; datarow["Dosen"] = rdr["nama"]; datarow["Kelas"] = rdr["kelas"]; datarow["Hari"] = rdr["hari"]; datarow["Mulai"] = rdr["jm_awal_kuliah"]; datarow["Selesai"] = rdr["jm_akhir_kuliah"]; datarow["Ruang"] = rdr["nm_ruang"]; datarow["Jenis Kelas"] = rdr["jenis_kelas"]; TableJadwal.Rows.Add(datarow); } //Fill Gridview this.GVJadwal.DataSource = TableJadwal; this.GVJadwal.DataBind(); //hide panel Edit Mata Kuliah //this.PanelEditJadwal.Enabled = false; //this.PanelEditJadwal.Visible = false; } else { //this.LbJadwalResult.Text = "Jadwal Belum Ada "; //this.LbJadwalResult.ForeColor = System.Drawing.Color.Blue; // hide panel Edit Mata Kuliah //this.PanelEditJadwal.Enabled = false; //this.PanelEditJadwal.Visible = false; //clear Gridview TableJadwal.Rows.Clear(); TableJadwal.Clear(); GVJadwal.DataSource = TableJadwal; GVJadwal.DataBind(); } } // ------------------ Clear Data ----------------- LbProdi.Text = ""; LbKodeMakul.Text = ""; LbMakul.Text = ""; DLProdiMakul.SelectedIndex = 0; LbNidn.Text = ""; LbDosen.Text = ""; DLProdiDosen.SelectedIndex = 0; DLKelas.SelectedIndex = 0; DLHari.SelectedIndex = 0; TbMulai.Text = ""; TbSelesai.Text = ""; this.LbRuang.Text = ""; this.LbNo.Text = ""; DLJenisKelas.SelectedIndex = 0; TbQuota.Text = ""; //this.PanelRuangAktif.Enabled = false; //this.PanelRuangAktif.Visible = false; //if (this.Session["Semester"] != null) //{ // this.Session["Semester"] = (object)null; // this.Session.Remove("Semester"); //} this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Input Berhasil');", true); } } catch (Exception ex) { string message = "alert('" + ex.Message + "')"; ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true); //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('" + ex.Message.ToString() + "');", true); //return; } }
protected void BtnJadwal_Click(object sender, EventArgs e) { //set label thn & semester this.LbSmstr.Text = ""; this.LbThn.Text = ""; //form validation if (this.DLProdi.SelectedValue == "-1") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Program Studi');", true); return; } if (this.DLTahun.SelectedItem.Text == "Tahun") { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Tahun Akademik');", true); return; } if (this.DlSemester.SelectedItem.Text == "Semester") { 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 CmdJadwal = new SqlCommand("SPPesertaMakul2B", con); CmdJadwal.CommandType = System.Data.CommandType.StoredProcedure; CmdJadwal.Parameters.AddWithValue("@idprodi", this.DLProdi.SelectedValue); CmdJadwal.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue.ToString() + this.DlSemester.SelectedItem.Text); DataTable TableJadwal = new DataTable(); TableJadwal.Columns.Add("Key"); TableJadwal.Columns.Add("Kode"); TableJadwal.Columns.Add("Mata Kuliah"); TableJadwal.Columns.Add("SKS"); TableJadwal.Columns.Add("Dosen"); TableJadwal.Columns.Add("Kelas"); TableJadwal.Columns.Add("Hari"); TableJadwal.Columns.Add("Mulai"); TableJadwal.Columns.Add("Selesai"); TableJadwal.Columns.Add("Ruang"); TableJadwal.Columns.Add("Jenis Kelas"); TableJadwal.Columns.Add("Quota"); TableJadwal.Columns.Add("Peserta"); using (SqlDataReader rdr = CmdJadwal.ExecuteReader()) { if (rdr.HasRows) { this.LbSmstr.Text = this.DlSemester.SelectedItem.Text; this.LbThn.Text = this.DLTahun.SelectedItem.Text; this.LbJadwalResult.Text = ""; this.PanelJadwal.Enabled = true; this.PanelJadwal.Visible = true; while (rdr.Read()) { DataRow datarow = TableJadwal.NewRow(); datarow["Key"] = rdr["no_jadwal"]; datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["SKS"] = rdr["sks"]; datarow["Dosen"] = rdr["nama"]; datarow["Kelas"] = rdr["kelas"]; datarow["Hari"] = rdr["hari"]; datarow["Mulai"] = rdr["jm_awal_kuliah"]; datarow["Selesai"] = rdr["jm_akhir_kuliah"]; datarow["Ruang"] = rdr["nm_ruang"]; datarow["Jenis Kelas"] = rdr["jenis_kelas"]; datarow["Quota"] = rdr["quota"]; datarow["Peserta"] = rdr["jumlah"]; TableJadwal.Rows.Add(datarow); } //Fill Gridview this.GVJadwal.DataSource = TableJadwal; this.GVJadwal.DataBind(); // hide panel Edit Mata Kuliah this.PanelEditJadwal.Enabled = false; this.PanelEditJadwal.Visible = false; } else { this.LbJadwalResult.Text = "Jadwal Belum Ada "; this.LbJadwalResult.ForeColor = System.Drawing.Color.Blue; // hide panel Edit Mata Kuliah this.PanelEditJadwal.Enabled = false; this.PanelEditJadwal.Visible = false; //clear Gridview TableJadwal.Rows.Clear(); TableJadwal.Clear(); GVJadwal.DataSource = TableJadwal; GVJadwal.DataBind(); } } } }
protected void DLUjian_SelectedIndexChanged(object sender, EventArgs e) { //form validation if (this.DLUjian.SelectedValue == "Jenis Ujian") { this.DLUjian.SelectedIndex = 0; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Tahun Akademik');", true); return; } if (this.DLTahun.SelectedValue == "Tahun") { this.DLUjian.SelectedIndex = 0; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Tahun Akademik');", true); return; } if (this.DLSemester.SelectedValue == "Semester") { this.DLUjian.SelectedIndex = 0; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Semester');", true); return; } if (this.DLUjian.SelectedValue == "Jenis Ujian") { this.DLUjian.SelectedIndex = 0; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Jenis Ujian');", true); return; } string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { //// ----------------- Jadwal UTS ------------------------ //// if (this.DLUjian.SelectedValue == "uts") { //----- Read Jadwal ---- con.Open(); //SqlCommand CmdJadwalUTS = new SqlCommand("SpJadwalUTS", con); SqlCommand CmdJadwalUTS = new SqlCommand("SpJadwalUTS2", con); CmdJadwalUTS.CommandType = System.Data.CommandType.StoredProcedure; CmdJadwalUTS.Parameters.AddWithValue("@id_prodi", this.Session["level"].ToString()); CmdJadwalUTS.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue.ToString() + this.DLSemester.SelectedItem.Text); DataTable TableJadwalUTS = new DataTable(); TableJadwalUTS.Columns.Add("Key"); TableJadwalUTS.Columns.Add("Kode"); TableJadwalUTS.Columns.Add("Mata Kuliah"); TableJadwalUTS.Columns.Add("NIDN"); TableJadwalUTS.Columns.Add("Dosen"); TableJadwalUTS.Columns.Add("Kelas"); TableJadwalUTS.Columns.Add("Hari"); TableJadwalUTS.Columns.Add("Tanggal"); TableJadwalUTS.Columns.Add("Mulai"); TableJadwalUTS.Columns.Add("Selesai"); TableJadwalUTS.Columns.Add("Ruang"); TableJadwalUTS.Columns.Add("Jenis Kelas"); using (SqlDataReader rdr = CmdJadwalUTS.ExecuteReader()) { if (rdr.HasRows) { this.PanelMakul.Enabled = true; this.PanelMakul.Visible = true; this.LbIdProdi.Text = this.Session["level"].ToString(); this.LbProdi.Text = this.Session["Prodi"].ToString(); while (rdr.Read()) { DataRow datarow = TableJadwalUTS.NewRow(); datarow["Key"] = rdr["no_jadwal"]; datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["NIDN"] = rdr["nidn"]; datarow["Dosen"] = rdr["nama"]; datarow["Kelas"] = rdr["kelas"]; datarow["Hari"] = rdr["hari_uts"]; if (rdr["tgl_uts"] == DBNull.Value) { } else { DateTime TglUjian = Convert.ToDateTime(rdr["tgl_uts"]); datarow["Tanggal"] = TglUjian.ToString("dd-MMMM-yyyy"); } datarow["Mulai"] = rdr["jam_mulai_uts"]; datarow["Selesai"] = rdr["jam_sls_uts"]; datarow["Ruang"] = rdr["ruang_uts"]; datarow["Jenis Kelas"] = rdr["jenis_kelas"]; TableJadwalUTS.Rows.Add(datarow); } //Fill Gridview this.GVJadwal.DataSource = TableJadwalUTS; this.GVJadwal.DataBind(); } else { this.DLUjian.SelectedIndex = 0; //clear Gridview TableJadwalUTS.Rows.Clear(); TableJadwalUTS.Clear(); GVJadwal.DataSource = TableJadwalUTS; GVJadwal.DataBind(); this.PanelMakul.Enabled = false; this.PanelMakul.Visible = false; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Jadwal Belum Ada');", true); } } } //// ----------------- Jadwal UAS ------------------------ //// else if (this.DLUjian.SelectedValue == "uas") { //----- Read Jadwal ---- con.Open(); SqlCommand CmdJadwalUTS = new SqlCommand("SpJadwalUAS2", con); CmdJadwalUTS.CommandType = System.Data.CommandType.StoredProcedure; CmdJadwalUTS.Parameters.AddWithValue("@id_prodi", this.Session["level"].ToString()); CmdJadwalUTS.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue.ToString() + this.DLSemester.SelectedItem.Text); DataTable TableJadwalUTS = new DataTable(); TableJadwalUTS.Columns.Add("Key"); TableJadwalUTS.Columns.Add("Kode"); TableJadwalUTS.Columns.Add("Mata Kuliah"); TableJadwalUTS.Columns.Add("NIDN"); TableJadwalUTS.Columns.Add("Dosen"); TableJadwalUTS.Columns.Add("Kelas"); TableJadwalUTS.Columns.Add("Hari"); TableJadwalUTS.Columns.Add("Tanggal"); TableJadwalUTS.Columns.Add("Mulai"); TableJadwalUTS.Columns.Add("Selesai"); TableJadwalUTS.Columns.Add("Ruang"); TableJadwalUTS.Columns.Add("Jenis Kelas"); using (SqlDataReader rdr = CmdJadwalUTS.ExecuteReader()) { if (rdr.HasRows) { this.PanelMakul.Enabled = true; this.PanelMakul.Visible = true; this.LbIdProdi.Text = this.Session["level"].ToString(); this.LbProdi.Text = this.Session["Prodi"].ToString(); while (rdr.Read()) { DataRow datarow = TableJadwalUTS.NewRow(); datarow["Key"] = rdr["no_jadwal"]; datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["NIDN"] = rdr["nidn"]; datarow["Dosen"] = rdr["nama"]; datarow["Kelas"] = rdr["kelas"]; datarow["Hari"] = rdr["hari_uas"]; if (rdr["tgl_uas"] == DBNull.Value) { } else { DateTime TglUjian = Convert.ToDateTime(rdr["tgl_uas"]); datarow["Tanggal"] = TglUjian.ToString("dd-MMMM-yyyy"); } datarow["Mulai"] = rdr["jam_mulai_uas"]; datarow["Selesai"] = rdr["jam_sls_uas"]; datarow["Ruang"] = rdr["ruang_uas"]; datarow["Jenis Kelas"] = rdr["jenis_kelas"]; TableJadwalUTS.Rows.Add(datarow); } //Fill Gridview this.GVJadwal.DataSource = TableJadwalUTS; this.GVJadwal.DataBind(); } else { this.DLUjian.SelectedIndex = 0; //clear Gridview TableJadwalUTS.Rows.Clear(); TableJadwalUTS.Clear(); GVJadwal.DataSource = TableJadwalUTS; GVJadwal.DataBind(); this.PanelMakul.Enabled = false; this.PanelMakul.Visible = false; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Jadwal Belum Ada');", true); } } } } }
protected void BtnDownoad_Click(object sender, EventArgs e) { if (this.RbUTS.Checked) { string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { try { con.Open(); // -------------------- Cek Update Biodata --------------------- SqlCommand CmdCekBiodata = new SqlCommand("select npm,perbarui from bak_mahasiswa where npm=@npm", con); //CmdCekBiodata.Transaction = trans; CmdCekBiodata.CommandType = System.Data.CommandType.Text; CmdCekBiodata.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); using (SqlDataReader RdrBiodata = CmdCekBiodata.ExecuteReader()) { if (RdrBiodata.HasRows) { while (RdrBiodata.Read()) { if (RdrBiodata["perbarui"].ToString() != "Y") { Response.Redirect("~/account/UpdateBiodata.aspx"); } } } } //---------------------- Validasi Download --------------------- SqlCommand CmdCekMasa = new SqlCommand("SpCekDownloadUTS", con); //CmdCekMasa.Transaction = trans; CmdCekMasa.CommandType = System.Data.CommandType.StoredProcedure; CmdCekMasa.Parameters.AddWithValue("@semester", this.DLTahun.SelectedItem.Text + this.DLSemester.Text); CmdCekMasa.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); CmdCekMasa.ExecuteNonQuery(); // --------------------- Enable Panel ------------------------ this.PanelJadwal.Enabled = true; this.PanelJadwal.Visible = true; // --------------------- Fill Gridview UTS Makul ------------------------ SqlCommand CmdListUTS = new SqlCommand("SpListUTS", con); CmdListUTS.CommandType = System.Data.CommandType.StoredProcedure; CmdListUTS.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); CmdListUTS.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue + this.DLSemester.SelectedValue); DataTable TableUTSMakul = new DataTable(); TableUTSMakul.Columns.Add("Kode"); TableUTSMakul.Columns.Add("Mata kuliah"); TableUTSMakul.Columns.Add("SKS"); TableUTSMakul.Columns.Add("Tanggal Ujian"); //TableUTSMakul.Columns.Add("Tanda Tangan"); using (SqlDataReader rdr = CmdListUTS.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { DataRow datarow = TableUTSMakul.NewRow(); datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["SKS"] = rdr["sks"]; //--- format tanggal --- if (rdr["tgl_uts"] == DBNull.Value) { } else { DateTime TglUjian = Convert.ToDateTime(rdr["tgl_uts"]); datarow["Tanggal Ujian"] = TglUjian.ToString("dd-MMMM-yyyy"); } TableUTSMakul.Rows.Add(datarow); } //Fill Gridview this.GVJadwal.DataSource = TableUTSMakul; this.GVJadwal.DataBind(); } else { //clear Gridview TableUTSMakul.Rows.Clear(); TableUTSMakul.Clear(); GVJadwal.DataSource = TableUTSMakul; GVJadwal.DataBind(); } } //------------------------- GV UTS JADWAL --------------------- SqlCommand CmdUTSJadwal = new SqlCommand("SpListUTS", con); CmdUTSJadwal.CommandType = System.Data.CommandType.StoredProcedure; CmdUTSJadwal.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); CmdUTSJadwal.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue + this.DLSemester.SelectedValue); DataTable TableUTSJadwal = new DataTable(); TableUTSJadwal.Columns.Add("Hari"); TableUTSJadwal.Columns.Add("Mata Kuliah"); TableUTSJadwal.Columns.Add("Dosen"); TableUTSJadwal.Columns.Add("Mulai"); TableUTSJadwal.Columns.Add("Selesai"); TableUTSJadwal.Columns.Add("Ruang"); using (SqlDataReader rdr = CmdUTSJadwal.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { DataRow datarow2 = TableUTSJadwal.NewRow(); datarow2["Hari"] = rdr["hari_uts"]; datarow2["Mata Kuliah"] = rdr["makul"]; datarow2["Mulai"] = rdr["jam_mulai_uts"]; datarow2["Selesai"] = rdr["jam_sls_uts"]; datarow2["Ruang"] = rdr["ruang_uts"]; datarow2["Dosen"] = rdr["nama"]; TableUTSJadwal.Rows.Add(datarow2); } //Fill Gridview this.GVJadwalDetail.DataSource = TableUTSJadwal; this.GVJadwalDetail.DataBind(); } else { //clear Gridview TableUTSJadwal.Rows.Clear(); TableUTSJadwal.Clear(); GVJadwalDetail.DataSource = TableUTSJadwal; GVJadwalDetail.DataBind(); } } //SqlCommand CmdCekMasa = new SqlCommand("SpCekDownloadUTS", con); ////CmdCekMasa.Transaction = trans; //CmdCekMasa.CommandType = System.Data.CommandType.StoredProcedure; //CmdCekMasa.Parameters.AddWithValue("@semester", this.DLTahun.SelectedItem.Text + this.DLSemester.Text); //CmdCekMasa.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); //CmdCekMasa.ExecuteNonQuery(); ////Server.Transfer("~/am/KartuUTS.aspx", true); //DoDownloadKartuUTS("Kartu_UTS-" + this.Session["Name"].ToString() + "-" + DLTahun.SelectedItem.Text + DLSemester.SelectedItem.Text); } catch (Exception ex) { this.PanelJadwal.Enabled = false; this.PanelJadwal.Visible = false; this.DLSemester.SelectedIndex = 0; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('" + ex.Message.ToString() + "');", true); //string message = "alert('" + ex.Message.ToString() + "')"; //ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true); } } } else if (this.RbUAS.Checked) { string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { try { con.Open(); // -------------------- Cek Update Biodata --------------------- SqlCommand CmdCekBiodata = new SqlCommand("select npm,perbarui from bak_mahasiswa where npm=@npm", con); //CmdCekBiodata.Transaction = trans; CmdCekBiodata.CommandType = System.Data.CommandType.Text; CmdCekBiodata.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); using (SqlDataReader RdrBiodata = CmdCekBiodata.ExecuteReader()) { if (RdrBiodata.HasRows) { while (RdrBiodata.Read()) { if (RdrBiodata["perbarui"].ToString() != "Y") { Response.Redirect("~/account/UpdateBiodata.aspx"); } } } } // ------------------------ Validasi Download ------------------------- SqlCommand CmdCekMasa = new SqlCommand("SpCekDownloadUAS", con); //CmdCekMasa.Transaction = trans; CmdCekMasa.CommandType = System.Data.CommandType.StoredProcedure; CmdCekMasa.Parameters.AddWithValue("@semester", this.DLTahun.SelectedItem.Text + this.DLSemester.Text); CmdCekMasa.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); CmdCekMasa.ExecuteNonQuery(); // --------------------- Enable Panel ------------------------ this.PanelJadwal.Enabled = true; this.PanelJadwal.Visible = true; // --------------------- Fill Gridview UAS Makul ------------------------ SqlCommand CmdListUAS = new SqlCommand("SpListUAS", con); CmdListUAS.CommandType = System.Data.CommandType.StoredProcedure; CmdListUAS.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); CmdListUAS.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue + this.DLSemester.SelectedValue); DataTable TableUASMakul = new DataTable(); TableUASMakul.Columns.Add("Kode"); TableUASMakul.Columns.Add("Mata kuliah"); TableUASMakul.Columns.Add("SKS"); TableUASMakul.Columns.Add("Tanggal Ujian"); //TableUASMakul.Columns.Add("Tanda Tangan"); using (SqlDataReader rdr = CmdListUAS.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { DataRow datarow = TableUASMakul.NewRow(); datarow["Kode"] = rdr["kode_makul"]; datarow["Mata Kuliah"] = rdr["makul"]; datarow["SKS"] = rdr["sks"]; //--- format tanggal --- if (rdr["tgl_uas"] == DBNull.Value) { } else { DateTime TglUjian = Convert.ToDateTime(rdr["tgl_uas"]); datarow["Tanggal Ujian"] = TglUjian.ToString("dd-MMMM-yyyy"); } TableUASMakul.Rows.Add(datarow); } //Fill Gridview this.GVJadwal.DataSource = TableUASMakul; this.GVJadwal.DataBind(); } else { //clear Gridview TableUASMakul.Rows.Clear(); TableUASMakul.Clear(); GVJadwal.DataSource = TableUASMakul; GVJadwal.DataBind(); } } //------------------------- GV UAS JADWAL --------------------- SqlCommand CmdUASJadwal = new SqlCommand("SpListUAS", con); CmdUASJadwal.CommandType = System.Data.CommandType.StoredProcedure; CmdUASJadwal.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); CmdUASJadwal.Parameters.AddWithValue("@semester", this.DLTahun.SelectedValue + this.DLSemester.SelectedValue); DataTable TableUASJadwal = new DataTable(); TableUASJadwal.Columns.Add("Hari"); TableUASJadwal.Columns.Add("Mata Kuliah"); TableUASJadwal.Columns.Add("Dosen"); TableUASJadwal.Columns.Add("Mulai"); TableUASJadwal.Columns.Add("Selesai"); TableUASJadwal.Columns.Add("Ruang"); using (SqlDataReader rdr = CmdUASJadwal.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { DataRow datarow2 = TableUASJadwal.NewRow(); datarow2["Hari"] = rdr["hari_uas"]; datarow2["Mata Kuliah"] = rdr["makul"]; datarow2["Mulai"] = rdr["jam_mulai_uas"]; datarow2["Selesai"] = rdr["jam_sls_uas"]; datarow2["Ruang"] = rdr["ruang_uas"]; datarow2["Dosen"] = rdr["nama"]; TableUASJadwal.Rows.Add(datarow2); } //Fill Gridview this.GVJadwalDetail.DataSource = TableUASJadwal; this.GVJadwalDetail.DataBind(); } else { //clear Gridview TableUASJadwal.Rows.Clear(); TableUASJadwal.Clear(); GVJadwalDetail.DataSource = TableUASJadwal; GVJadwalDetail.DataBind(); } } // SqlCommand CmdCekMasa = new SqlCommand("SpCekDownloadUAS", con); // //CmdCekMasa.Transaction = trans; // CmdCekMasa.CommandType = System.Data.CommandType.StoredProcedure; // CmdCekMasa.Parameters.AddWithValue("@semester", this.DLTahun.SelectedItem.Text + this.DLSemester.Text); // CmdCekMasa.Parameters.AddWithValue("@npm", this.Session["Name"].ToString()); // CmdCekMasa.ExecuteNonQuery(); //// Server.Transfer("~/am/KartuUAS.aspx", true); // DoDownloadKartuUAS("Kartu_UAS-" + this.Session["Name"].ToString() + "-" + DLTahun.SelectedItem.Text + DLSemester.SelectedItem.Text); } catch (Exception ex) { this.PanelJadwal.Enabled = false; this.PanelJadwal.Visible = false; this.DLSemester.SelectedIndex = 0; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('" + ex.Message.ToString() + "');", true); //string message = "alert('" + ex.Message.ToString() + "')"; //ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true); } } } }