Ejemplo n.º 1
0
        private void btnBuyCar_Click(object sender, EventArgs e)
        {
            if (selectedCar == null)
            {
                MessageBox.Show("You should select the car");
            }
            else
            {
                var confirmResult = MessageBox.Show("Are you sure to order this Car ??",
                                                    "Confirm Order!!", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    SelledCar sell = new SelledCar
                    {
                        ID        = selectedCar.ID,
                        ModelIDs  = selectedCar.ModelID,
                        YearIDs   = selectedCar.YearID,
                        FuelIDs   = selectedCar.FuelID,
                        EpowIDs   = selectedCar.EPowID,
                        StatusIDs = selectedCar.StatusID,
                        By        = lbUserNameBy.Text,
                    };


                    db.SelledCars.Add(sell);
                    db.SaveChanges();
                    UpdateSelled();
                }
                else
                {
                    MessageBox.Show("You did't order any car");
                }
            }
        }
Ejemplo n.º 2
0
        private void dgvSelledCar_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = (int)dgvSelledCar.Rows[e.RowIndex].Cells[0].Value;

            selectedSelledCar = db.SelledCars.Where(s => s.ID == id).FirstOrDefault();
        }