Example #1
0
        private void btnLeer_Click(object sender, EventArgs e)
        {
            if (File.Exists(deposito.DireccionXml))
            {
                DialogResult Confirmacion;

                Confirmacion = MessageBox.Show("Si carga los datos XML de los anteojos fabricados, se sobreescribiran los datos actuales", "AVISO", MessageBoxButtons.OKCancel);

                if (Confirmacion == DialogResult.OK)
                {
                    this.deposito.Lista.Clear();
                    this.deposito = Archivos <Anteojo> .CargarFabrica(deposito);

                    this.dt.Rows.Clear();
                    foreach (Anteojo item in this.deposito.Lista)
                    {
                        this.AgregarADataT(item);
                    }
                    MessageBox.Show("Se cargaron los datos del XML", "Cargado correctamente");
                }
            }
            else
            {
                MessageBox.Show("No existe el archivo", "Error al cargar el XML");
            }
        }
        public void AgregarProduccionRepetida()
        {
            DepositoFabrica <Anteojo> deposito = new DepositoFabrica <Anteojo>("Test Fabrica");
            Clasico anteojo1 = new Clasico(false, 1, 1, EArmazon.Acero, ELente.Plastico, EColor.Blanco, true, true);
            Clasico anteojo2 = new Clasico(false, 1, 1, EArmazon.Acero, ELente.Plastico, EColor.Blanco, true, true);

            deposito += anteojo1;
            deposito += anteojo2;
        }
        static void Main(string[] args)
        {
            Tanque T1 = new Tanque(TipoCañon.KwK_43, 5, TipoMotor.Maybach_HL_230_P30, 10, TipoAmetralladoras.MG_34, 5);  // Tiger

            Tanque T2 = new Tanque(TipoCañon.M1_76_mm, 2, TipoMotor.R975_C4, 2, TipoAmetralladoras.Browning_M1919A4, 3); // Sherman

            Tanque T3 = new Tanque(TipoCañon.F34_de_76_2_mm, 3, TipoMotor.Diesel_V2_34, 3, TipoAmetralladoras.DT, 6);    // T-34

            Avion A1 = new Avion(Cañones.Hispano_M2, 2, MotorRadial.Pratt_and_Whitney_R, 5, Ametralladoras.Browning_M2, 10);

            Avion A2 = new Avion(Cañones.MG_151_20, 10, MotorRadial.Gnome_Rhône_14M_5, 11, Ametralladoras.MG_17, 9);

            Avion A3 = new Avion(Cañones.Nudelman_Suranov_NS_23, 1, MotorRadial.Daimler_Benz_DB_603, 3, Ametralladoras.Berezin_UB, 5);

            Fabrica <Tanque, Avion> fabricarTanquesyAviones = new Fabrica <Tanque, Avion>(100);

            DepositoFabrica <Tanque, Avion> depositofabrica = new DepositoFabrica <Tanque, Avion>();

            T1.IdentificarTanque();
            T2.IdentificarTanque();
            T3.IdentificarTanque();

            A1.IdentificarAvion();
            A2.IdentificarAvion();
            A3.IdentificarAvion();

            fabricarTanquesyAviones.AdministrarCapacidad();

            fabricarTanquesyAviones.ValidarIngresoTanques(T1);
            fabricarTanquesyAviones.ValidarIngresoTanques(T2);
            fabricarTanquesyAviones.ValidarIngresoTanques(T3);

            fabricarTanquesyAviones.ValidarIngresoAviones(A1);
            fabricarTanquesyAviones.ValidarIngresoAviones(A2);
            fabricarTanquesyAviones.ValidarIngresoAviones(A3);

            Console.WriteLine(fabricarTanquesyAviones.EmsambladoTanques(T1));
            Console.WriteLine(fabricarTanquesyAviones.EmsambladoTanques(T2));
            Console.WriteLine(fabricarTanquesyAviones.EmsambladoTanques(T3));

            Console.WriteLine(fabricarTanquesyAviones.EmsambladoAviones(A1));
            Console.WriteLine(fabricarTanquesyAviones.EmsambladoAviones(A2));
            Console.WriteLine(fabricarTanquesyAviones.EmsambladoAviones(A3));

            Console.WriteLine(fabricarTanquesyAviones.Mostrar());

            Console.ReadKey();
        }
Example #4
0
        private void btnCargarBD_Click(object sender, EventArgs e)
        {
            Sol        anteojoSol;
            Clasico    anteojoClasico;
            Graduables anteojoGraduable;


            try
            {
                this.conexion.Open();
                SqlCommand    traerTodo = new SqlCommand("SELECT * FROM TablaAnteojos", this.conexion);
                SqlDataReader dtReader  = traerTodo.ExecuteReader();
                this.deposito.Lista.Clear();
                this.dt.Rows.Clear();
                while (dtReader.Read() != false)
                {
                    switch (dtReader["Tipo"].ToString())
                    {
                    case "Clasico":
                        anteojoClasico = new Clasico(Convert.ToBoolean(dtReader["Desmontable"].ToString()), Convert.ToInt32(dtReader["Cantidad"]), Convert.ToInt32(dtReader["NroSerie"]), (EArmazon)Enum.Parse(typeof(EArmazon), dtReader["Armazon"].ToString()), (ELente)Enum.Parse(typeof(ELente), dtReader["Lente"].ToString()), (EColor)Enum.Parse(typeof(EColor), dtReader["Color"].ToString()), Convert.ToBoolean(dtReader["BiFocal"].ToString()), Convert.ToBoolean(dtReader["BlueRay"].ToString()));
                        this.deposito += (Anteojo)anteojoClasico;
                        this.AgregarADataT((Anteojo)anteojoClasico);
                        break;

                    case "Sol":
                        anteojoSol     = new Sol(Convert.ToBoolean(dtReader["Polarizado"].ToString()), Convert.ToInt32(dtReader["Cantidad"]), Convert.ToInt32(dtReader["NroSerie"]), (EArmazon)Enum.Parse(typeof(EArmazon), dtReader["Armazon"].ToString()), (ELente)Enum.Parse(typeof(ELente), dtReader["Lente"].ToString()), (EColor)Enum.Parse(typeof(EColor), dtReader["Color"].ToString()), Convert.ToBoolean(dtReader["BiFocal"].ToString()), Convert.ToBoolean(dtReader["BlueRay"].ToString()));
                        this.deposito += (Anteojo)anteojoSol;
                        this.AgregarADataT((Anteojo)anteojoSol);
                        break;

                    case "Graduables":
                        anteojoGraduable = new Graduables(float.Parse(dtReader["GraduacionOI"].ToString()), float.Parse(dtReader["GraduacionOD"].ToString()), Convert.ToBoolean(dtReader["Desmontable"].ToString()), Convert.ToInt32(dtReader["Cantidad"]), Convert.ToInt32(dtReader["NroSerie"]), (EArmazon)Enum.Parse(typeof(EArmazon), dtReader["Armazon"].ToString()), (ELente)Enum.Parse(typeof(ELente), dtReader["Lente"].ToString()), (EColor)Enum.Parse(typeof(EColor), dtReader["Color"].ToString()), Convert.ToBoolean(dtReader["BiFocal"].ToString()), Convert.ToBoolean(dtReader["BlueRay"].ToString()));
                        this.deposito   += (Anteojo)anteojoGraduable;
                        this.AgregarADataT((Anteojo)anteojoGraduable);
                        break;
                    }
                }
                MessageBox.Show("Se cargaron los datos correctamente");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.conexion.Close();
            }
        }
Example #5
0
        public Menu()
        {
            InitializeComponent();
            this.deposito = new DepositoFabrica <Anteojo>("Fabrica");
            this.deposito.DireccionXml = AppDomain.CurrentDomain.BaseDirectory + "AnteojosProducidos.xml";

            ///CAMBIAR
            this.conexion = new SqlConnection(@"Data Source = DESKTOP-ILTUKAA\SQLEXPRESS; Initial Catalog = dbAnteojosTP4; Integrated Security = True");
            this.Configurardtable();
            this.eventoImagen += this.MostrarImagen;
            this.hiloAnteojos  = new Thread(this.CambiarImagen);

            if (!this.hiloAnteojos.IsAlive)
            {
                this.hiloAnteojos.Start();
            }

            this.dtable.DataSource = this.dt;
        }
Example #6
0
        private void btnFabricarSol_Click(object sender, EventArgs e)
        {
            frmFabricarSol frmSol = new frmFabricarSol();

            this.Hide();
            if (frmSol.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    this.deposito += (Anteojo)frmSol.Anteojo;
                    MessageBox.Show("Fabricacion exitosa!");
                    this.AgregarADataT((Anteojo)frmSol.Anteojo);
                }
                catch (ProduccionRepetidaException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            this.Show();
        }
Example #7
0
 public frmDeposito(DepositoFabrica <Anteojo> fabrica)
 {
     InitializeComponent();
     anteojos = fabrica;
     MostrarDeposito();
 }