Beispiel #1
0
 public ClientSession()
 {
     client = new Client();
     session = new Session();
     status = new Status();
 }
Beispiel #2
0
 private static void AddParameters(Client client, SqlCommand comm)
 {
     comm.Parameters.AddWithValue("CompanyID", client.CompanyID);
     comm.Parameters.AddWithValue("AddressCity", client.ClientAddressCity);
     comm.Parameters.AddWithValue("AddressCountry", client.ClientAddressCountry);
     comm.Parameters.AddWithValue("AddressLine1", client.ClientAddressLine1);
     comm.Parameters.AddWithValue("AddressLine2", client.ClientAddressLine2 == null ? (object)DBNull.Value : client.ClientAddressLine2); // Check for null
     comm.Parameters.AddWithValue("AddressPostalCode", client.ClientAddressPostalCode);
     comm.Parameters.AddWithValue("AddressRegion", client.ClientAddressRegion);
     comm.Parameters.AddWithValue("FaxPhone", client.ClientFaxPhone == null ? (object)DBNull.Value : client.ClientFaxPhone); // Check for null
     comm.Parameters.AddWithValue("FirstName", client.ClientFirstName);
     comm.Parameters.AddWithValue("HomePhone", client.ClientHomePhone);
     comm.Parameters.AddWithValue("LastName", client.ClientLastName);
     comm.Parameters.AddWithValue("WorkPhone", client.ClientWorkPhone);
 }
Beispiel #3
0
 public static Client ReadClient(SqlDataReader reader)
 {
     Client client = new Client();
     client.ClientID = (int)reader["ClientID"];
     client.ClientAddressCity = (string)reader["ClientAddressCity"];
     client.ClientAddressCountry = (string)reader["ClientAddressCountry"];
     client.ClientAddressLine1 = (string)reader["ClientAddressLine1"];
     client.ClientAddressLine2 = reader["ClientAddressLine2"] as string; // Allow null
     client.ClientAddressPostalCode = (string)reader["ClientAddressPostalCode"];
     client.ClientAddressRegion = (string)reader["ClientAddressRegion"];
     client.ClientFaxPhone = reader["ClientFaxPhone"] as string; // Allow null
     client.ClientFirstName = (string)reader["ClientFirstName"];
     client.ClientHomePhone = (string)reader["ClientHomePhone"];
     client.ClientLastName = (string)reader["ClientLastName"];
     client.ClientWorkPhone = (string)reader["ClientWorkPhone"];
     client.company = Company.ReadCompany(reader);
     return client;
 }
Beispiel #4
0
        public static int UpdateClient(Client client, Client oldClient)
        {
            int rowsAffected = 0;

            // Setup Connection
            using (DatabaseConnection db = new DatabaseConnection("dbo.UpdateClient"))
            {
                // Set Parameters
                AddParameters(client, db.comm);
                AddOldParameters(oldClient, db.comm);

                // Open Connection
                db.conn.Open();

                // Execute Command and Read Response
                rowsAffected = db.comm.ExecuteNonQuery();
            }

            return rowsAffected;
        }
Beispiel #5
0
        public static int AddClient(Client client)
        {
            int clientID = -1;

            // Setup Connection
            using (DatabaseConnection db = new DatabaseConnection("dbo.AddClient"))
            {
                // Set Parameters
                AddParameters(client, db.comm);

                // Open Connection
                db.conn.Open();

                // Execute Command and Read Response
                clientID = Convert.ToInt32(db.comm.ExecuteScalar());
            }

            return clientID;
        }