示例#1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewChekProduct.SelectedItems.Count == 1)
     {
         ProductTraking product = listViewChekProduct.SelectedItems[0].Tag as ProductTraking;
         product.IdClient  = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
         product.IdProduct = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]);
         product.IdWorker  = Convert.ToInt32(comboBoxWorker.SelectedItem.ToString().Split('.')[0]);
         Program.mpgc.SaveChanges();
         ShowProductTraking();
     }
 }
示例#2
0
 private void listViewChekProduct_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewChekProduct.SelectedItems.Count == 1)
     {
         ProductTraking product = listViewChekProduct.SelectedItems[0].Tag as ProductTraking;
         comboBoxClient.SelectedIndex  = comboBoxClient.FindString(product.IdClient.ToString());
         comboBoxWorker.SelectedIndex  = comboBoxWorker.FindString(product.IdWorker.ToString());
         comboBoxProduct.SelectedIndex = comboBoxProduct.FindString(product.IdProduct.ToString());
     }
     else
     {
         comboBoxClient.SelectedItem  = null;
         comboBoxProduct.SelectedItem = null;
         comboBoxWorker.SelectedItem  = null;
     }
 }
示例#3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxClient.SelectedItem != null && comboBoxProduct.SelectedItem != null && comboBoxWorker.SelectedItem != null)
     {
         ProductTraking product = new ProductTraking();
         product.IdClient  = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
         product.IdProduct = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]);
         product.IdWorker  = Convert.ToInt32(comboBoxWorker.SelectedItem.ToString().Split('.')[0]);
         Program.mpgc.ProductTraking.Add(product);
         Program.mpgc.SaveChanges();
         ShowProductTraking();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewChekProduct.SelectedItems.Count == 1)
         {
             ProductTraking product = listViewChekProduct.SelectedItems[0].Tag as ProductTraking;
             Program.mpgc.ProductTraking.Remove(product);
             Program.mpgc.SaveChanges();
             ShowProductTraking();
         }
         comboBoxClient.SelectedItem  = null;
         comboBoxProduct.SelectedItem = null;
         comboBoxWorker.SelectedItem  = null;
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }