Ejemplo n.º 1
0
        public List <clscatprp> find_rec(Int32 catcod)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("findcat", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@catcod", SqlDbType.Int).Value = catcod;
            SqlDataReader    dr  = cmd.ExecuteReader();
            List <clscatprp> obj = new List <clscatprp>();

            if (dr.HasRows)
            {
                dr.Read();
                clscatprp k = new clscatprp();
                k.catcod = Convert.ToInt32(dr[0]);
                k.catnam = dr[1].ToString();
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }
Ejemplo n.º 2
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     nsquiz.clscat    obj    = new nsquiz.clscat();
     nsquiz.clscatprp objprp = new nsquiz.clscatprp();
     objprp.catnam = TextBox1.Text;
     obj.save_rec(objprp);
     GridView1.DataBind();
     TextBox1.Text = String.Empty;
 }
Ejemplo n.º 3
0
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     nsquiz.clscat    obj    = new nsquiz.clscat();
     nsquiz.clscatprp objprp = new nsquiz.clscatprp();
     objprp.catcod = Convert.ToInt32(GridView1.DataKeys[e.RowIndex][0]);
     objprp.catnam = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text;
     obj.update_rec(objprp);
     GridView1.EditIndex = -1;
     GridView1.DataBind();
     e.Cancel = true;
 }
Ejemplo n.º 4
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Int32 cod = Convert.ToInt32(GridView1.DataKeys[e.RowIndex][0]);

        nsquiz.clscat    obj    = new nsquiz.clscat();
        nsquiz.clscatprp objprp = new nsquiz.clscatprp();
        objprp.catcod = cod;
        obj.delete_rec(objprp);
        GridView1.DataBind();
        e.Cancel = true;
    }
Ejemplo n.º 5
0
        public void delete_rec(clscatprp p)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("delcat", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@catcod", SqlDbType.Int).Value = p.catcod;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
Ejemplo n.º 6
0
        public List <clscatprp> disp_rec()
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("displcat", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader    dr  = cmd.ExecuteReader();
            List <clscatprp> obj = new List <clscatprp>();

            while (dr.Read())
            {
                clscatprp k = new clscatprp();
                k.catcod = Convert.ToInt32(dr[0]);
                k.catnam = dr[1].ToString();
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }