コード例 #1
0
        public address Insert(address id)
        {
            string        ConnectionString = IDManager.connection();
            SqlConnection con = new SqlConnection(ConnectionString);

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_ADDRESS", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@address_type_id", id.address_type_id);
                cmd.Parameters.AddWithValue("@city", id.city);
                cmd.Parameters.AddWithValue("@country", id.country);
                cmd.Parameters.AddWithValue("@County_Township", id.County_Township);
                cmd.Parameters.AddWithValue("@longitude", id.longitude);
                cmd.Parameters.AddWithValue("@latitude", id.latitude);
                cmd.Parameters.AddWithValue("@state", id.state);
                cmd.Parameters.AddWithValue("@str_add", id.str_add);
                cmd.Parameters.AddWithValue("@str_add2", id.str_add2);
                cmd.Parameters.AddWithValue("@zip_plus_four", id.zip_plus_four);
                cmd.ExecuteReader();
                con.Close();
                con.Open();
                cmd             = new SqlCommand("SP_DMCS_GET_ADDRESS", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@address_type_id", id.address_type_id);
                cmd.Parameters.AddWithValue("@city", id.city);
                cmd.Parameters.AddWithValue("@country", id.country);
                cmd.Parameters.AddWithValue("@County_Township", id.County_Township);
                cmd.Parameters.AddWithValue("@longitude", id.longitude);
                cmd.Parameters.AddWithValue("@latitude", id.latitude);
                cmd.Parameters.AddWithValue("@state", id.state);
                cmd.Parameters.AddWithValue("@str_add", id.str_add);
                cmd.Parameters.AddWithValue("@str_add2", id.str_add2);
                cmd.Parameters.AddWithValue("@zip_plus_four", id.zip_plus_four);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    rdr.Read();
                    id.address_id = rdr.GetInt32(0);
                }
            }
            catch (Exception ex)
            {
                id.SetColumnDefaults();
            }
            finally
            {
                con.Close();
            }
            return(id);
        }
コード例 #2
0
        public address Select(int id)
        {
            address       address          = new address();
            string        ConnectionString = IDManager.connection();
            SqlConnection con = new SqlConnection(ConnectionString);

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_ADDRESS", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@address_id", id);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    rdr.Read();
                    if (!rdr.IsDBNull(0))
                    {
                        address.address_id = rdr.GetInt32(0);
                    }
                    else
                    {
                        address.address_id = 0;
                    }
                    if (!rdr.IsDBNull(1))
                    {
                        address.address_type_id = rdr.GetInt32(1);
                    }
                    else
                    {
                        address.address_type_id = 0;
                    }
                    if (!rdr.IsDBNull(2))
                    {
                        address.city = rdr.GetString(2);
                    }
                    else
                    {
                        address.city = " ";
                    }
                    if (!rdr.IsDBNull(3))
                    {
                        address.country = rdr.GetString(3);
                    }
                    else
                    {
                        address.country = " ";
                    }
                    if (!rdr.IsDBNull(4))
                    {
                        address.County_Township = rdr.GetString(4);
                    }
                    else
                    {
                        address.County_Township = " ";
                    }
                    if (!rdr.IsDBNull(5))
                    {
                        address.longitude = rdr.GetDecimal(5);
                    }
                    else
                    {
                        address.longitude = 0;
                    }
                    if (!rdr.IsDBNull(6))
                    {
                        address.latitude = rdr.GetDecimal(6);
                    }
                    else
                    {
                        address.latitude = 0;
                    }
                    if (!rdr.IsDBNull(7))
                    {
                        address.state = rdr.GetString(7);
                    }
                    else
                    {
                        address.state = " ";
                    }
                    if (!rdr.IsDBNull(8))
                    {
                        address.str_add = rdr.GetString(8);
                    }
                    else
                    {
                        address.str_add = " ";
                    }
                    if (!rdr.IsDBNull(9))
                    {
                        address.str_add2 = rdr.GetString(9);
                    }
                    else
                    {
                        address.str_add2 = " ";
                    }
                    if (!rdr.IsDBNull(10))
                    {
                        address.zip_plus_four = rdr.GetString(10);
                    }
                    else
                    {
                        address.zip_plus_four = " ";
                    }
                }
                else
                {
                    address.SetColumnDefaults();
                }
            }
            catch (Exception ex)
            {
                address.SetColumnDefaults();
                return(address);
            }
            finally
            {
                con.Close();
            }
            return(address);
        }
コード例 #3
0
 public address Select(int id)
 {
     address address = new address();
     string ConnectionString = IDManager.connection();
     SqlConnection con = new SqlConnection(ConnectionString);
     try
     {
     con.Open();
     SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_ADDRESS", con);
     cmd.CommandType = System.Data.CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@address_id", id);
     SqlDataReader rdr = cmd.ExecuteReader();
     if (rdr.HasRows)
     {
         rdr.Read();
         if (!rdr.IsDBNull(0))
         {
             address.address_id = rdr.GetInt32(0);
         }
         else
         {
             address.address_id = 0;
         }
         if (!rdr.IsDBNull(1))
         {
             address.address_type_id = rdr.GetInt32(1);
         }
         else
         {
             address.address_type_id = 0;
         }
         if (!rdr.IsDBNull(2))
         {
             address.city = rdr.GetString(2);
         }
         else
         {
             address.city = " ";
         }
         if (!rdr.IsDBNull(3))
         {
             address.country = rdr.GetString(3);
         }
         else
         {
             address.country = " ";
         }
         if (!rdr.IsDBNull(4))
         {
             address.County_Township = rdr.GetString(4);
         }
         else
         {
             address.County_Township = " ";
         }
         if (!rdr.IsDBNull(5))
         {
             address.longitude = rdr.GetDecimal(5);
         }
         else
         {
             address.longitude = 0;
         }
         if (!rdr.IsDBNull(6))
         {
             address.latitude = rdr.GetDecimal(6);
         }
         else
         {
             address.latitude = 0;
         }
         if (!rdr.IsDBNull(7))
         {
             address.state = rdr.GetString(7);
         }
         else
         {
             address.state = " ";
         }
         if (!rdr.IsDBNull(8))
         {
             address.str_add = rdr.GetString(8);
         }
         else
         {
             address.str_add = " ";
         }
         if (!rdr.IsDBNull(9))
         {
             address.str_add2 = rdr.GetString(9);
         }
         else
         {
             address.str_add2 = " ";
         }
         if (!rdr.IsDBNull(10))
         {
             address.zip_plus_four = rdr.GetString(10);
         }
         else
         {
             address.zip_plus_four = " ";
         }
         }
         else
         {
             address.SetColumnDefaults();
         }
     }
     catch (Exception ex)
     {
     address.SetColumnDefaults();
     return address;
     }
     finally
     {
     con.Close();
     }
     return address;
 }
コード例 #4
0
 public address Insert(address id)
 {
     string ConnectionString = IDManager.connection();
     SqlConnection con = new SqlConnection(ConnectionString);
     try
     {
     con.Open();
     SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_ADDRESS", con);
     cmd.CommandType = System.Data.CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@address_type_id", id.address_type_id);
     cmd.Parameters.AddWithValue("@city", id.city);
     cmd.Parameters.AddWithValue("@country", id.country);
     cmd.Parameters.AddWithValue("@County_Township", id.County_Township);
     cmd.Parameters.AddWithValue("@longitude", id.longitude);
     cmd.Parameters.AddWithValue("@latitude", id.latitude);
     cmd.Parameters.AddWithValue("@state", id.state);
     cmd.Parameters.AddWithValue("@str_add", id.str_add);
     cmd.Parameters.AddWithValue("@str_add2", id.str_add2);
     cmd.Parameters.AddWithValue("@zip_plus_four", id.zip_plus_four);
     cmd.ExecuteReader();
     con.Close();
     con.Open();
     cmd = new SqlCommand("SP_DMCS_GET_ADDRESS", con);
     cmd.CommandType = System.Data.CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@address_type_id", id.address_type_id);
     cmd.Parameters.AddWithValue("@city", id.city);
     cmd.Parameters.AddWithValue("@country", id.country);
     cmd.Parameters.AddWithValue("@County_Township", id.County_Township);
     cmd.Parameters.AddWithValue("@longitude", id.longitude);
     cmd.Parameters.AddWithValue("@latitude", id.latitude);
     cmd.Parameters.AddWithValue("@state", id.state);
     cmd.Parameters.AddWithValue("@str_add", id.str_add);
     cmd.Parameters.AddWithValue("@str_add2", id.str_add2);
     cmd.Parameters.AddWithValue("@zip_plus_four", id.zip_plus_four);
     SqlDataReader rdr = cmd.ExecuteReader();
     if (rdr.HasRows)
     {
         rdr.Read();
         id.address_id = rdr.GetInt32(0);
     }
     }
     catch (Exception ex)
     {
     id.SetColumnDefaults();
     }
     finally
     {
     con.Close();
     }
     return id;
 }