コード例 #1
0
ファイル: MainForm.cs プロジェクト: fo-xi/ContactsApp
        /// <summary>
        /// Deletes contact information in the list and ListBox.
        /// </summary>
        private void RemoveContact()
        {
            var selectedIndex = AllContactsListBox.SelectedIndex;

            if (selectedIndex == -1)
            {
                MessageBox.Show("Select a contact from the list", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
                //TODO: если после if-else нет никакой общей логики, тогда в if можно написать return, а else с лишней вложенностью убрать (+)
            }

            DialogResult result = MessageBox.Show("Do you really want to remove this contact?",
                                                  "Remove contact", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.OK)
            {
                var selectedContact = _contacts[selectedIndex];
                _project.Contacts.Remove(selectedContact);
                AllContactsListBox.Items.RemoveAt(selectedIndex);
                SurnameTextBox.Clear();
                NameTextBox.Clear();
                PhoneTextBox.Clear();
                EmailTextBox.Clear();
                VkIDTextBox.Clear();
                SaveToFile();
            }
            SortingFoundContacts();
        }
コード例 #2
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(PhoneTextBox.Text) && !string.IsNullOrEmpty(NameTextBox.Text) && !string.IsNullOrEmpty(PasswordBox.Password) && !string.IsNullOrEmpty(ConfirmPasswordBox.Password))
     {
         if (PasswordBox.Password == ConfirmPasswordBox.Password)
         {
             if (!service.SignUpEmployee(NameTextBox.Text, PhoneTextBox.Text, PasswordBox.Password, "default", out string message, out Employee user))
             {
                 Close();
             }
             else
             {
                 PhoneTextBox.Clear();
                 NameTextBox.Clear();
                 PasswordBox.Clear();
                 ConfirmPasswordBox.Clear();
             }
         }
         else
         {
             MessageBox.Show("Passwords in to fields should be equal");
             PasswordBox.Clear();
             ConfirmPasswordBox.Clear();
             PasswordBox.Focus();
         }
     }
コード例 #3
0
 void ClearMethod()
 {
     NameTextBox.Clear();
     AgeTextBox.Clear();
     AddressTextBox.Clear();
     PhoneTextBox.Clear();
     HistoryTextBox.Clear();
 }
コード例 #4
0
 private void ClearForm()
 {
     NameTextBox.Clear();
     EmailTextBox.Clear();
     PhoneTextBox.Clear();
     AddressTextBox.Clear();
     Products.Clear();
     TotalTextBox.Text = "0";
 }
コード例 #5
0
 private void refresh()
 {
     NameTextBox.Clear();
     ProjectComboBox.SelectedIndex = 0;
     PhoneTextBox.Clear();
     passwordTextBox.Clear();
     confrimPWTextBox.Clear();
     CommentTextBox.Clear();
     bindingDateGridView(null);
 }
コード例 #6
0
        private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedItem = (string)comboBox.SelectedItem;
            try
            {
                MySqlConnection connection = new MySqlConnection("Datasource=localhost;port=3306;username=root;password="******"SELECT * FROM bookstore.customers WHERE first = \"{name[0]}\" AND last = \"{name[1]}\"";
                connection.Open();
                MySqlCommand    command = new MySqlCommand(query, connection);
                MySqlDataReader reader  = command.ExecuteReader();
                if (reader.Read())
                {
                    firstTextBox.Text   = reader["first"].ToString();
                    lastTextBox.Text    = reader["last"].ToString();
                    addressTextBox.Text = reader["address"].ToString();
                    cityTextBox.Text    = reader["city"].ToString();
                    stateTextBox.Text   = reader["state"].ToString();
                    zipTextBox.Text     = reader["zip"].ToString();
                    emailTextBox.Text   = reader["email"].ToString();
                    PhoneTextBox.Text   = reader["phone"].ToString();
                    tempfirst           = reader["first"].ToString();
                    templast            = reader["last"].ToString();
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //clear form
                firstTextBox.Clear();
                lastTextBox.Clear();
                addressTextBox.Clear();
                cityTextBox.Clear();
                stateTextBox.Clear();
                zipTextBox.Clear();
                PhoneTextBox.Clear();
                //emailTextBox.Clear();
            }
            finally
            {
                connection.Close();
            }
            comboBox.Focus();
        }
コード例 #7
0
ファイル: Customer.cs プロジェクト: michaelolivas/Bookstore
        private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedItem = (string)comboBox.SelectedItem;
            try
            {
                //access books
                string  BookJSON = File.ReadAllText(path);
                JObject json     = JObject.Parse(BookJSON);

                JObject CustoTarget = (JObject)json[SelectedItem];

                string custo_target = CustoTarget.ToString();

                CustomerList foundCusto = new CustomerList();
                Newtonsoft.Json.JsonConvert.PopulateObject(custo_target, foundCusto);
                firstTextBox.Text   = foundCusto.first;
                lastTextBox.Text    = foundCusto.last;
                addressTextBox.Text = foundCusto.address;
                cityTextBox.Text    = foundCusto.city;
                stateTextBox.Text   = foundCusto.state;
                zipTextBox.Text     = foundCusto.zip;
                PhoneTextBox.Text   = foundCusto.phone;
                emailTextBox.Text   = foundCusto.email;

                tempfirst = foundCusto.first;
                templast  = foundCusto.last;
            }
            catch
            {
                //clear form
                firstTextBox.Clear();
                lastTextBox.Clear();
                addressTextBox.Clear();
                cityTextBox.Clear();
                stateTextBox.Clear();
                zipTextBox.Clear();
                PhoneTextBox.Clear();
                //emailTextBox.Clear();
            }

            comboBox.Focus();
        }