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; }
public void VerificarProduccionRepetida_Ok() { 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); bool retorno = anteojo1 == anteojo2; Assert.IsTrue(retorno); }
private void btnFabricar_Click(object sender, EventArgs e) { try { bool biFocal = false; bool blueRay = false; bool desmontable = false; int NUMERO_SERIE = 0; int cantidad = 0; if (int.Parse(textBoxSerie.Text) > 0) { NUMERO_SERIE = int.Parse(textBoxSerie.Text); } else { MessageBox.Show("El N° de serie debe ser mayor a 0"); } if (numericCantidad.Value > 0) { cantidad = (int)numericCantidad.Value; } else { MessageBox.Show("La cantidad a fabricar debe ser mayor a 0"); } ELente LENTE = (ELente)cmbBoxLente.SelectedItem; EArmazon ARMAZON = (EArmazon)cmbBoxArmazon.SelectedItem; EColor COLOR = (EColor)cmbBoxColor.SelectedItem; if (cmbBoxBiFocal.Text == "Si") { biFocal = true; } if (cmbBoxBlueRay.Text == "Si") { blueRay = true; } if (cmbBoxDesmontable.Text == "Si") { desmontable = true; } this.anteojo = new Clasico(desmontable, cantidad, NUMERO_SERIE, ARMAZON, LENTE, COLOR, biFocal, blueRay); this.DialogResult = DialogResult.OK; MessageBox.Show("Procesando...."); } catch { MessageBox.Show("Ingrese todos los campos"); } }
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(); } }