Exemplo n.º 1
0
 private void listViewCustoms_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewCustoms.SelectedItems.Count == 1)
     {
         CustomsSet customSet = listViewCustoms.SelectedItems[0].Tag as CustomsSet;
         comboBoxProvider.SelectedIndex = comboBoxProvider.FindString(customSet.IdProvider.ToString());
         textBoxNameProduct.Text        = customSet.NameProduct;
         textBoxMkProduct.Text          = customSet.MkProduct.ToString();
         textBoxNumberProduct.Text      = customSet.NumberProduct.ToString();
         textBoxPrice.Text          = customSet.Price.ToString();
         comboBoxTypeProduct.Text   = customSet.TypeProduct;
         dateTimePickerCustom.Value = customSet.Date;
         comboBoxStatus.Text        = customSet.Status;
     }
     else
     {
         comboBoxStatus.SelectedItem      = null;
         comboBoxTypeProduct.SelectedItem = null;
         comboBoxProvider.SelectedItem    = null;
         textBoxNameProduct.Text          = "";
         textBoxMkProduct.Text            = "";
         textBoxNumberProduct.Text        = "";
         textBoxPrice.Text          = "";
         dateTimePickerCustom.Value = DateTime.Now;
     }
 }
Exemplo n.º 2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewCustoms.SelectedItems.Count == 1)
         {
             CustomsSet customSet = listViewCustoms.SelectedItems[0].Tag as CustomsSet;
             Program.zooDb.CustomsSet.Remove(customSet);
             Program.zooDb.SaveChanges();
             ShowCustoms();
         }
         else
         {
             comboBoxStatus.SelectedItem      = null;
             comboBoxTypeProduct.SelectedItem = null;
             comboBoxProvider.SelectedItem    = null;
             textBoxNameProduct.Text          = "";
             textBoxMkProduct.Text            = "";
             textBoxNumberProduct.Text        = "";
             textBoxPrice.Text          = "";
             dateTimePickerCustom.Value = DateTime.Now;
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxTypeProduct.SelectedItem != null && comboBoxProvider.SelectedItem != null)
     {
         CustomsSet customSet = new CustomsSet();
         customSet.IdProvider    = Convert.ToInt32(comboBoxProvider.SelectedItem.ToString().Split('.')[0]);
         customSet.NameProduct   = textBoxNameProduct.Text;
         customSet.MkProduct     = Convert.ToInt32(textBoxMkProduct.Text);
         customSet.NumberProduct = Convert.ToInt32(textBoxNumberProduct.Text);
         customSet.Price         = Convert.ToInt32(textBoxPrice.Text);
         customSet.Date          = dateTimePickerCustom.Value;
         if (comboBoxTypeProduct.SelectedIndex == 0)
         {
             customSet.TypeProduct = "Корм";
         }
         else if (comboBoxTypeProduct.SelectedIndex == 1)
         {
             customSet.TypeProduct = "Игрушки";
         }
         else if (comboBoxTypeProduct.SelectedIndex == 2)
         {
             customSet.TypeProduct = "Поводки";
         }
         else
         {
             customSet.TypeProduct = "Медикаменты";
         }
         if (comboBoxStatus.SelectedIndex == 0)
         {
             customSet.Status = "Заказ формируется";
         }
         else if (comboBoxStatus.SelectedIndex == 1)
         {
             customSet.Status = "Отправка заказа";
         }
         else if (comboBoxStatus.SelectedIndex == 2)
         {
             customSet.Status = "Заказ отправлен";
         }
         else
         {
             customSet.Status = "Доставлено";
         }
         Program.zooDb.CustomsSet.Add(customSet);
         Program.zooDb.SaveChanges();
         ShowCustoms();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 4
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxTypeProduct.SelectedItem != null && comboBoxProvider.SelectedItem != null)
         {
             if (listViewCustoms.SelectedItems.Count == 1)
             {
                 CustomsSet customSet = listViewCustoms.SelectedItems[0].Tag as CustomsSet;
                 customSet.IdProvider    = Convert.ToInt32(comboBoxProvider.SelectedItem.ToString().Split('.')[0]);
                 customSet.NameProduct   = textBoxNameProduct.Text;
                 customSet.MkProduct     = Convert.ToInt32(textBoxMkProduct.Text);
                 customSet.NumberProduct = Convert.ToInt32(textBoxNumberProduct.Text);
                 customSet.Price         = Convert.ToInt32(textBoxPrice.Text);
                 customSet.Date          = dateTimePickerCustom.Value;
                 if (comboBoxTypeProduct.SelectedIndex == 0)
                 {
                     customSet.TypeProduct = "Корм";
                 }
                 else if (comboBoxTypeProduct.SelectedIndex == 1)
                 {
                     customSet.TypeProduct = "Игрушки";
                 }
                 else if (comboBoxTypeProduct.SelectedIndex == 2)
                 {
                     customSet.TypeProduct = "Поводки";
                 }
                 else
                 {
                     customSet.TypeProduct = "Медикаменты";
                 }
                 if (comboBoxStatus.SelectedIndex == 0)
                 {
                     customSet.Status = "Заказ формируется";
                 }
                 else if (comboBoxStatus.SelectedIndex == 1)
                 {
                     customSet.Status = "Отправка заказа";
                 }
                 else if (comboBoxStatus.SelectedIndex == 2)
                 {
                     customSet.Status = "Заказ отправлен";
                 }
                 else
                 {
                     customSet.Status = "Доставлено";
                 }
                 Program.zooDb.SaveChanges();
                 ShowCustoms();
             }
             else
             {
                 comboBoxStatus.SelectedItem      = null;
                 comboBoxTypeProduct.SelectedItem = null;
                 comboBoxProvider.SelectedItem    = null;
                 textBoxNameProduct.Text          = "";
                 textBoxMkProduct.Text            = "";
                 textBoxNumberProduct.Text        = "";
                 textBoxPrice.Text          = "";
                 dateTimePickerCustom.Value = DateTime.Now;
             }
         }
         else
         {
             MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex) { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }