示例#1
0
文件: FAgregarInf.cs 项目: TPSUM/TP1
        private void buttonCrearInfracc_Click(object sender, EventArgs e)
        {
            int        cod = int.Parse(textBoxCodInfrac.Text);
            Infraccion inf = adm.buscarInfraccion(cod);

            if (inf != null)
            {
                MessageBox.Show("Infraccion ya existente");
            }
            else
            {
                //ver si  hay otra manera de trabajr esto con el combobox
                int seleccionada = comboBoxTipoInfrac.SelectedIndex;
                if (seleccionada == 0)//el primer item del combo es LEVE
                {
                    FDescLeves fdescL = new FDescLeves(adm);
                    fdescL.ShowDialog();
                    int porc10Dias = fdescL.porcDesc10Dias();
                    int porc20Dias = fdescL.porcDesc20Dias();
                    infrac = new Leve(porc20Dias, porc10Dias, cod, textBoxDescInfrac.Text, float.Parse(textBoxImporteInfrac.Text));

                    //MessageBox.Show(infrac.ToString());
                }
                else   //el segundo item del combo el GRAVE
                {
                    FDescGraves fDescG = new FDescGraves(adm);
                    fDescG.ShowDialog();
                    int porDesc = fDescG.porcDescGraves();
                    infrac = new Grave(porDesc, cod, textBoxDescInfrac.Text, float.Parse(textBoxImporteInfrac.Text));
                    //MessageBox.Show(infrac.ToString());
                }
                adm.agregarInfraccion(infrac);
                MessageBox.Show("Infraccion creada con exito");
            }


            /* foreach (Infraccion f in adm.darInfracciones()) {
             *   MessageBox.Show(f.ToString());
             * }*/
        }