Ejemplo n.º 1
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(idTxt.Text);

            getId();
            Masina         masina   = ManagerMasini.getMasina(id);
            ModificareForm modifica = new ModificareForm(masina, 2);

            modifica.ShowDialog();
            this.Close();
        }
Ejemplo n.º 2
0
        private void editareBtn_Click(object sender, EventArgs e)
        {
            List <Masina> listaMasini = new List <Masina>(ManagerMasini.getMasiniList());

            afisareListBox.Items.Clear();
            var antetTabel = String.Format("{0,-8}{1,-30}{2,-30}{3,-20}{4,-15}{5,-15}{6,-14}{7,-20}{8,-10}\n", "Id", "Nume vanzator", "Nume cumparator", "Data tranzactie", "Firma", "Model", "Culoare", "An fabricatie", "Pret");

            afisareListBox.Items.Add(antetTabel);

            foreach (Masina m in listaMasini)
            {
                int calculId             = -8 - m.getIdMasina().ToString().Length + 1;
                int calculNumeVanzator   = -30 - m.numeVanzator.Length + 10;
                int calculNumeCumparator = -30 - m.numeCumparator.Length + 7;
                int calculData           = -20 - m.dataTranzactie.Length + 6;
                int calculFirma          = -15 - m.firmaProp.Length + 4;
                int calculModel          = -15 - m.modelProp.Length + 3;
                int calculCuloare        = -14 - m.culoareProp.Length + 4;
                int calculAn             = -20 - m.anFabricatie.ToString().Length + 2;
                int calculPret           = -10 - m.pretProp.ToString().Length + 1;

                var mAfisare = String.Format("\n{0," + calculId.ToString() + "}{1," + calculNumeVanzator.ToString() + "}{2," + calculNumeCumparator.ToString() + "}{3," + calculData.ToString() + "}{4," + calculFirma.ToString() + "}{5," + calculModel.ToString() + "}{6," + calculCuloare.ToString() + "}{7," + calculAn.ToString() + "}{8," + calculPret.ToString() + "}\n",
                                             m.getIdMasina().ToString(), m.numeVanzator, m.numeCumparator, m.dataTranzactie, m.firmaProp, m.modelProp, m.culoareProp, m.anFabricatie.ToString(), m.pretProp.ToString());
                afisareListBox.Items.Add(mAfisare);
                afisareListBox.Items.Add("\t\t" + m.OptiuniAsString);
                afisareListBox.Items.Add(Environment.NewLine);
            }

            IdModifica idModifica = new IdModifica();

            idModifica.ShowDialog();
            int    id     = Convert.ToInt32(idModifica.getId());
            Masina masina = ManagerMasini.getMasina(id);

            afisareListBox.Items.Clear();

            int calculId1             = -8 - masina.getIdMasina().ToString().Length + 1;
            int calculNumeVanzator1   = -30 - masina.numeVanzator.Length + 10;
            int calculNumeCumparator1 = -30 - masina.numeCumparator.Length + 7;
            int calculData1           = -20 - masina.dataTranzactie.Length + 6;
            int calculFirma1          = -15 - masina.firmaProp.Length + 4;
            int calculModel1          = -15 - masina.modelProp.Length + 3;
            int calculCuloare1        = -14 - masina.culoareProp.Length + 4;
            int calculAn1             = -20 - masina.anFabricatie.ToString().Length + 2;
            int calculPret1           = -10 - masina.pretProp.ToString().Length + 1;

            var mAfisare1 = String.Format("\n{0," + calculId1.ToString() + "}{1," + calculNumeVanzator1.ToString() + "}{2," + calculNumeCumparator1.ToString() + "}{3," + calculData1.ToString() + "}{4," + calculFirma1.ToString() + "}{5," + calculModel1.ToString() + "}{6," + calculCuloare1.ToString() + "}{7," + calculAn1.ToString() + "}{8," + calculPret1.ToString() + "}\n",
                                          masina.getIdMasina().ToString(), masina.numeVanzator, masina.numeCumparator, masina.dataTranzactie, masina.firmaProp, masina.modelProp, masina.culoareProp, masina.anFabricatie.ToString(), masina.pretProp.ToString());

            afisareListBox.Items.Add(mAfisare1);
            afisareListBox.Items.Add("\t\t" + masina.OptiuniAsString);
            afisareListBox.Items.Add(Environment.NewLine);
        }
Ejemplo n.º 3
0
        private void modificaBtn_Click(object sender, EventArgs e)
        {
            if (firmaTxt.Text == string.Empty && modelTxt.Text == string.Empty && numeVanzatorTxt.Text == string.Empty && numeCumparatorTxt.Text == string.Empty && culoareTxt.Text == string.Empty && dataTxt.Text == string.Empty && anFTxt.Text == string.Empty && pretTxt.Text == string.Empty && optiuniTxt.Text == string.Empty)
            {
                afisareRichTextBox.Clear();
                List <Masina> listaMasini = new List <Masina>(ManagerMasini.getMasiniList());

                foreach (Masina m in listaMasini)
                {
                    afisareRichTextBox.AppendText(m.toString());
                    afisareRichTextBox.AppendText(Environment.NewLine);
                }
                afisareLbl.Text = "Introduceti noile modificari";

                Modifica modificaForm = new Modifica();
                modificaForm.ShowDialog();
                int    id     = Convert.ToInt32(modificaForm.getId());
                Masina masina = ManagerMasini.getMasina(id);
                firmaTxt.Text          = masina.firmaProp;
                modelTxt.Text          = masina.modelProp;
                anFTxt.Text            = masina.anFabricatie.ToString();
                culoareTxt.Text        = masina.culoareProp;
                numeCumparatorTxt.Text = masina.numeCumparator;
                numeVanzatorTxt.Text   = masina.numeVanzator;
                pretTxt.Text           = masina.pretProp.ToString();
                dataTxt.Text           = masina.dataTranzactie;
                optiuniTxt.Text        = masina.OptiuniAsString;

                idMasina = id;
            }
            else
            {
                Masina masina = ManagerMasini.getMasina(idMasina);
                masina.firmaProp    = firmaTxt.Text;
                masina.modelProp    = modelTxt.Text;
                masina.anFabricatie = Convert.ToInt32(anFTxt.Text);
                masina.culoareProp  = culoareTxt.Text;
                masina.identificaCuloare();
                masina.numeVanzator   = numeVanzatorTxt.Text;
                masina.numeCumparator = numeCumparatorTxt.Text;
                masina.dataTranzactie = dataTxt.Text;
                masina.pretProp       = Convert.ToDouble(pretTxt.Text);
                if (OptiuniAsString() != string.Empty)
                {
                    masina.setOptiuni(OptiuniAsString());
                }

                afisareRichTextBox.Clear();
                afisareRichTextBox.AppendText(masina.toString());
                ResetareControale();
            }
        }
Ejemplo n.º 4
0
        private void modificaBtn_Click(object sender, EventArgs e)
        {
            Masina masina;

            if (nr == 1)
            {
                masina = ManagerMasini.getMasina(id - 1);
            }
            else
            {
                masina = ManagerMasini.getMasina(id);
            }

            masina.Optiuni = new ArrayList();
            masina.Optiuni.AddRange(optiuniSelectate);

            masina.firmaProp     = firmaTxt.Text;
            masina.modelProp     = modelTxt.Text;
            masina.anFabricatie  = Convert.ToInt32(anFTxt.Text);
            masina.CuloareMasina = GetCuloareSelectata();
            masina.identificaCuloare();
            masina.numeVanzator   = numeVanzatorTxt.Text;
            masina.numeCumparator = numeCumparatorTxt.Text;
            masina.dataTranzactie = dataTxt.Text;
            masina.pretProp       = Convert.ToDouble(pretTxt.Text);
            if (OptiuniAsString() != string.Empty)
            {
                masina.setOptiuni(OptiuniAsString());
            }

            masina.dataActualizare = DateTime.Now;

            List <Masina> masini = new List <Masina>(ManagerMasini.getMasiniList());

            File.WriteAllText(@"C:\Users\sebyg\source\repos\ProiectMasiniPIU\ProiectMasiniPIU\MasiniSalvate.txt", String.Empty);

            foreach (Masina m in masini)
            {
                adminMasini.AddMasina(m);
            }

            ResetareControale();
            this.Close();
        }
Ejemplo n.º 5
0
        private void editareBtn_Click(object sender, EventArgs e)
        {
            Masina masina = ManagerMasini.getMasina(idMasinaModificata);

            masina.firmaProp     = firmaTxt.Text;
            masina.modelProp     = modelTxt.Text;
            masina.anFabricatie  = Convert.ToInt32(anFTxt.Text);
            masina.CuloareMasina = GetCuloareSelectata();
            masina.identificaCuloare();
            masina.numeVanzator   = numeVanzatorTxt.Text;
            masina.numeCumparator = numeCumparatorTxt.Text;
            masina.dataTranzactie = dataTxt.Text;
            masina.pretProp       = Convert.ToDouble(pretTxt.Text);
            masina.tipMasina      = tipCmbBox.Text;
            if (OptiuniAsString() != string.Empty)
            {
                masina.setOptiuni(OptiuniAsString());
            }

            this.Close();
        }
Ejemplo n.º 6
0
        private void editareBtn_Click(object sender, EventArgs e)
        {
            albRdb.Checked = false;
            if (firmaTxt.Text == string.Empty && modelTxt.Text == string.Empty && numeVanzatorTxt.Text == string.Empty && numeCumparatorTxt.Text == string.Empty && GetCuloareSelectata() == Culori.culoare_inexistenta && dataTxt.Text == string.Empty && anFTxt.Text == string.Empty && pretTxt.Text == string.Empty && validareOptiuni() == 0 && nrC != 1)
            {
                nrC = 1;
                afisareRichTextBox.Clear();
                List <Masina> listaMasini = new List <Masina>(ManagerMasini.getMasiniList());


                foreach (Masina m in listaMasini)
                {
                    afisareRichTextBox.AppendText(m.toString());
                    afisareRichTextBox.AppendText(Environment.NewLine);
                }
                afisareLbl.Text = "Introduceti noile modificari";

                ModificaT8 modificaForm = new ModificaT8();
                modificaForm.ShowDialog();
                int    id     = Convert.ToInt32(modificaForm.getId());
                Masina masina = ManagerMasini.getMasina(id);
                firmaTxt.Text = masina.firmaProp;
                modelTxt.Text = masina.modelProp;
                anFTxt.Text   = masina.anFabricatie.ToString();
                if (masina.culoareProp.Trim().Equals("alb"))
                {
                    albRdb.Checked = true;
                }
                else if (masina.culoareProp.Trim().Equals("albastru"))
                {
                    albastruRdb.Checked = true;
                }
                else if (masina.culoareProp.Trim().Equals("mov"))
                {
                    movRdb.Checked = true;
                }
                else if (masina.culoareProp.Trim().Equals("galben"))
                {
                    galbenRdb.Checked = true;
                }
                else if (masina.culoareProp.Trim().Equals("portocaliu"))
                {
                    portocaliuRdb.Checked = true;
                }
                else if (masina.culoareProp.Trim().Equals("rosu"))
                {
                    rosuRdb.Checked = true;
                }
                else if (masina.culoareProp.Trim().Equals("verde"))
                {
                    verdeRdb.Checked = true;
                }
                else if (masina.culoareProp.Trim().Equals("maro"))
                {
                    maroRdb.Checked = true;
                }
                else if (masina.culoareProp.Trim().Equals("negru"))
                {
                    negruRdb.Checked = true;
                }

                //culoareTxt.Text = masina.culoareProp;
                numeCumparatorTxt.Text = masina.numeCumparator;
                numeVanzatorTxt.Text   = masina.numeVanzator;
                pretTxt.Text           = masina.pretProp.ToString();
                dataTxt.Text           = masina.dataTranzactie;

                string[] optiuniMasinaCautata = masina.OptiuniAsString.Split(',');
                foreach (string opt in optiuniMasinaCautata)
                {
                    if (opt.Trim().Equals("ABS"))
                    {
                        absCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Airbaguri laterale"))
                    {
                        airbagCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Cruise Control"))
                    {
                        cruiseCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Solar Roof"))
                    {
                        solarCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Conectivitate Bluetooth"))
                    {
                        bluetoothCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Proiectoare Ceata"))
                    {
                        proiectoareCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Pilot automat"))
                    {
                        pilotCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Scaune masaj"))
                    {
                        masajCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Full Leather"))
                    {
                        leatherCheck.Checked = true;
                    }
                }
                //optiuniTxt.Text = masina.optiuniProp;

                idMasina = id;
            }
            else
            {
                nrC = 2;
                Masina masina = ManagerMasini.getMasina(idMasina);
                masina.firmaProp     = firmaTxt.Text;
                masina.modelProp     = modelTxt.Text;
                masina.anFabricatie  = Convert.ToInt32(anFTxt.Text);
                masina.CuloareMasina = GetCuloareSelectata();
                masina.identificaCuloare();
                masina.numeVanzator   = numeVanzatorTxt.Text;
                masina.numeCumparator = numeCumparatorTxt.Text;
                masina.dataTranzactie = dataTxt.Text;
                masina.pretProp       = Convert.ToDouble(pretTxt.Text);
                if (OptiuniAsString() != string.Empty)
                {
                    masina.setOptiuni(OptiuniAsString());
                }

                afisareRichTextBox.Clear();
                afisareRichTextBox.AppendText(masina.toString());
                ResetareControale();
            }
        }
Ejemplo n.º 7
0
        public Modifica(int id)
        {
            InitializeComponent();



            idMasinaModificata = id;

            Masina masina = ManagerMasini.getMasina(id);

            masina.Optiuni = new ArrayList();
            masina.Optiuni.AddRange(optiuniSelectate);

            firmaTxt.Text = masina.firmaProp;
            modelTxt.Text = masina.modelProp;
            anFTxt.Text   = masina.anFabricatie.ToString();
            if (masina.culoareProp.Trim().Equals("alb"))
            {
                albRdb.Checked = true;
            }
            else if (masina.culoareProp.Trim().Equals("albastru"))
            {
                albastruRdb.Checked = true;
            }
            else if (masina.culoareProp.Trim().Equals("mov"))
            {
                movRdb.Checked = true;
            }
            else if (masina.culoareProp.Trim().Equals("galben"))
            {
                galbenRdb.Checked = true;
            }
            else if (masina.culoareProp.Trim().Equals("portocaliu"))
            {
                portocaliuRdb.Checked = true;
            }
            else if (masina.culoareProp.Trim().Equals("rosu"))
            {
                rosuRdb.Checked = true;
            }
            else if (masina.culoareProp.Trim().Equals("verde"))
            {
                verdeRdb.Checked = true;
            }
            else if (masina.culoareProp.Trim().Equals("maro"))
            {
                maroRdb.Checked = true;
            }
            else if (masina.culoareProp.Trim().Equals("negru"))
            {
                negruRdb.Checked = true;
            }

            numeCumparatorTxt.Text = masina.numeCumparator;
            numeVanzatorTxt.Text   = masina.numeVanzator;
            pretTxt.Text           = masina.pretProp.ToString();
            dataTxt.Text           = masina.dataTranzactie;
            tipCmbBox.Text         = masina.tipMasina.ToString();

            string[] optiuniMasinaCautata = masina.OptiuniAsString.Split(',');
            foreach (string opt in optiuniMasinaCautata)
            {
                if (tipCmbBox.Text.Trim().Equals("Sedan"))
                {
                    if (opt.Trim().Equals("ABS"))
                    {
                        absCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Airbaguri laterale"))
                    {
                        airbagCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Cruise Control"))
                    {
                        cruiseCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Solar Roof"))
                    {
                        solarCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Conectivitate Bluetooth"))
                    {
                        bluetoothCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Proiectoare ceata"))
                    {
                        proiectoareCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Pilot automat"))
                    {
                        pilotCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Scaune masaj"))
                    {
                        masajCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Full Leather"))
                    {
                        leatherCheck.Checked = true;
                    }
                }
                else if (tipCmbBox.Text.Trim().Equals("Sport"))
                {
                    if (opt.Trim().Equals("WiFi Hotspot"))
                    {
                        absCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Pachet Alcantara"))
                    {
                        airbagCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Cruise Control"))
                    {
                        cruiseCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Solar Roof"))
                    {
                        solarCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Fibra de carbon"))
                    {
                        bluetoothCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Frane ceramice"))
                    {
                        proiectoareCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Camere laterale"))
                    {
                        pilotCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Smart Suspension"))
                    {
                        masajCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Volan piele"))
                    {
                        leatherCheck.Checked = true;
                    }
                }
                else if (tipCmbBox.Text.Trim().Equals("SUV"))
                {
                    if (opt.Trim().Equals("Track Pace"))
                    {
                        absCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Airbaguri laterale"))
                    {
                        airbagCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Full Leather"))
                    {
                        cruiseCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Keyless Entry"))
                    {
                        solarCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Conectivitate Bluetooth"))
                    {
                        bluetoothCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Head-Up Display"))
                    {
                        proiectoareCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Power Tailgate"))
                    {
                        pilotCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Scaune masaj"))
                    {
                        masajCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Volan piele"))
                    {
                        leatherCheck.Checked = true;
                    }
                }
                else if (tipCmbBox.Text.Trim().Equals("Lux"))
                {
                    if (opt.Trim().Equals("Bara spate"))
                    {
                        absCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Airbaguri laterale"))
                    {
                        airbagCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Cruise Control"))
                    {
                        cruiseCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Solar Roof"))
                    {
                        solarCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Head-Up Display"))
                    {
                        bluetoothCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Keyless Entry"))
                    {
                        proiectoareCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Pilot automat"))
                    {
                        pilotCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Scaune masaj"))
                    {
                        masajCheck.Checked = true;
                    }
                    if (opt.Trim().Equals("Full Leather"))
                    {
                        leatherCheck.Checked = true;
                    }
                }
            }
        }