public Int32 UpdateTempCard(TempCardModel tm, int id) { using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("tempcard_update", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@tmpno", id); cmd.Parameters.AddWithValue("@empid", tm.empid); cmd.Parameters.AddWithValue("@cardid", tm.tempcardno); cmd.Parameters.AddWithValue("@isdel", tm.IsDeleted); cmd.Parameters.AddWithValue("@isactive", tm.IsActive); cmd.Parameters.AddWithValue("@modifiedby", tm.modifiedby); cmd.Parameters.AddWithValue("@modifiedon", tm.modifiedon); cmd.Parameters.Add("@ret", SqlDbType.Int); cmd.Parameters["@ret"].Direction = ParameterDirection.ReturnValue; con.Open(); // cmd.Parameters.Add("@id", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); Int32 k = Convert.ToInt32(cmd.Parameters["@ret"].Value); con.Close(); cmd.Dispose(); return(k); } }
public IEnumerable <TempCardModel> GetTempCardDetails() { List <TempCardModel> lstcard = new List <TempCardModel>(); using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("tempcard_display", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { TempCardModel tm = new TempCardModel(); tm.tempno = Convert.ToInt32(rdr[0]); tm.empid = Convert.ToInt32(rdr[1]); tm.tempcardno = Convert.ToInt32(rdr[2]); tm.IsDeleted = Convert.ToBoolean(rdr[3]); tm.IsActive = Convert.ToBoolean(rdr[4]); tm.addedby = rdr[5].ToString(); tm.addedon = Convert.ToDateTime(rdr[6]); tm.modifiedby = rdr[7].ToString(); tm.modifiedon = Convert.ToDateTime(rdr[8]); lstcard.Add(tm); } con.Close(); } return(lstcard); }