Esempio n. 1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxAgent.SelectedItem != null && comboBoxClient.SelectedItem != null && comboBoxProduct.SelectedItem != null)
         {
             DealSet zakaz = new DealSet();
             zakaz.IdAgent   = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
             zakaz.IdClient  = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
             zakaz.IdProduct = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]);
             if (zakaz.IdAgent == null || zakaz.IdClient == null || zakaz.IdProduct == null)
             {
                 throw new Exception("Обязательное заполнение полей!");
             }
             Program.furn.DealSet.Add(zakaz);
             Program.furn.SaveChanges();
             ShowZakaz();
         }
         else
         {
             MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception a)
     {
         MessageBox.Show(" " + a.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewZakaz.SelectedItems.Count == 1)
            {
                DealSet zakaz = listViewZakaz.SelectedItems[0].Tag as DealSet;
                zakaz.IdAgent   = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
                zakaz.IdClient  = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
                zakaz.IdProduct = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]);

                Program.furn.SaveChanges();
                ShowZakaz();
            }
        }
Esempio n. 3
0
 private void listViewZakaz_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewZakaz.SelectedItems.Count == 1)
     {
         DealSet zakaz = listViewZakaz.SelectedItems[0].Tag as DealSet;
         comboBoxAgent.SelectedIndex   = comboBoxAgent.FindString(zakaz.IdAgent.ToString());
         comboBoxClient.SelectedIndex  = comboBoxClient.FindString(zakaz.IdClient.ToString());
         comboBoxProduct.SelectedIndex = comboBoxProduct.FindString(zakaz.IdProduct.ToString());
     }
     else
     {
         comboBoxAgent.SelectedItem   = null;
         comboBoxClient.SelectedItem  = null;
         comboBoxProduct.SelectedItem = null;
     }
 }
Esempio n. 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewZakaz.SelectedItems.Count == 1)
         {
             DealSet zakaz = listViewZakaz.SelectedItems[0].Tag as DealSet;
             if (zakaz.IdAgent == null || zakaz.IdClient == null || zakaz.IdProduct == null)
             {
                 throw new Exception("Удалите данные клиента или менеджера!");
             }
             Program.furn.DealSet.Remove(zakaz);
             Program.furn.SaveChanges();
             ShowZakaz();
         }
         comboBoxAgent.SelectedItem   = null;
         comboBoxClient.SelectedItem  = null;
         comboBoxProduct.SelectedItem = null;
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }