Esempio n. 1
0
 private void listViewOrdersP_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewOrdersP.SelectedItems.Count == 1)
     {
         Order_F orders = listViewOrdersP.SelectedItems[0].Tag as Order_F;
         comboBoxProduction.SelectedIndex = comboBoxProduction.FindString(orders.id_production.ToString());
         comboBoxOrder.SelectedIndex      = comboBoxOrder.FindString(orders.Id.ToString());
         if (orders.Date != null)
         {
             textBoxDate.Text = Convert.ToString(orders.Date).Substring(0, 10);
         }
     }
     else
     {
         comboBoxOrder.SelectedItem      = null;
         comboBoxProduction.SelectedItem = null;
         textBoxDate.Text = "";
     }
 }
Esempio n. 2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewOrdersP.SelectedItems.Count == 1)
         {
             Order_F FL = listViewOrdersP.SelectedItems[0].Tag as Order_F;
             Program.wtfDb.Order_F.Remove(FL);
             Program.wtfDb.SaveChanges();
             ShowOrdersP();
         }
         comboBoxOrder.SelectedItem      = null;
         comboBoxProduction.SelectedItem = null;
         textBoxDate.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (comboBoxOrder.SelectedItem != null && comboBoxProduction.SelectedItem != null)
            {
                Order_F orders = new Order_F();

                orders.Id            = Convert.ToInt32(comboBoxOrder.SelectedItem.ToString().Split('.')[0]);
                orders.id_production = Convert.ToInt32(comboBoxProduction.SelectedItem.ToString().Split('.')[0]);
                if (textBoxDate.Text.Length == 10)
                {
                    orders.Date = Convert.ToDateTime(textBoxDate.Text);
                }
                Program.wtfDb.Order_F.Add(orders);
                Program.wtfDb.SaveChanges();
                ShowOrdersP();
                showOrders();
            }
            else
            {
                MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }