public List <clssciprp> Sci(Int32 cod) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("dissci", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@cod", SqlDbType.Int).Value = cod; SqlDataReader dr = cmd.ExecuteReader(); List <clssciprp> obj = new List <clssciprp>(); while (dr.Read()) { clssciprp k = new clssciprp(); k.scicod = Convert.ToInt32(dr[0]); k.scihed = dr[1].ToString(); k.scidis = dr[2].ToString(); k.scidis1 = dr[3].ToString(); k.scidis2 = dr[4].ToString(); k.sciimg = dr[5].ToString(); k.scicat = dr[6].ToString(); k.scidate = Convert.ToDateTime(dr[7]); k.sciautcod = Convert.ToInt32(dr[8]); obj.Add(k); } dr.Close(); cmd.Dispose(); con.Close(); return(obj); }
public void Sub_Sci(clssciprp p) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("inssci", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@cod", SqlDbType.Int).Value = p.scicod; cmd.Parameters.Add("@hed", SqlDbType.VarChar).Value = p.scihed; cmd.Parameters.Add("@dis", SqlDbType.NVarChar).Value = p.scidis; cmd.Parameters.Add("@dis1", SqlDbType.VarChar).Value = p.scidis1; cmd.Parameters.Add("@dis2", SqlDbType.VarChar).Value = p.scidis2; cmd.Parameters.Add("@img", SqlDbType.VarChar).Value = p.sciimg; cmd.Parameters.Add("@simg", SqlDbType.VarChar).Value = p.scisimg; cmd.Parameters.Add("@cat", SqlDbType.VarChar).Value = p.scicat; cmd.Parameters.Add("@date", SqlDbType.DateTime).Value = p.scidate; cmd.Parameters.Add("@aut", SqlDbType.Int).Value = p.sciautcod; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }