Exemplo n.º 1
0
        public List <clsoptprp> find_rec(Int32 qstcode)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("findans", con);

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

            if (dr.HasRows)
            {
                dr.Read();
                clsoptprp k = new clsoptprp();
                k.optcode    = Convert.ToInt32(dr[0]);
                k.optdsc     = dr[1].ToString();
                k.optqstcode = Convert.ToInt32(dr[2]);
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }
Exemplo n.º 2
0
        public void delete_rec(clsoptprp p)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("delopt", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@optcode", SqlDbType.Int).Value = p.optcode;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
Exemplo n.º 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        nsquiz.clstbqst    obj    = new nsquiz.clstbqst();
        nsquiz.clstbqstprp objprp = new nsquiz.clstbqstprp();
        objprp.qstcatcod = Convert.ToInt32(DropDownList1.SelectedValue);
        objprp.qstlvl    = DropDownList2.SelectedValue;
        objprp.qstdsc    = TextBox1.Text;
        // obj.save_rec(objprp);
        Int32 a = obj.save_rec(objprp);

        //code for answer
        nsquiz.clsopt    obj1    = new nsquiz.clsopt();
        nsquiz.clsoptprp objprp1 = new nsquiz.clsoptprp();
        objprp1.optqstcode = a;
        objprp1.optdsc     = TextBox2.Text;
        obj1.save_rec(objprp1);
        Response.Redirect("frmqst.aspx");
    }