Example #1
0
 public static List <ContactDetails> GetCustomerNumbers(int id)
 {
     using (SqlConnection con = new SqlConnection(connString, credentials))
     {
         try
         {
             Dictionary <string, object> p = new Dictionary <string, object>
             {
                 { "@Id", id }
             };
             string query = "SELECT Id, CustomerId, ContactTypeId, ContactInfo " +
                            "FROM CustomerContactDetails " +
                            "WHERE CustomerId = @Id";
             con.Open();
             return(DBActions.ExecReaderListQR <ContactDetails>(con, query, p));
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             return(null);
         }
         finally
         {
             con.Close();
         }
     }
 }
Example #2
0
 public static List <AddressVM> GetCustomerAddressList(int id)
 {
     using (SqlConnection con = new SqlConnection(connString, credentials))
     {
         try
         {
             Dictionary <string, object> p = new Dictionary <string, object>
             {
                 { "@Id", id }
             };
             string query = "SELECT Id, Road, Number, City, Region, State, PostalCode, Country " +
                            "FROM CustomerAddress " +
                            "WHERE CustomerId = @Id";
             con.Open();
             return(DBActions.ExecReaderListQR <AddressVM>(con, query, p));
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             return(null);
         }
         finally
         {
             con.Close();
         }
     }
 }
Example #3
0
 public static List <CustomerItemVM> GetCustomerItemsVM()
 {
     using (SqlConnection con = new SqlConnection(connString, credentials)) {
         try {
             string query = @"SELECT cust.Id, cust.FirstName, cust.LastName, cust.DateOfBirth, comp.Name as CompanyName " +
                            "FROM Customers cust " +
                            "LEFT JOIN Companies comp " +
                            "ON cust.CompanyId = comp.Id";
             con.Open();
             return(DBActions.ExecReaderListQR <CustomerItemVM>(con, query, null));
         }
         catch (Exception ex) {
             MessageBox.Show(ex.Message);
             return(null);
         }
         finally {
             con.Close();
         }
     }
 }
Example #4
0
 public static List <ContactType> GetContactTypes()
 {
     using (SqlConnection con = new SqlConnection(connString, credentials))
     {
         try
         {
             string query = "SELECT Id, Type " +
                            "FROM ContactType";
             con.Open();
             return(DBActions.ExecReaderListQR <ContactType>(con, query, null));
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             return(null);
         }
         finally
         {
             con.Close();
         }
     }
 }
Example #5
0
 public static List <Company> GetAllCompanies()
 {
     using (SqlConnection con = new SqlConnection(connString, credentials))
     {
         try
         {
             string query = "SELECT Id, Name, Title, Country " +
                            "FROM Companies";
             con.Open();
             return(DBActions.ExecReaderListQR <Company>(con, query, null));
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             return(null);
         }
         finally
         {
             con.Close();
         }
     }
 }