protected void Button1_Click(object sender, EventArgs e) { nsskills.clsans obj = new nsskills.clsans(); nsskills.clsansprp objprp = new nsskills.clsansprp(); objprp.ansdsc = TextBox1.Text; objprp.ansqstcod = Convert.ToInt32(Request.QueryString["qcod"]); if (CheckBox1.Checked == true) { objprp.anssts = 'T'; } else { objprp.anssts = 'F'; } if (Button1.Text == "Submit") { obj.save_rec(objprp); } else { objprp.anscod = Convert.ToInt32(ViewState["cod"]); obj.upd_rec(objprp); Button1.Text = "Submit"; } TextBox1.Text = String.Empty; CheckBox1.Checked = false; GridView1.DataBind(); }
public List <clsansprp> fnd_rec(Int32 anscod) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("fndans", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@anscod", SqlDbType.Int).Value = anscod; SqlDataReader dr = cmd.ExecuteReader(); List <clsansprp> obj = new List <clsansprp>(); if (dr.HasRows) { dr.Read(); clsansprp x = new clsansprp(); x.anscod = Convert.ToInt32(dr[0]); x.ansqstcod = Convert.ToInt32(dr[1]); x.ansdsc = dr[2].ToString(); x.anssts = Convert.ToChar(dr[3]); obj.Add(x); } dr.Close(); cmd.Dispose(); con.Close(); return(obj); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { nsskills.clsans obj = new nsskills.clsans(); nsskills.clsansprp objprp = new nsskills.clsansprp(); objprp.anscod = Convert.ToInt32(GridView1.DataKeys[e.RowIndex][0]); obj.del_rec(objprp); GridView1.DataBind(); e.Cancel = true; }
public void del_rec(clsansprp p) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("delans", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@anscod", SqlDbType.Int).Value = p.anscod; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public void save_rec(clsansprp p) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("insans", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ansqstcod", SqlDbType.Int).Value = p.ansqstcod; cmd.Parameters.Add("@ansdsc", SqlDbType.NVarChar, 2000).Value = p.ansdsc; cmd.Parameters.Add("@anssts", SqlDbType.Char, 1).Value = p.anssts; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }