Ejemplo n.º 1
0
        protected void DLRuangProdi_SelectedIndexChanged(object sender, EventArgs e)
        {
            string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                con.Open();
                SqlCommand CmdDosen = new SqlCommand("SELECT * FROM  bak_ruang WHERE id_prog_study=@id_prodi", con);
                CmdDosen.CommandType = System.Data.CommandType.Text;

                CmdDosen.Parameters.AddWithValue("@id_prodi", this.DLRuangProdi.SelectedValue);

                DataTable TableRuang = new DataTable();
                TableRuang.Columns.Add("No");
                TableRuang.Columns.Add("Ruang");
                TableRuang.Columns.Add("Kapasitas");


                using (SqlDataReader rdr = CmdDosen.ExecuteReader())
                {
                    if (rdr.HasRows)
                    {
                        this.PanelDetailRuang.Enabled = true;
                        this.PanelDetailRuang.Visible = true;

                        while (rdr.Read())
                        {
                            DataRow datarow = TableRuang.NewRow();
                            datarow["No"]        = rdr["no"];
                            datarow["Ruang"]     = rdr["nm_ruang"];
                            datarow["Kapasitas"] = rdr["kapasitas"];

                            TableRuang.Rows.Add(datarow);
                        }

                        //Fill Gridview
                        this.GVRuang.DataSource = TableRuang;
                        this.GVRuang.DataBind();
                    }
                    else
                    {
                        //clear Gridview
                        TableRuang.Rows.Clear();
                        TableRuang.Clear();
                        GVRuang.DataSource = TableRuang;
                        GVRuang.DataBind();

                        this.PanelDetailRuang.Enabled = false;
                        this.PanelDetailRuang.Visible = false;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void ListRuangByProdi()
        {
            string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                //-----------------------------------------List All Ruang Kuliah -------------------------------------------
                con.Open();
                SqlCommand CmdRuang = new SqlCommand("SpRuangByProdi", con);
                CmdRuang.CommandType = System.Data.CommandType.StoredProcedure;

                if (this.DLMasterProdi.SelectedValue == "00-000")
                {
                    // All Prodi
                    this.PanelDataRuang.Visible = true;
                    this.PanelDataRuang.Enabled = true;

                    this.PanelAddRuang.Visible = false;
                    this.PanelAddRuang.Enabled = false;

                    this.PanelEditRuang.Visible = false;
                    this.PanelEditRuang.Enabled = false;
                }
                else if (this.DLMasterProdi.SelectedValue == "-1")
                {
                    this.PanelDataRuang.Visible = false;
                    this.PanelDataRuang.Enabled = false;

                    this.PanelAddRuang.Visible = false;
                    this.PanelAddRuang.Enabled = false;

                    this.PanelEditRuang.Visible = false;
                    this.PanelEditRuang.Enabled = false;

                    return;
                }
                else
                {
                    // By Prodi
                    CmdRuang.Parameters.AddWithValue("@IdProdi", this.DLMasterProdi.SelectedValue);

                    this.PanelDataRuang.Visible = true;
                    this.PanelDataRuang.Enabled = true;

                    this.PanelAddRuang.Visible = false;
                    this.PanelAddRuang.Enabled = false;

                    this.PanelEditRuang.Visible = false;
                    this.PanelEditRuang.Enabled = false;
                }


                DataTable TableRuang = new DataTable();
                TableRuang.Columns.Add("No");
                TableRuang.Columns.Add("Id Ruang");
                TableRuang.Columns.Add("Ruang");
                TableRuang.Columns.Add("Kapasitas");
                TableRuang.Columns.Add("Program Studi");
                TableRuang.Columns.Add("Keterangan");

                using (SqlDataReader rdr = CmdRuang.ExecuteReader())
                {
                    if (rdr.HasRows)
                    {
                        this.PanelDataRuang.Visible = true;
                        this.PanelDataRuang.Enabled = true;

                        while (rdr.Read())
                        {
                            DataRow datarow = TableRuang.NewRow();
                            datarow["No"]            = rdr["nomor"];
                            datarow["Id Ruang"]      = rdr["no"];
                            datarow["Ruang"]         = rdr["nm_ruang"];
                            datarow["Kapasitas"]     = rdr["kapasitas"];
                            datarow["Program Studi"] = rdr["prog_study"];
                            if (rdr["status"].ToString() == "1")
                            {
                                datarow["Keterangan"] = "Aktif";
                            }
                            else
                            {
                                datarow["Keterangan"] = "Non Aktif";
                            }

                            TableRuang.Rows.Add(datarow);
                        }
                        //Fill Gridview
                        this.GVRuang.DataSource = TableRuang;
                        this.GVRuang.DataBind();
                    }
                    else
                    {
                        //clear Gridview
                        TableRuang.Rows.Clear();
                        TableRuang.Clear();
                        GVRuang.DataSource = TableRuang;
                        GVRuang.DataBind();
                    }
                }
            }
        }