Exemplo n.º 1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewFL.SelectedItems.Count == 1 && textBoxFirstName.Text != "" && textBoxLastName.Text != "" && textBoxMiddleName.Text != "")
     {
         Customers_FL_ FL = listViewFL.SelectedItems[0].Tag as Customers_FL_;
         FL.FirstName  = textBoxFirstName.Text;
         FL.MiddleName = textBoxMiddleName.Text;
         FL.LastName   = textBoxLastName.Text;
         FL.Phone      = textBoxPhone.Text;
         FL.Email      = textBoxEmail.Text;
         Program.wtfDb.SaveChanges();
         ShowFL();
     }
     else
     {
         MessageBox.Show("Не все данные введены!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (textBoxFirstName.Text != "" && textBoxLastName.Text != "" && textBoxMiddleName.Text != "")
     {
         Customers_FL_ FL = new Customers_FL_();
         FL.FirstName  = textBoxFirstName.Text;
         FL.MiddleName = textBoxMiddleName.Text;
         FL.LastName   = textBoxLastName.Text;
         FL.Phone      = textBoxPhone.Text;
         FL.Email      = textBoxEmail.Text;
         Program.wtfDb.Customers_FL_.Add(FL);
         Program.wtfDb.SaveChanges();
         ShowFL();
     }
     else
     {
         MessageBox.Show("Не все данные введены!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
 private void listViewFL_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewFL.SelectedItems.Count == 1)
     {
         Customers_FL_ FL = listViewFL.SelectedItems[0].Tag as Customers_FL_;
         textBoxFirstName.Text  = FL.FirstName;
         textBoxMiddleName.Text = FL.MiddleName;
         textBoxLastName.Text   = FL.LastName;
         textBoxPhone.Text      = FL.Phone;
         textBoxEmail.Text      = FL.Email;
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxPhone.Text      = "";
         textBoxEmail.Text      = "";
     }
 }
Exemplo n.º 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewFL.SelectedItems.Count == 1)
         {
             Customers_FL_ FL = listViewFL.SelectedItems[0].Tag as Customers_FL_;
             Program.wtfDb.Customers_FL_.Remove(FL);
             Program.wtfDb.SaveChanges();
             ShowFL();
         }
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxPhone.Text      = "";
         textBoxEmail.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }