示例#1
0
        public List <clstbqstprp> find_rec(Int32 qstcode)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("findqst", con);

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

            if (dr.HasRows)
            {
                dr.Read();
                clstbqstprp k = new clstbqstprp();
                k.qstcode   = Convert.ToInt32(dr[0]);
                k.qstdsc    = dr[1].ToString();
                k.qstcatcod = Convert.ToInt32(dr[2]);
                k.qstlvl    = dr[2].ToString();
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }
示例#2
0
        public List <clstbqstprp> disp_rec(Int32 catcod, String lvl)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("dispqst", con);

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

            while (dr.Read())
            {
                clstbqstprp k = new clstbqstprp();
                k.qstcode   = Convert.ToInt32(dr[0]);
                k.qstdsc    = dr[1].ToString();
                k.qstcatcod = Convert.ToInt32(dr[2]);
                k.qstlvl    = dr[2].ToString();
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }
示例#3
0
        public void delete_rec(clstbqstprp p)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("delqst", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@qstcode", SqlDbType.Int).Value = p.qstcode;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
示例#4
0
        public void update_rec(clstbqstprp p)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("updateqst", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@qstcode", SqlDbType.Int).Value         = p.qstcode;
            cmd.Parameters.Add("@qstdsc", SqlDbType.VarChar, 100).Value = p.qstdsc;
            cmd.Parameters.Add("@qstcatcod", SqlDbType.Int).Value       = p.qstcatcod;
            cmd.Parameters.Add("@qstlvl", SqlDbType.VarChar, 50).Value  = p.qstlvl;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
    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");
    }
示例#6
0
        public Int32 save_rec(clstbqstprp p)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("insqst", con);

            cmd.CommandType = CommandType.StoredProcedure;
            // cmd.Parameters.Add("@qstcode", SqlDbType.Int).Value = p.qstcode;
            cmd.Parameters.Add("@qstdsc", SqlDbType.VarChar, 100).Value = p.qstdsc;
            cmd.Parameters.Add("@qstcacod", SqlDbType.Int).Value        = p.qstcatcod;
            cmd.Parameters.Add("@qstlvl", SqlDbType.VarChar, 50).Value  = p.qstlvl;
            cmd.Parameters.Add("@r", SqlDbType.Int).Direction           = ParameterDirection.ReturnValue;
            cmd.ExecuteNonQuery();
            Int32 a = Convert.ToInt32(cmd.Parameters["@r"].Value);

            cmd.Dispose();
            con.Close();
            return(a);
        }