Example #1
0
        private void AdmListCars_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!carShowroom1.IfSaved)
            {
                var res = MessageBox.Show("Save the data before exit?", "Verification", MessageBoxButtons.YesNoCancel);
                switch (res)
                {
                case DialogResult.Cancel:
                    e.Cancel = true;
                    break;

                case DialogResult.Yes:
                    carShowroom1.Save();
                    break;

                case DialogResult.No:
                    break;
                }
            }
        }
Example #2
0
        private void RegistrationBut_Click(object sender, EventArgs e)
        {
            carShowroom1.Load();
            var fo = new Register();

            if (fo.ShowDialog() == DialogResult.OK)
            {
                carShowroom1.Buyers.Add(fo.Buyer);
                carShowroom1.Save();
            }
        }
Example #3
0
        private void AccountBut_Click(object sender, EventArgs e)
        {
            carShowroom1.Load();
            foreach (var b in carShowroom1.Buyers)
            {
                if (b.Name.Equals(CurentBuyer.Name))
                {
                    CurentBuyer = b;
                }
            }
            var f = new Register(CurentBuyer);

            f.ShowDialog();
            carShowroom1.Save();
        }
Example #4
0
        private void BuyBut_Click(object sender, EventArgs e)
        {
            if (carShowroom1.ShoppingCart.Count == 0)
            {
                return;
            }
            var ToBuy = CarsdataGridView.SelectedRows[0].DataBoundItem as Car;
            var res   = MessageBox.Show($"Buy {ToBuy.Model}?", "Сonfirmation", MessageBoxButtons.YesNo);

            if (res == DialogResult.No)
            {
                return;
            }
            List <Car> ForBuy = new List <Car>();

            ForBuy.Add(ToBuy);
            Report buy = new Report(ForBuy, CurentBuyer.Name, DateTime.Now);

            carShowroom1.Reports.Add(buy);
            foreach (var c in carShowroom1.Cars)
            {
                if (c.ID.Equals(ToBuy.ID))
                {
                    carShowroom1.Cars.Remove(c);
                    break;
                }
            }
            foreach (var c in carShowroom1.ShoppingCart)
            {
                if (c.ID.Equals(ToBuy.ID))
                {
                    carShowroom1.ShoppingCart.Remove(c);
                    break;
                }
            }
            carShowroom1.Save();
            carBindingSource.ResetBindings(false);
        }
Example #5
0
 private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     carShowroom1.Save();
     carShowroom1.IfSaved = true;
 }