Exemplo n.º 1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (comboBoxBakery.SelectedItem != null && comboBoxMagazine.SelectedItem != null && textBoxPieces.Text != "" && listView_Sales.SelectedItems.Count == 1)
     {
         SalesSet supplySet = listView_Sales.SelectedItems[0].Tag as SalesSet;
         supplySet.IdMagazine = Convert.ToInt32(comboBoxMagazine.SelectedItem.ToString().Split('.')[0]);
         supplySet.IdBakery   = Convert.ToInt32(comboBoxBakery.SelectedItem.ToString().Split('.')[0]);
         supplySet.Pieces     = Convert.ToDouble(textBoxPieces.Text);
         supplySet.SumProfit  = Convert.ToInt64(supplySet.Pieces * supplySet.BakerySet.Profit);
         Program.bdSKI.SaveChanges();
         ShowSales();
     }
 }
Exemplo n.º 2
0
 private void listView_Sales_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listView_Sales.SelectedItems.Count == 1)
     {
         SalesSet supplySet = listView_Sales.SelectedItems[0].Tag as SalesSet;
         comboBoxBakery.SelectedIndex   = comboBoxBakery.FindString(supplySet.IdBakery.ToString());
         comboBoxMagazine.SelectedIndex = comboBoxMagazine.FindString(supplySet.IdMagazine.ToString());
         textBoxPieces.Text             = supplySet.Pieces.ToString();
     }
     else
     {
         comboBoxBakery.SelectedItem   = null;
         comboBoxMagazine.SelectedItem = null;
         textBoxPieces.Text            = "";
     }
 }
Exemplo n.º 3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView_Sales.SelectedItems.Count == 1)
         {
             SalesSet clientSet = listView_Sales.SelectedItems[0].Tag as SalesSet;
             Program.bdSKI.SalesSet.Remove(clientSet);
             Program.bdSKI.SaveChanges();
             ShowSales();
         }
         comboBoxBakery.SelectedItem   = null;
         comboBoxMagazine.SelectedItem = null;
         textBoxPieces.Text            = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }