Exemplo n.º 1
0
        /// <summary>
        /// Button for adding new client
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // If client without name than give email value to name
                if (textBoxEmail.Text != "" && textBoxProduct.Text != "")
                {
                    Client client = new Client();

                    // Receive info from text boxes to new client
                    client.Email   = textBoxEmail.Text;
                    client.Link    = textBoxLink.Text;
                    client.Product = textBoxProduct.Text;
                    client.Name    = textBoxEmail.Text;

                    // Add new client to list
                    Clients.AddClient(client);


                    // Syncronize list with list box
                    SyncListBoxWithList();

                    // Clear all text boxes
                    ClearTextBoxes();
                } // If we have client name than add full info
                else
                {
                    MessageBox.Show("One of important fields is empty!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }