private void btnViewIndividualClients_Click(object sender, EventArgs e)
        {
            Individual_Client_Info individualform = new Individual_Client_Info();

            individualform.Show();
            this.Close();
        }
コード例 #2
0
        private void btnInsertClient_Click(object sender, EventArgs e)
        {
            //assign values to variables

            try
            {
                int    id      = Convert.ToInt32(nudID.Value);
                string name    = txtName.Text;
                string surname = txtSurname.Text;
                string email   = txtEmail.Text;

                int currentclient = lstCurrentClient.SelectedIndex;
                if (currentclient == 0)
                {
                    currentclient = 1;
                }
                else
                {
                    currentclient = 0;
                }


                string cellphone = txtCellphone.Text;
                if (cellphone == "")
                {
                    cellphone = "Unknown";
                }

                string status = rtbStatus.Text;
                if (status == "")
                {
                    status = "Unknown";
                }

                int streetnumber = Convert.ToInt32(nudStreetNumber.Value);

                string streetname = txtStreetName.Text;
                if (streetname == "")
                {
                    streetname = "Unknown";
                }

                string city = txtCity.Text;
                if (city == "")
                {
                    city = "Unknown";
                }

                string country;
                if (lstCountries.SelectedItem == null)
                {
                    country = "Unknown";
                }
                else
                {
                    country = lstCountries.SelectedItem.ToString();
                }


                IndividualClient client = new IndividualClient(id, name, surname, email, cellphone, status, currentclient, streetnumber, streetname, city, country);
                client.SendClientToDataAccess(client);
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error with one of your values: " + ex.Message);
            }
            finally
            {
                Individual_Client_Info clientform = new Individual_Client_Info();
                clientform.Show();
                this.Close();
            }
        }