private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SeteazaDiscounts adaugaDiscounts = new SeteazaDiscounts(companie.Rute.Keys.ToList());

            adaugaDiscounts.StartPosition = FormStartPosition.CenterParent;
            var listaRute = new List <RutaAeriana>();
            var ruta      = GetRutaOfSelectedDiscount();

            if (ruta == null)
            {
                return;
            }
            listaRute.Add(GetRutaOfSelectedDiscount());
            adaugaDiscounts.RuteAeriene.DataSource = listaRute;
            adaugaDiscounts.RuteAeriene.Enabled    = false;
            if (adaugaDiscounts.ShowDialog(this) == DialogResult.OK)
            {
                if (adaugaDiscounts.Discount != null)
                {
                    companie.AdaugaDiscount(adaugaDiscounts.Ruta, adaugaDiscounts.Discount);
                    tvDiscounts.Nodes.Clear();
                    InitDiscountTree();
                }
            }
        }
        private void updateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SeteazaDiscounts adaugaDiscounts = new SeteazaDiscounts(companie.Rute.Keys.ToList());

            adaugaDiscounts.StartPosition = FormStartPosition.CenterParent;
            var listaRute = new List <RutaAeriana>();
            var ruta      = GetRutaOfSelectedDiscount();

            if (ruta == null)
            {
                return;
            }
            listaRute.Add(GetRutaOfSelectedDiscount());
            adaugaDiscounts.RuteAeriene.DataSource     = listaRute;
            adaugaDiscounts.RuteAeriene.Enabled        = false;
            adaugaDiscounts.AdaugaDiscountsButton.Text = "Modifică";
            if (tvDiscounts.SelectedNode.Tag is IDiscount && !(tvDiscounts.SelectedNode.Tag is DiscountManager))
            {
                adaugaDiscounts.SetDiscount(tvDiscounts.SelectedNode.Tag as IDiscount);
            }
            else if (tvDiscounts.SelectedNode.Tag is DiscountManager)
            {
                var dManager = tvDiscounts.SelectedNode.Tag as DiscountManager;
                ModificaDiscountManager modificaDiscountManager = new ModificaDiscountManager();
                modificaDiscountManager.ProcentDiscountMaxim = dManager.ProcentDiscountMaxim * 100;
                modificaDiscountManager.StartPosition        = FormStartPosition.CenterParent;
                modificaDiscountManager.ShowDialog(this);
                dManager.ProcentDiscountMaxim = modificaDiscountManager.ProcentDiscountMaxim;

                tvDiscounts.Nodes.Clear();
                InitDiscountTree();

                return;
            }

            if (adaugaDiscounts.ShowDialog(this) == DialogResult.OK)
            {
                if (adaugaDiscounts.Discount != null)
                {
                    (tvDiscounts.SelectedNode.Tag as DiscountGeneric).CopyDiscount(adaugaDiscounts.Discount);
                    var parent = tvDiscounts.SelectedNode.Parent;
                    parent.Nodes.Clear();
                    InitModifiedDiscountSubTree(parent, (parent.Tag as DiscountManager).Discounts);
                    parent.ExpandAll();
                }
            }
        }
Ejemplo n.º 3
0
        private void valoriDiscountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SeteazaDiscounts adaugaDiscounts = new SeteazaDiscounts(AirMoldova.Rute.Keys.ToList());

            adaugaDiscounts.StartPosition = FormStartPosition.CenterParent;
            var result = adaugaDiscounts.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                AirMoldova.DiscountMaxim = adaugaDiscounts.DiscountMaxim;
                AirMoldova.AdaugaDiscount(adaugaDiscounts.Ruta, adaugaDiscounts.Discounts);
            }
            else if (result == DialogResult.Yes)
            {
                AirMoldova.DiscountMaxim = adaugaDiscounts.DiscountMaxim;
                foreach (var ruta in AirMoldova.Rute)
                {
                    AirMoldova.AdaugaDiscount(ruta.Key, adaugaDiscounts.Discounts);
                }
            }
        }