//gets the current address ID that was just made from the first stored procedure so not to cause an error
 private static void getCurrentAddId(RowData rd)
 {
     using (SqlConnection conn = new SqlConnection(DB.getConnection()))
     {
         SqlCommand cmd = new SqlCommand("getlastaddID", conn);
         cmd.CommandType = CommandType.StoredProcedure;
         conn.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         dr.Read();
         rd.addID = dr.GetInt32(0);
     }
 }
 private static void updateAddress(RowData rd)
 {
     using (SqlConnection conn = new SqlConnection(DB.getConnection()))
     {
         SqlCommand cmd = new SqlCommand("InsertCustomerAddress", conn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@custID", rd.custID);
         cmd.Parameters.AddWithValue("@addID", rd.addID);
         cmd.Parameters.AddWithValue("@addressType", rd.addType);
         cmd.Parameters.AddWithValue("@modifiedDate", rd.modDate);
         conn.Open();
         cmd.ExecuteNonQuery();
     }
 }
 private static void insertCustomersAddress(RowData rd)
 {
     using (SqlConnection conn = new SqlConnection(DB.getConnection()))
     {
         SqlCommand cmd = new SqlCommand("InsertAddress", conn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@addressLine1", rd.addLine1);
         cmd.Parameters.AddWithValue("@addressLine2", rd.addLine2);
         cmd.Parameters.AddWithValue("@city", rd.city);
         cmd.Parameters.AddWithValue("@stateProvince", rd.stateProv);
         cmd.Parameters.AddWithValue("@countryRegion", rd.country);
         cmd.Parameters.AddWithValue("@postalCode", rd.postalc);
         cmd.Parameters.AddWithValue("@modifiedDate", rd.modDate);
         conn.Open();
         cmd.ExecuteNonQuery();
     }
 }
        private static void insertCustomers(RowData rd)
        {
            using (SqlConnection conn = new SqlConnection(DB.getConnection()))
            {
                SqlCommand cmd = new SqlCommand("InsertCustomers", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Title", rd.title);
                cmd.Parameters.AddWithValue("@firstName", rd.firstName);
                cmd.Parameters.AddWithValue("@lastName", rd.lastName);
                cmd.Parameters.AddWithValue("@middleName", rd.middleName);
                cmd.Parameters.AddWithValue("@suffix", rd.suffex);
                cmd.Parameters.AddWithValue("@companyName", rd.companyName);
                cmd.Parameters.AddWithValue("@salesPerson", rd.salesPerson);
                cmd.Parameters.AddWithValue("@emailAddress", rd.email);
                cmd.Parameters.AddWithValue("@phone", rd.phone);
                cmd.Parameters.AddWithValue("@PasswordHash", rd.passhash);
                cmd.Parameters.AddWithValue("@PasswordSalt", rd.passSalt);
                cmd.Parameters.AddWithValue("@modifydate", rd.modDate);
                conn.Open();
                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 5
0
 public static void updateRow(RowData rd)
 {
     updateCustomers(rd);
     updateCustomersAddress(rd);
     updateAddress(rd);
 }