public property Insert(property id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_PROPERTY", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@approx_mrkt_value", id.approx_mrkt_value); cmd.Parameters.AddWithValue("@address_id", id.address_id); cmd.Parameters.AddWithValue("@case_id", id.case_id); cmd.Parameters.AddWithValue("@client_id", id.client_id); cmd.Parameters.AddWithValue("@Homeowners_Insurance_Payment", id.Homeowners_Insurance_Payment); cmd.Parameters.AddWithValue("@monthly_property_payment", id.monthly_property_payment); cmd.Parameters.AddWithValue("@mortg_comp", id.mortg_comp); cmd.Parameters.AddWithValue("@Property_Tax_Payment", id.Property_Tax_Payment); cmd.Parameters.AddWithValue("@own_prop", id.own_prop); cmd.Parameters.AddWithValue("@rent_prop", id.rent_prop); cmd.Parameters.AddWithValue("@date_purchased", id.date_purchased); cmd.ExecuteReader(); con.Close(); con.Open(); cmd = new SqlCommand("SP_DMCS_GET_PROPERTY", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@approx_mrkt_value", id.approx_mrkt_value); cmd.Parameters.AddWithValue("@address_id", id.address_id); cmd.Parameters.AddWithValue("@case_id", id.case_id); cmd.Parameters.AddWithValue("@client_id", id.client_id); cmd.Parameters.AddWithValue("@Homeowners_Insurance_Payment", id.Homeowners_Insurance_Payment); cmd.Parameters.AddWithValue("@monthly_property_payment", id.monthly_property_payment); cmd.Parameters.AddWithValue("@mortg_comp", id.mortg_comp); cmd.Parameters.AddWithValue("@Property_Tax_Payment", id.Property_Tax_Payment); cmd.Parameters.AddWithValue("@own_prop", id.own_prop); cmd.Parameters.AddWithValue("@rent_prop", id.rent_prop); cmd.Parameters.AddWithValue("@date_purchased", id.date_purchased); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); id.property_id = rdr.GetInt32(0); } } catch (Exception ex) { id.SetColumnDefaults(); } finally { con.Close(); } return(id); }
public property Select(int id) { property property = new property(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_PROPERTY", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@property_id", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { property.property_id = rdr.GetInt32(0); } else { property.property_id = 0; } if (!rdr.IsDBNull(1)) { property.approx_mrkt_value = rdr.GetDecimal(1); } else { property.approx_mrkt_value = 0; } if (!rdr.IsDBNull(2)) { property.address_id = rdr.GetInt32(2); } else { property.address_id = 0; } if (!rdr.IsDBNull(3)) { property.case_id = rdr.GetInt32(3); } else { property.case_id = 0; } if (!rdr.IsDBNull(4)) { property.client_id = rdr.GetInt32(4); } else { property.client_id = 0; } if (!rdr.IsDBNull(5)) { property.Homeowners_Insurance_Payment = rdr.GetDecimal(5); } else { property.Homeowners_Insurance_Payment = 0; } if (!rdr.IsDBNull(6)) { property.monthly_property_payment = rdr.GetDecimal(6); } else { property.monthly_property_payment = 0; } if (!rdr.IsDBNull(7)) { property.mortg_comp = rdr.GetString(7); } else { property.mortg_comp = " "; } if (!rdr.IsDBNull(8)) { property.Property_Tax_Payment = rdr.GetDecimal(8); } else { property.Property_Tax_Payment = 0; } if (!rdr.IsDBNull(9)) { property.own_prop = rdr.GetString(9); } else { property.own_prop = " "; } if (!rdr.IsDBNull(10)) { property.rent_prop = rdr.GetString(10); } else { property.rent_prop = " "; } if (!rdr.IsDBNull(11)) { property.date_purchased = rdr.GetInt32(11); } else { property.date_purchased = 0; } } else { property.SetColumnDefaults(); } } catch (Exception ex) { property.SetColumnDefaults(); return(property); } finally { con.Close(); } return(property); }
public property Select(int id) { property property = new property(); string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_PROPERTY", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@property_id", id); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); if (!rdr.IsDBNull(0)) { property.property_id = rdr.GetInt32(0); } else { property.property_id = 0; } if (!rdr.IsDBNull(1)) { property.approx_mrkt_value = rdr.GetDecimal(1); } else { property.approx_mrkt_value = 0; } if (!rdr.IsDBNull(2)) { property.address_id = rdr.GetInt32(2); } else { property.address_id = 0; } if (!rdr.IsDBNull(3)) { property.case_id = rdr.GetInt32(3); } else { property.case_id = 0; } if (!rdr.IsDBNull(4)) { property.client_id = rdr.GetInt32(4); } else { property.client_id = 0; } if (!rdr.IsDBNull(5)) { property.Homeowners_Insurance_Payment = rdr.GetDecimal(5); } else { property.Homeowners_Insurance_Payment = 0; } if (!rdr.IsDBNull(6)) { property.monthly_property_payment = rdr.GetDecimal(6); } else { property.monthly_property_payment = 0; } if (!rdr.IsDBNull(7)) { property.mortg_comp = rdr.GetString(7); } else { property.mortg_comp = " "; } if (!rdr.IsDBNull(8)) { property.Property_Tax_Payment = rdr.GetDecimal(8); } else { property.Property_Tax_Payment = 0; } if (!rdr.IsDBNull(9)) { property.own_prop = rdr.GetString(9); } else { property.own_prop = " "; } if (!rdr.IsDBNull(10)) { property.rent_prop = rdr.GetString(10); } else { property.rent_prop = " "; } if (!rdr.IsDBNull(11)) { property.date_purchased = rdr.GetInt32(11); } else { property.date_purchased = 0; } } else { property.SetColumnDefaults(); } } catch (Exception ex) { property.SetColumnDefaults(); return property; } finally { con.Close(); } return property; }
public property Insert(property id) { string ConnectionString = IDManager.connection(); SqlConnection con = new SqlConnection(ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_PROPERTY", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@approx_mrkt_value", id.approx_mrkt_value); cmd.Parameters.AddWithValue("@address_id", id.address_id); cmd.Parameters.AddWithValue("@case_id", id.case_id); cmd.Parameters.AddWithValue("@client_id", id.client_id); cmd.Parameters.AddWithValue("@Homeowners_Insurance_Payment", id.Homeowners_Insurance_Payment); cmd.Parameters.AddWithValue("@monthly_property_payment", id.monthly_property_payment); cmd.Parameters.AddWithValue("@mortg_comp", id.mortg_comp); cmd.Parameters.AddWithValue("@Property_Tax_Payment", id.Property_Tax_Payment); cmd.Parameters.AddWithValue("@own_prop", id.own_prop); cmd.Parameters.AddWithValue("@rent_prop", id.rent_prop); cmd.Parameters.AddWithValue("@date_purchased", id.date_purchased); cmd.ExecuteReader(); con.Close(); con.Open(); cmd = new SqlCommand("SP_DMCS_GET_PROPERTY", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@approx_mrkt_value", id.approx_mrkt_value); cmd.Parameters.AddWithValue("@address_id", id.address_id); cmd.Parameters.AddWithValue("@case_id", id.case_id); cmd.Parameters.AddWithValue("@client_id", id.client_id); cmd.Parameters.AddWithValue("@Homeowners_Insurance_Payment", id.Homeowners_Insurance_Payment); cmd.Parameters.AddWithValue("@monthly_property_payment", id.monthly_property_payment); cmd.Parameters.AddWithValue("@mortg_comp", id.mortg_comp); cmd.Parameters.AddWithValue("@Property_Tax_Payment", id.Property_Tax_Payment); cmd.Parameters.AddWithValue("@own_prop", id.own_prop); cmd.Parameters.AddWithValue("@rent_prop", id.rent_prop); cmd.Parameters.AddWithValue("@date_purchased", id.date_purchased); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); id.property_id = rdr.GetInt32(0); } } catch (Exception ex) { id.SetColumnDefaults(); } finally { con.Close(); } return id; }