예제 #1
0
        private void btnAddLocation_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BITClient selectedClient = (BITClient)lvClients.SelectedItem;
                selectedClient.ClientLocationUnit     = txtClientUnit.Text;
                selectedClient.ClientLocationStreet   = txtClientStreet.Text.Replace("'", @"\'");
                selectedClient.ClientLocationSuburb   = txtClientSuburb.Text.Replace("'", @"\'");
                selectedClient.ClientLocationState    = txtClientState.Text;
                selectedClient.ClientLocationPostcode = txtClientPostcode.Text;
                if (chkBxMarkAsPrimary.IsChecked == true)
                {
                    selectedClient.IsPrimary = 1;
                }
                else if (chkBxMarkAsPrimary.IsChecked == false)
                {
                    selectedClient.IsPrimary = 0;
                }
                selectedClient.ClientLocationDetails = txtClientDetails.Text;

                selectedClient.AddNewLocation();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "We could not add this client.");
            }
            ShowData();
        }
예제 #2
0
        private void LoadClientsList()
        {
            DataTable dtClients = BITClient.ReadClientCombo();

            cmbNewJobClient.SelectedValuePath = "clientID";
            cmbNewJobClient.DisplayMemberPath = "clientFirstName";
            cmbNewJobClient.ItemsSource       = dtClients.DefaultView;
        }
예제 #3
0
        private void cmbNewJobClient_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int       selected    = Convert.ToInt32(cmbNewJobClient.SelectedValue);
            DataTable dtLocations = BITClient.ReadClientLocation(selected);

            cmbNewJobLocation.SelectedValuePath = "clientLocationID";
            cmbNewJobLocation.DisplayMemberPath = "clientLocationSuburb";
            cmbNewJobLocation.ItemsSource       = dtLocations.DefaultView;
        }
예제 #4
0
 private void btnDeleteLocation_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         BITClient selectedClient = (BITClient)lvClients.SelectedItem;
         selectedClient.DeleteLocation();
         ShowData();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Something went wrong.");
     }
 }
예제 #5
0
        private void btnClientUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!IsValidEmail(txtClientEmail.Text))
                {
                    MessageBox.Show("Please enter a valid email address.");
                    return;
                }

                if (txtClientBusinessName.Text == "" || txtClientFName.Text == "" || txtClientLName.Text == "" || txtClientPhone.Text == "" || txtClientEmail.Text == "" || txtClientFax.Text == "" || txtClientUnit.Text == "" || txtClientStreet.Text == "" || txtClientSuburb.Text == "" || txtClientState.Text == "" || txtClientPostcode.Text == "" || txtClientDetails.Text == "")
                {
                    var result = MessageBox.Show("Is this correct? Do you want to proceed with the update?", "You have some empty fields.", MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (result == MessageBoxResult.Yes)
                    {
                        BITClient selectedClient = (BITClient)lvClients.SelectedItem;
                        selectedClient.ClientBusinessName     = txtClientBusinessName.Text.Replace("'", @"\'");
                        selectedClient.ClientFName            = txtClientFName.Text.Replace("'", @"\'");
                        selectedClient.ClientLName            = txtClientLName.Text.Replace("'", @"\'");
                        selectedClient.ClientPhone            = txtClientPhone.Text;
                        selectedClient.ClientEmail            = txtClientEmail.Text;
                        selectedClient.ClientFax              = txtClientFax.Text;
                        selectedClient.ClientLocationUnit     = txtClientUnit.Text;
                        selectedClient.ClientLocationStreet   = txtClientStreet.Text.Replace("'", @"\'");
                        selectedClient.ClientLocationSuburb   = txtClientSuburb.Text.Replace("'", @"\'");
                        selectedClient.ClientLocationState    = txtClientState.Text;
                        selectedClient.ClientLocationPostcode = txtClientPostcode.Text;
                        selectedClient.ClientUsername         = txtBxUsername.Text;
                        selectedClient.ClientPassword         = txtBxPassword.Text;
                        if (chkBxMarkAsPrimary.IsChecked == true)
                        {
                            selectedClient.IsPrimary = 1;
                        }
                        else if (chkBxMarkAsPrimary.IsChecked == false)
                        {
                            selectedClient.IsPrimary = 0;
                        }
                        selectedClient.ClientLocationDetails = txtClientDetails.Text;

                        selectedClient.UpdateClient();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Something went wrong.");
            }
            ShowData();
        }
예제 #6
0
        private void lvClients_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            BITClient client = (BITClient)lvClients.SelectedItem;

            if (lvClients.SelectedItem == null)
            {
                chkBxMarkAsPrimary.IsChecked = false;
            }
            else if (client.IsPrimary == 1)
            {
                chkBxMarkAsPrimary.IsChecked = true;
            }
            else
            {
                chkBxMarkAsPrimary.IsChecked = false;
            }
        }
예제 #7
0
 private void chkBxMarkAsPrimary_Unloaded(object sender, RoutedEventArgs e)
 {
     try
     {
         BITClient client = (BITClient)lvClients.SelectedItem;
         if (client == null)
         {
             return;
         }
         else
         {
             client.IsPrimary = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Something went wrong.");
     }
 }
예제 #8
0
        private void add_client()
        {
            try
            {
                if (!IsValidEmail(txtClientEmail.Text))
                {
                    MessageBox.Show("Please enter a valid email address.");
                    return;
                }

                //Put the text box values into the client object
                BITClient newClient = new BITClient();

                if (string.IsNullOrEmpty(txtClientState.Text) || string.IsNullOrEmpty(txtClientStreet.Text))
                {
                    newClient.ClientBusinessName     = txtClientBusinessName.Text.Replace("'", @"\'");
                    newClient.ClientFName            = txtClientFName.Text.Replace("'", @"\'");
                    newClient.ClientLName            = txtClientLName.Text.Replace("'", @"\'");
                    newClient.ClientPhone            = txtClientPhone.Text;
                    newClient.ClientEmail            = txtClientEmail.Text;
                    newClient.ClientFax              = txtClientFax.Text;
                    newClient.ClientUsername         = txtBxUsername.Text;
                    newClient.ClientPassword         = txtBxPassword.Text;
                    newClient.IsPrimary              = null;
                    newClient.ClientLocationID       = null;
                    newClient.ClientLocationUnit     = null;
                    newClient.ClientLocationStreet   = null;
                    newClient.ClientLocationSuburb   = null;
                    newClient.ClientLocationPostcode = null;
                    newClient.ClientLocationState    = null;
                    newClient.ClientLocationDetails  = null;
                    newClient.AddClientNoAddress();
                    ShowData();
                    clearFields();
                }
                else
                {
                    newClient.ClientBusinessName = txtClientBusinessName.Text.Replace("'", @"\'");
                    newClient.ClientFName        = txtClientFName.Text.Replace("'", @"\'");
                    newClient.ClientLName        = txtClientLName.Text.Replace("'", @"\'");
                    newClient.ClientPhone        = txtClientPhone.Text;
                    newClient.ClientEmail        = txtClientEmail.Text;
                    newClient.ClientFax          = txtClientFax.Text;
                    newClient.ClientUsername     = txtBxUsername.Text;
                    newClient.ClientPassword     = txtBxPassword.Text;
                    if (chkBxMarkAsPrimary.IsChecked == true)
                    {
                        newClient.IsPrimary = 1;
                    }
                    else
                    {
                        newClient.IsPrimary = 0;
                    }
                    newClient.ClientLocationUnit     = txtClientUnit.Text;
                    newClient.ClientLocationStreet   = txtClientStreet.Text.Replace("'", @"\'");
                    newClient.ClientLocationSuburb   = txtClientSuburb.Text.Replace("'", @"\'");
                    newClient.ClientLocationPostcode = txtClientPostcode.Text;
                    newClient.ClientLocationState    = txtClientState.Text;
                    newClient.ClientLocationDetails  = txtClientDetails.Text;
                    //Add the patient to the database

                    newClient.AddClientWithAddress();
                }

                //Refresh the view and clear the textboxes
                ShowData();
                clearFields();
            }
            catch (Exception ex)
            {
                MessageBox.Show("You probably need to do something with the parameters and the inputs for the stored procedure. " + ex.Message);
            }
        }