Пример #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewAccounting.SelectedItems.Count == 1)
     {
         AccountingsSet accountingsSet = listViewAccounting.SelectedItems[0].Tag as AccountingsSet;
         accountingsSet.IdAgent    = Convert.ToInt32(comboBoxAgents.SelectedItem.ToString().Split('.')[0]);
         accountingsSet.IdClient   = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]);
         accountingsSet.IdSupplier = Convert.ToInt32(comboBoxSupplier.SelectedItem.ToString().Split('.')[0]);
         accountingsSet.IdProduct  = Convert.ToInt32(comboBoxType.SelectedItem.ToString().Split('.')[0]);
         accountingsSet.Balance    = Convert.ToInt32(textBoxBalance.Text);
         Program.zooDb.SaveChanges();
         ShowAccounting();
     }
 }
Пример #2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxAgents.SelectedItem != null && comboBoxClients.SelectedItem != null && comboBoxType != null && comboBoxSupplier != null)
     {
         AccountingsSet accountingsSet = new AccountingsSet();
         accountingsSet.IdAgent    = Convert.ToInt32(comboBoxAgents.SelectedItem.ToString().Split('.')[0]);
         accountingsSet.IdClient   = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]);
         accountingsSet.IdProduct  = Convert.ToInt32(comboBoxType.SelectedItem.ToString().Split('.')[0]);
         accountingsSet.IdSupplier = Convert.ToInt32(comboBoxSupplier.SelectedItem.ToString().Split('.')[0]);
         accountingsSet.Balance    = Convert.ToInt32(textBoxBalance.Text);
         Program.zooDb.AccountingsSet.Add(accountingsSet);
         Program.zooDb.SaveChanges();
         ShowAccounting();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #3
0
 private void listViewAccounting_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewAccounting.SelectedItems.Count == 1)
     {
         AccountingsSet accountingsSet = listViewAccounting.SelectedItems[0].Tag as AccountingsSet;
         comboBoxAgents.SelectedIndex   = comboBoxAgents.FindString(accountingsSet.IdAgent.ToString());
         comboBoxClients.SelectedIndex  = comboBoxClients.FindString(accountingsSet.IdClient.ToString());
         comboBoxType.SelectedIndex     = comboBoxType.FindString(accountingsSet.IdProduct.ToString());
         comboBoxSupplier.SelectedIndex = comboBoxSupplier.FindString(accountingsSet.IdSupplier.ToString());
         textBoxBalance.Text            = accountingsSet.Balance.ToString();
     }
     else
     {
         comboBoxAgents.SelectedItem   = null;
         comboBoxClients.SelectedItem  = null;
         comboBoxType.SelectedItem     = null;
         comboBoxSupplier.SelectedItem = null;
         textBoxBalance.Text           = "";
     }
 }
Пример #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewAccounting.SelectedItems.Count == 1)
         {
             AccountingsSet accountingsSet = listViewAccounting.SelectedItems[0].Tag as AccountingsSet;
             Program.zooDb.AccountingsSet.Remove(accountingsSet);
             Program.zooDb.SaveChanges();
             ShowAccounting();
         }
         comboBoxAgents.SelectedItem   = null;
         comboBoxClients.SelectedItem  = null;
         comboBoxSupplier.SelectedItem = null;
         comboBoxType.SelectedItem     = null;
         textBoxBalance.Text           = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }