Ejemplo n.º 1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewCompany.SelectedItems.Count == 1)
     {
         CompanySet person = listViewCompany.SelectedItems[0].Tag as CompanySet;
         person.ShortName = textBoxShortName.Text;
         person.INN       = textBoxINN.Text;
         person.KPP       = textBoxKPP.Text;
         person.Adress    = textBoxAdress.Text;
         person.IdAgent   = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
         Program.Edb.SaveChanges();
         ShowCompany();
     }
 }
Ejemplo n.º 2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewCompany.SelectedItems.Count == 1)
         {
             CompanySet company = listViewCompany.SelectedItems[0].Tag as CompanySet;
             Program.Edb.CompanySet.Remove(company);
             Program.Edb.SaveChanges();
             ShowAgent();
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта кнопка используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(textBoxINN.Text) ||
         String.IsNullOrEmpty(textBoxKPP.Text) ||
         String.IsNullOrEmpty(textBoxShortName.Text) ||
         String.IsNullOrEmpty(textBoxAdress.Text) ||
         comboBoxAgent.SelectedItem == null)
     {
         MessageBox.Show("Введите данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         CompanySet comp = new CompanySet();
         comp.IdAgent   = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
         comp.ShortName = textBoxShortName.Text;
         comp.INN       = textBoxINN.Text;
         comp.KPP       = textBoxKPP.Text;
         comp.Adress    = textBoxAdress.Text;
         Program.Edb.CompanySet.Add(comp);
         Program.Edb.SaveChanges();
         ShowCompany();
     }
 }