public tier_req Select(int id) { tier_req tier_req = new tier_req(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_TIER_REQ", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@tier_req_id", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { tier_req.tier_req_id = rdr.GetInt32(0); } else { tier_req.tier_req_id = 0; } if (!rdr.IsDBNull(1)) { tier_req.req_id = rdr.GetInt32(1); } else { tier_req.req_id = 0; } if (!rdr.IsDBNull(2)) { tier_req.tier_id = rdr.GetInt32(2); } else { tier_req.tier_id = 0; } } else { tier_req.SetColumnDefaults(); } } catch (Exception ex) { tier_req.SetColumnDefaults(); return(tier_req); } finally { con.Close(); } return(tier_req); }
public tier_req Insert(tier_req id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_TIER_REQ", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@req_id", id.req_id); cmd.Parameters.AddWithValue("@tier_id", id.tier_id); cmd.ExecuteReader(); con.Close(); con.Open(); cmd = new SqlCommand("SP_DMCS_GET_TIER_REQ", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@req_id", id.req_id); cmd.Parameters.AddWithValue("@tier_id", id.tier_id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); id.tier_req_id = rdr.GetInt32(0); } } catch (Exception ex) { id.SetColumnDefaults(); } finally { con.Close(); } return(id); }
public tier_req Select(int id) { tier_req tier_req = new tier_req(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_TIER_REQ", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@tier_req_id", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { tier_req.tier_req_id = rdr.GetInt32(0); } else { tier_req.tier_req_id = 0; } if (!rdr.IsDBNull(1)) { tier_req.req_id = rdr.GetInt32(1); } else { tier_req.req_id = 0; } if (!rdr.IsDBNull(2)) { tier_req.tier_id = rdr.GetInt32(2); } else { tier_req.tier_id = 0; } } else { tier_req.SetColumnDefaults(); } } catch (Exception ex) { tier_req.SetColumnDefaults(); return tier_req; } finally { con.Close(); } return tier_req; }
public tier_req Insert(tier_req id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_TIER_REQ", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@req_id", id.req_id); cmd.Parameters.AddWithValue("@tier_id", id.tier_id); cmd.ExecuteReader(); con.Close(); con.Open(); cmd = new SqlCommand("SP_DMCS_GET_TIER_REQ", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@req_id", id.req_id); cmd.Parameters.AddWithValue("@tier_id", id.tier_id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); id.tier_req_id = rdr.GetInt32(0); } } catch (Exception ex) { id.SetColumnDefaults(); } finally { con.Close(); } return id; }