예제 #1
0
파일: ViewPin.aspx.cs 프로젝트: patih19/PMB
        protected void BtnLihat_Click(object sender, EventArgs e)
        {
            string CS = ConfigurationManager.ConnectionStrings["sm-untidar"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                con.Open();
                //SqlTransaction trans = con.BeginTransaction();

                SqlCommand CmdPIN = new SqlCommand("SpLihatPIN", con);
                //CmdPeriodik.Transaction = trans;
                CmdPIN.CommandType = System.Data.CommandType.StoredProcedure;
                CmdPIN.Parameters.AddWithValue("@no_tagihan", this.GVTerdaftar.Rows[0].Cells[1].Text);

                DataTable TblPendaftr = new DataTable();
                TblPendaftr.Columns.Add("Nomor Tagihan/Jurnal");
                TblPendaftr.Columns.Add("Nama");
                TblPendaftr.Columns.Add("PIN");

                using (SqlDataReader rdr = CmdPIN.ExecuteReader())
                {
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            DataRow datarow = TblPendaftr.NewRow();
                            datarow["Nomor Tagihan/Jurnal"] = rdr["no_tagihan"];
                            datarow["Nama"] = rdr["nama"];
                            datarow["PIN"]  = rdr["pin"];

                            TblPendaftr.Rows.Add(datarow);
                        }

                        this.PnlPIN.Enabled = true;
                        this.PnlPIN.Visible = true;

                        //Fill Gridview
                        this.GVPin.DataSource = TblPendaftr;
                        this.GVPin.DataBind();
                    }
                    else
                    {
                        //clear Gridview
                        TblPendaftr.Rows.Clear();
                        TblPendaftr.Clear();
                        GVPin.DataSource = TblPendaftr;
                        GVPin.DataBind();
                    }
                }
                CmdPIN.Dispose();

                // LihatFoto(this.Session["Name"].ToString());
            }
        }
예제 #2
0
파일: ViewPin.aspx.cs 프로젝트: patih19/PMB
        protected void GVTerdaftar_SelectedIndexChanged(object sender, EventArgs e)
        {
            // ------------- GET ROW INDEX --------------------
            // Get the currently selected row using the SelectedRow property.
            GridViewRow row = this.GVTerdaftar.SelectedRow;

            // Display the first name from the selected row.
            // In this example, the third column (index 1) contains
            // the first name.
            this.LbNoTagihan.Text = "Nomor Tagihan : " + row.Cells[1].Text;

            //-------------- View PIN --------------------
            string CS = ConfigurationManager.ConnectionStrings["sm-untidar"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                con.Open();
                //SqlTransaction trans = con.BeginTransaction();

                SqlCommand CmdPIN = new SqlCommand("SpLihatPIN", con);
                //CmdPeriodik.Transaction = trans;
                CmdPIN.CommandType = System.Data.CommandType.StoredProcedure;
                CmdPIN.Parameters.AddWithValue("@no_tagihan", row.Cells[1].Text);

                DataTable TblPendaftr = new DataTable();
                TblPendaftr.Columns.Add("Nomor Tagihan/Jurnal");
                TblPendaftr.Columns.Add("Nama");
                TblPendaftr.Columns.Add("PIN");

                using (SqlDataReader rdr = CmdPIN.ExecuteReader())
                {
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            DataRow datarow = TblPendaftr.NewRow();
                            datarow["Nomor Tagihan/Jurnal"] = rdr["no_tagihan"];
                            datarow["Nama"] = rdr["nama"];
                            datarow["PIN"]  = rdr["pin"];

                            TblPendaftr.Rows.Add(datarow);
                        }

                        this.PnlPIN.Enabled = true;
                        this.PnlPIN.Visible = true;

                        //Fill Gridview
                        this.GVPin.DataSource = TblPendaftr;
                        this.GVPin.DataBind();
                    }
                    else
                    {
                        //clear Gridview
                        TblPendaftr.Rows.Clear();
                        TblPendaftr.Clear();
                        GVPin.DataSource = TblPendaftr;
                        GVPin.DataBind();
                    }
                }
                CmdPIN.Dispose();
            }
        }