public List <clsenterprp> Enter(Int32 cod) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("disenter", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@cod", SqlDbType.Int).Value = cod; SqlDataReader dr = cmd.ExecuteReader(); List <clsenterprp> obj = new List <clsenterprp>(); while (dr.Read()) { clsenterprp k = new clsenterprp(); k.entercod = Convert.ToInt32(dr[0]); k.enterhed = dr[1].ToString(); k.enterdis = dr[2].ToString(); k.enterdis1 = dr[3].ToString(); k.enterdis2 = dr[4].ToString(); k.enterimg = dr[5].ToString(); k.entercat = dr[6].ToString(); k.enterdate = Convert.ToDateTime(dr[7]); k.enterautcod = Convert.ToInt32(dr[8]); obj.Add(k); } dr.Close(); cmd.Dispose(); con.Close(); return(obj); }
public void Sub_Enter(clsenterprp p) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("insenter", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@cod", SqlDbType.Int).Value = p.entercod; cmd.Parameters.Add("@hed", SqlDbType.VarChar).Value = p.enterhed; cmd.Parameters.Add("@dis", SqlDbType.NVarChar).Value = p.enterdis; cmd.Parameters.Add("@dis1", SqlDbType.VarChar).Value = p.enterdis1; cmd.Parameters.Add("@dis2", SqlDbType.VarChar).Value = p.enterdis2; cmd.Parameters.Add("@img", SqlDbType.VarChar).Value = p.enterimg; cmd.Parameters.Add("@simg", SqlDbType.VarChar).Value = p.entersimg; cmd.Parameters.Add("@cat", SqlDbType.VarChar).Value = p.entercat; cmd.Parameters.Add("@date", SqlDbType.DateTime).Value = p.enterdate; cmd.Parameters.Add("@aut", SqlDbType.Int).Value = p.enterautcod; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }