Пример #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewSales.SelectedItems.Count == 1)
            {
                SalesSet salesSet = listViewSales.SelectedItems[0].Tag as SalesSet;


                salesSet.Date = (textBoxDate.Text);

                Program.dbmotor.SaveChanges();
                ShowSales();
            }
        }
Пример #2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxClient.SelectedItem != null && textBoxDate.Text != "" && comboBoxCar.SelectedItem != null)
     {
         SalesSet saleSet = new SalesSet();
         saleSet.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
         saleSet.Date     = (textBoxDate.Text);
         saleSet.IdCar    = Convert.ToInt32(comboBoxCar.SelectedItem.ToString().Split('.')[0]);
         Program.dbmotor.SalesSet.Add(saleSet);
         Program.dbmotor.SaveChanges();
         ShowSales();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #3
0
        private void listViewPokupki_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewSales.SelectedItems.Count == 1)
            {
                SalesSet saleSet = listViewSales.SelectedItems[0].Tag as SalesSet;
                comboBoxClient.SelectedIndex = comboBoxClient.FindString(saleSet.IdClient.ToString());

                textBoxDate.Text          = saleSet.Date.ToString();
                comboBoxCar.SelectedIndex = comboBoxCar.FindString(saleSet.IdCar.ToString());
            }
            else
            {
                comboBoxClient.SelectedItem = null;

                textBoxDate.Text         = "";
                comboBoxCar.SelectedItem = null;
            }
        }
Пример #4
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewSales.SelectedItems.Count == 1)
                {
                    SalesSet salesSet = listViewSales.SelectedItems[0].Tag as SalesSet;
                    Program.dbmotor.SalesSet.Remove(salesSet);
                    Program.dbmotor.SaveChanges();
                    ShowSales();
                }

                comboBoxClient.SelectedItem = null;
                textBoxDate.Text            = "";
                comboBoxCar.SelectedItem    = null;
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }