Exemplo n.º 1
0
        private void LoadGVStatus(int PageIndex, int PageSize)
        {
            // TAHUN ANGKATAN
            if (this.TbAngkatan.Text == string.Empty)
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Isi Tahun Angkatan');", true);
                return;
            }

            // PRODI
            if (this.DLProdi.SelectedValue == "-1")
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Pilih Program Studi');", true);
                return;
            }

            //// ---------------- Mahasiswa CUTI/DO/DOUBLE DEGREE/KELUAR/NON-AKTIF ----------------
            int    TotalRows = 0;
            string CS        = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                con.Open();
                // --------------------- Fill Gridview  ------------------------
                SqlCommand CmdLls = new SqlCommand("GetMhsByStatus2", con);
                CmdLls.CommandType = System.Data.CommandType.StoredProcedure;

                CmdLls.Parameters.AddWithValue("@index", PageIndex);
                CmdLls.Parameters.AddWithValue("@size", this.GVMhs.PageSize);
                CmdLls.Parameters.AddWithValue("@idprodi", this.DLProdi.SelectedValue);
                CmdLls.Parameters.AddWithValue("@angkatan", this.TbAngkatan.Text);

                if (this.DLStatus.SelectedValue != "-1")
                {
                    if (this.DLStatus.SelectedValue != "All")
                    {
                        SqlParameter StatusParam = new SqlParameter("@status", this.DLStatus.SelectedValue);
                        CmdLls.Parameters.Add(StatusParam);
                    }
                }

                if (this.DLSex.SelectedValue != "-1")
                {
                    SqlParameter GenderParam = new SqlParameter("@gender", this.DLSex.SelectedItem.Text);
                    CmdLls.Parameters.Add(GenderParam);
                }

                if (this.DLReligi.SelectedValue != "-1")
                {
                    SqlParameter AgamaParam = new SqlParameter("@agama", this.DLReligi.SelectedValue);
                    CmdLls.Parameters.Add(AgamaParam);
                }

                // -------- FILTER PROV DAN KABUPATEN -----//
                // -------- FILTER KABUPATEN SAJA TIDAK DISEDIAKAN ------ //

                if (this.DLProv.SelectedItem.Text != string.Empty)
                {
                    // --- Filter By Provinsi dan Kabupaten --- //
                    if (this.DLKotaKab.SelectedItem.Text != string.Empty)
                    {
                        // validasi kriteria pencarian
                        if ((this.PilihanKotaKab.SelectedValue != "=" && this.PilihanKotaKab.SelectedValue != "!=") && (this.PilihanProv.SelectedValue != "=" && this.PilihanProv.SelectedValue != "!="))
                        {
                            con.Close();
                            con.Dispose();

                            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('PILIH JENIS PENCARIAN');", true);
                            return;
                        }

                        SqlParameter ProvParam = new SqlParameter("@provinsi", this.DLProv.SelectedItem.Text);
                        CmdLls.Parameters.Add(ProvParam);

                        SqlParameter KotaKabParam = new SqlParameter("@kotakab", this.DLKotaKab.SelectedItem.Text);
                        CmdLls.Parameters.Add(KotaKabParam);

                        SqlParameter VarProv = new SqlParameter("@varprov", this.PilihanProv.SelectedValue);
                        CmdLls.Parameters.Add(VarProv);

                        SqlParameter VarKotaKab = new SqlParameter("@varkota", this.PilihanKotaKab.SelectedValue);
                        CmdLls.Parameters.Add(VarKotaKab);
                    }
                    // --- Filter By Provinsi Saja --- //
                    else
                    {
                        // validasi kriteria pencarian
                        if (this.PilihanProv.SelectedValue != "=" && this.PilihanProv.SelectedValue != "!=")
                        {
                            con.Close();
                            con.Dispose();

                            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('PILIH JENIS PENCARIAN PROVINSI');", true);
                            return;
                        }

                        SqlParameter ProvParam = new SqlParameter("@provinsi", this.DLProv.SelectedItem.Text);
                        CmdLls.Parameters.Add(ProvParam);

                        SqlParameter VarProv = new SqlParameter("@varprov", this.PilihanProv.SelectedValue);
                        CmdLls.Parameters.Add(VarProv);
                    }
                }
                // Filter Biasa (Tanpa Provinsi dan atau Kota/Kab)
                else
                {
                }

                SqlParameter TotalRow = new SqlParameter();
                TotalRow.ParameterName = "@totalRow";
                TotalRow.SqlDbType     = System.Data.SqlDbType.Int;
                TotalRow.Size          = 20;
                TotalRow.Direction     = System.Data.ParameterDirection.Output;
                CmdLls.Parameters.Add(TotalRow);

                DataTable TableKRS = new DataTable();
                TableKRS.Columns.Add("No");
                TableKRS.Columns.Add("NPM");
                TableKRS.Columns.Add("Nama");
                TableKRS.Columns.Add("Program Studi");
                TableKRS.Columns.Add("Tahun Angkatan");
                TableKRS.Columns.Add("Jenis Kelas");
                TableKRS.Columns.Add("Status");

                using (SqlDataReader rdr = CmdLls.ExecuteReader())
                {
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            DataRow datarow = TableKRS.NewRow();
                            datarow["No"]             = rdr["urutan"];
                            datarow["NPM"]            = rdr["npm"];
                            datarow["Nama"]           = rdr["nama"];
                            datarow["Program Studi"]  = rdr["prog_study"];
                            datarow["Tahun Angkatan"] = rdr["thn_angkatan"];
                            datarow["Jenis Kelas"]    = rdr["kelas"];

                            //----- status ------
                            string st = rdr["status"].ToString();
                            if (rdr["status"].ToString() == "A")
                            {
                                datarow["STATUS"] = "AKTIF";
                            }
                            else if (rdr["status"].ToString() == "C")
                            {
                                datarow["STATUS"] = "CUTI";
                            }
                            else if (rdr["status"].ToString() == "D")
                            {
                                datarow["STATUS"] = "DROP-OUT";
                            }
                            else if (rdr["status"].ToString() == "G")
                            {
                                datarow["STATUS"] = "DOUBLE DEGREE";
                            }
                            else if (rdr["status"].ToString() == "K")
                            {
                                datarow["STATUS"] = "KELUAR";
                            }
                            else if (rdr["status"].ToString() == "N")
                            {
                                datarow["STATUS"] = "NON-AKTIF";
                            }
                            else if (rdr["status"].ToString() == "L")
                            {
                                datarow["STATUS"] = "LULUS";
                            }

                            TableKRS.Rows.Add(datarow);
                        }

                        rdr.Close();
                        TotalRows = (int)CmdLls.Parameters["@totalRow"].Value;

                        //this.DLKelas.SelectedIndex = 0;

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

                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('Data Tidak Ditemukan');", true);
                    }
                }
            }

            //paging
            DataBindRepeater(PageIndex, this.GVMhs.PageSize, TotalRows);
        }
Exemplo n.º 2
0
        private void LoadGridViewProdi(int PageIndex, int PageSize)
        {
            int TotalRows = 0;

            string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                con.Open();
                // --------------------- Fill Gridview  ------------------------
                SqlCommand CmdKRS = new SqlCommand("SpMhsByProdi", con);
                CmdKRS.CommandType = System.Data.CommandType.StoredProcedure;

                CmdKRS.Parameters.AddWithValue("@index", PageIndex);
                CmdKRS.Parameters.AddWithValue("@size", this.GVMhs.PageSize);
                CmdKRS.Parameters.AddWithValue("@idprodi", this.DLProdi.SelectedValue);
                CmdKRS.Parameters.AddWithValue("@status", this.LbKetSelect.Text);

                SqlParameter TotalRow = new SqlParameter();
                TotalRow.ParameterName = "@totalRow";
                TotalRow.SqlDbType     = System.Data.SqlDbType.Int;
                TotalRow.Size          = 20;
                TotalRow.Direction     = System.Data.ParameterDirection.Output;
                CmdKRS.Parameters.Add(TotalRow);

                DataTable TableKRS = new DataTable();
                TableKRS.Columns.Add("No");
                TableKRS.Columns.Add("NPM");
                TableKRS.Columns.Add("NAMA");
                TableKRS.Columns.Add("PROGRAM STUDI");
                TableKRS.Columns.Add("TAHUN ANGKATAN");
                TableKRS.Columns.Add("JENIS KELAS");
                TableKRS.Columns.Add("STATUS");

                using (SqlDataReader rdr = CmdKRS.ExecuteReader())
                {
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            DataRow datarow = TableKRS.NewRow();
                            datarow["No"]             = rdr["urutan"];
                            datarow["NPM"]            = rdr["npm"];
                            datarow["NAMA"]           = rdr["nama"];
                            datarow["PROGRAM STUDI"]  = rdr["prog_study"];
                            datarow["TAHUN ANGKATAN"] = rdr["thn_angkatan"];
                            datarow["JENIS KELAS"]    = rdr["kelas"];

                            //----- status ------
                            string st = rdr["status"].ToString();
                            if (rdr["status"].ToString() == "A")
                            {
                                datarow["STATUS"] = "AKTIF";
                            }
                            else if (rdr["status"].ToString() == "C")
                            {
                                datarow["STATUS"] = "CUTI";
                            }
                            else if (rdr["status"].ToString() == "D")
                            {
                                datarow["STATUS"] = "DROP-OUT";
                            }
                            else if (rdr["status"].ToString() == "G")
                            {
                                datarow["STATUS"] = "DOUBLE DEGREE";
                            }
                            else if (rdr["status"].ToString() == "K")
                            {
                                datarow["STATUS"] = "KELUAR";
                            }
                            else if (rdr["status"].ToString() == "N")
                            {
                                datarow["STATUS"] = "NON-AKTIF";
                            }

                            TableKRS.Rows.Add(datarow);
                        }

                        rdr.Close();
                        TotalRows = (int)CmdKRS.Parameters["@totalRow"].Value;

                        //this.DLKelas.SelectedIndex = 0;

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

            //paging
            DataBindRepeater(PageIndex, this.GVMhs.PageSize, TotalRows);
        }
Exemplo n.º 3
0
        private void LoadGridViewNama(int PageIndex, int PageSize)
        {
            //validation
            if (this.TbSrcNama2.Text != string.Empty)
            {
                if (this.TbSrcNama2.Text.Length < 4)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('ISI NAMA LEBIH DARI 4 HURUF');", true);
                    return;
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('NPM/NAMA HARUS DIISI');", true);
                return;
            }


            int TotalRows = 0;

            string CS = ConfigurationManager.ConnectionStrings["MainDb"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                con.Open();
                // --------------------- Fill Gridview  ------------------------
                SqlCommand CmdKRS = new SqlCommand("SpMhsByNamaNpm", con);
                CmdKRS.CommandType = System.Data.CommandType.StoredProcedure;

                CmdKRS.Parameters.AddWithValue("@index", PageIndex);
                CmdKRS.Parameters.AddWithValue("@size", this.GVMhs.PageSize);
                CmdKRS.Parameters.AddWithValue("@nama", this.TbSrcNama2.Text);

                SqlParameter TotalRow = new SqlParameter();
                TotalRow.ParameterName = "@totalRow";
                TotalRow.SqlDbType     = System.Data.SqlDbType.Int;
                TotalRow.Size          = 20;
                TotalRow.Direction     = System.Data.ParameterDirection.Output;
                CmdKRS.Parameters.Add(TotalRow);

                DataTable TableKRS = new DataTable();
                TableKRS.Columns.Add("No");
                TableKRS.Columns.Add("NPM");
                TableKRS.Columns.Add("NAMA");
                TableKRS.Columns.Add("PROGRAM STUDI");
                TableKRS.Columns.Add("TAHUN ANGKATAN");
                TableKRS.Columns.Add("JENIS KELAS");
                TableKRS.Columns.Add("STATUS");

                using (SqlDataReader rdr = CmdKRS.ExecuteReader())
                {
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            DataRow datarow = TableKRS.NewRow();
                            datarow["No"]             = rdr["urutan"];
                            datarow["NPM"]            = rdr["npm"];
                            datarow["NAMA"]           = rdr["nama"];
                            datarow["PROGRAM STUDI"]  = rdr["prog_study"];
                            datarow["TAHUN ANGKATAN"] = rdr["thn_angkatan"];
                            datarow["JENIS KELAS"]    = rdr["kelas"];

                            //----- status ------
                            string st = rdr["status"].ToString();
                            if (rdr["status"].ToString() == "A")
                            {
                                datarow["STATUS"] = "AKTIF";
                            }
                            else if (rdr["status"].ToString() == "C")
                            {
                                datarow["STATUS"] = "CUTI";
                            }
                            else if (rdr["status"].ToString() == "D")
                            {
                                datarow["STATUS"] = "DROP-OUT";
                            }
                            else if (rdr["status"].ToString() == "G")
                            {
                                datarow["STATUS"] = "DOUBLE DEGREE";
                            }
                            else if (rdr["status"].ToString() == "K")
                            {
                                datarow["STATUS"] = "KELUAR";
                            }
                            else if (rdr["status"].ToString() == "N")
                            {
                                datarow["STATUS"] = "NON-AKTIF";
                            }
                            else if (rdr["status"].ToString() == "L")
                            {
                                datarow["STATUS"] = "LULUS";
                            }

                            TableKRS.Rows.Add(datarow);
                        }

                        rdr.Close();
                        TotalRows = (int)CmdKRS.Parameters["@totalRow"].Value;

                        //this.DLKelas.SelectedIndex = 0;

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

            //paging
            DataBindRepeater(PageIndex, this.GVMhs.PageSize, TotalRows);
        }