Ejemplo n.º 1
0
 private void listViewOrders_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewOrders.SelectedItems.Count == 1)
     {
         OrderSpareSet orderSpare = listViewOrders.SelectedItems[0].Tag as OrderSpareSet;
         comboBoxSpare.SelectedIndex = comboBoxSpare.FindString(orderSpare.IdSpare.ToString());
         textBoxDate.Text            = orderSpare.Date.ToString("dd.MM.yyyy");
     }
     else
     {
         comboBoxSpare.SelectedItem = null;
         textBoxDate.Text           = "";
     }
 }
Ejemplo n.º 2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         OrderSpareSet orderSpare = new OrderSpareSet();
         if (comboBoxSpare.SelectedItem != null)
         {
             orderSpare.IdSpare = Convert.ToInt32(comboBoxSpare.SelectedItem.ToString().Split('.')[0]);
         }
         orderSpare.Date = Convert.ToDateTime(textBoxDate.Text);
         Program.OilerDb.OrderSpareSet.Add(orderSpare);
         Program.OilerDb.SaveChanges();
     }
     catch
     {
         { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); }
     }
     ShowOrder();
 }
Ejemplo n.º 3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewOrders.SelectedItems.Count == 1)
         {
             OrderSpareSet orderSpare = listViewOrders.SelectedItems[0].Tag as OrderSpareSet;
             Program.OilerDb.OrderSpareSet.Remove(orderSpare);
             Program.OilerDb.SaveChanges();
             ShowOrder();
         }
         comboBoxSpare.SelectedItem = null;
         textBoxDate.Text           = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 4
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if ((comboBoxSpare.SelectedItem != null) && (textBoxDate.Text != ""))
     {
         if (listViewOrders.SelectedItems.Count == 1)
         {
             OrderSpareSet orderSpare = listViewOrders.SelectedItems[0].Tag as OrderSpareSet;
             if (comboBoxSpare.SelectedItem != null)
             {
                 orderSpare.IdSpare = Convert.ToInt32(comboBoxSpare.SelectedItem.ToString().Split('.')[0]);
             }
             if (textBoxDate.Text != "")
             {
                 orderSpare.Date = Convert.ToDateTime(textBoxDate.Text);
             }
             Program.OilerDb.SaveChanges();
             ShowOrder();
         }
         else
         {
             MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }