/// <summary> /// Constructor parametrizado /// </summary> /// <param name="arma"></param> public FormVenta(Armamento arma) : this() { this.a = arma; this.lblNombreVenta.Text = arma.Nombre; this.lblTipoVenta.Text = arma.TipoArmamento.ToString(); this.lblOrigenVenta.Text = arma.Origen; this.lblPrecioVenta.Text = arma.Precio.ToString(); this.lblStockVenta.Text = arma.Stock.ToString(); }
private void toolStripButton4_Click(object sender, EventArgs e) { string num_cadastro = txtAnoCadastro.Text + "/" + txtNumCadastro.Text; armamento = new Armamento(txtEspecie.Text, txtMarca.Text, txtModelo.Text, txtNumArma.Text, txtCalibre.Text, cmbCapTiros.Text, cmbFuncionamento.Text, txtAcabamento.Text, cmbQtdCanos.Text, txtCompCano.Text, txtTipoAlma.Text, txtQtdRaia.Text, txtSentRaia.Text, txtPaisFab.Text, txtNumNF.Text, dtpDataNF.Text, txtCidadeEmissao.Text, dtpDataEmissaoDoc.Text, txtNumRegistro.Text, dtpDataValidade.Text, num_cadastro, id); _armamentoServices = new ArmamentoServices(); MessageBox.Show(_armamentoServices.CadastrarArmamento(armamento)); }
/// <summary> /// Constructor parametrizado /// </summary> /// <param name="a"></param> public FormCarga(Armamento a) : this() { this.a = a; this.txtNombre.Text = a.Nombre; this.cmbTipo.Text = a.TipoArmamento.ToString(); this.txtOrigen.Text = a.Origen; this.txtPrecio.Text = a.Precio.ToString(); this.txtStock.Text = a.Stock.ToString(); }
private void btnCadastrar_Click(object sender, EventArgs e) { String om = cmbOM.SelectedItem != null?cmbOM.SelectedItem.ToString() : ""; String nomeCompleto = txtNomeCompleto.Text; String nomeGuerra = txtNomeGuerra.Text; String patente = cmbPatente.SelectedItem != null?cmbPatente.SelectedItem.ToString() : ""; String registro = txtRegistro.Text; if (Dados.verificarPreenchimento(new List <String> { om, nomeCompleto, nomeGuerra, patente, registro })) { Militar mil = new Militar(); mil.NomeCompleto = nomeCompleto; mil.NomeDeGuerra = nomeGuerra; mil.Patente = patente; mil.Registro = new RegistroMilitar(); mil.Registro.Registro = registro; mil.Registro.Militar = mil; mil.Registro.Patente = patente; mil.OmPertencente = (OrganizacaoMilitar)cmbOM.SelectedItem; mil.OmPertencente.Militares.Add(mil); mil.Punicao = false; Armamento armamento = new Armamento(); armamento.Codigo = (new Random()).Next(); armamento.OmPertencente = ((OrganizacaoMilitar)cmbOM.SelectedItem).Nome; armamento.EmUso = false; mil.Armamento = armamento; FichaDeFATDs fichaFATD = new FichaDeFATDs(); fichaFATD.Militar = mil; fichaFATD.OmPertencente = ((OrganizacaoMilitar)cmbOM.SelectedItem).Nome; mil.FichasFATD.Add(fichaFATD); //dataNascimento Dados.ListaMilitares.Add(mil); var form = new frmInicio(); form.Show(); this.Hide(); } }
/// <summary> /// Abrirá el formulario Vender, /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnVender_Click(object sender, EventArgs e) { int i = this.dgvGrilla.SelectedRows[0].Index; DataRow fila = this.dt.Rows[i]; if (fila["tipo"].ToString() == "Fusil") { arma = new Fusil(int.Parse(fila["id"].ToString()), fila["nombre"].ToString(), Armamento.ETipo.fusil, fila["origen"].ToString(), int.Parse(fila["precio"].ToString()), int.Parse(fila["stock"].ToString())); } else if (fila["tipo"].ToString() == "Pistola") { arma = new Pistola(int.Parse(fila["id"].ToString()), fila["nombre"].ToString(), Armamento.ETipo.pistola, fila["origen"].ToString(), int.Parse(fila["precio"].ToString()), int.Parse(fila["stock"].ToString())); } else if (fila["tipo"].ToString() == "Dron") { arma = new Dron(int.Parse(fila["id"].ToString()), fila["nombre"].ToString(), Armamento.ETipo.dron, fila["origen"].ToString(), int.Parse(fila["precio"].ToString()), int.Parse(fila["stock"].ToString())); } else if (fila["tipo"].ToString() == "Explosivo") { arma = new Explosivo(int.Parse(fila["id"].ToString()), fila["nombre"].ToString(), Armamento.ETipo.explosivo, fila["origen"].ToString(), int.Parse(fila["precio"].ToString()), int.Parse(fila["stock"].ToString())); } FormVenta frm = new FormVenta(arma); frm.StartPosition = FormStartPosition.CenterScreen; if (frm.ShowDialog() == DialogResult.OK) { dgvGrilla.Update(); dgvGrilla.Refresh(); } }
/// <summary> /// Método estático para eliminar un arma de la base de datos. /// </summary> /// <returns>Retora booleano (true) si se eliminó de la basde de datos o (false) si no.</returns> public static bool Eliminar(this Armamento arma) { ArmamentoBD armaBD = new ArmamentoBD(); return(armaBD.EliminarArma(arma)); }
/// <summary> /// Método estático para moodificar/actualizar un arma de la base de datos. /// </summary> /// <returns>Retora booleano (true) si se modificó en la basde de datos o (false) si no.</returns> public static bool Modificar(this Armamento arma) { ArmamentoBD armaBD = new ArmamentoBD(); return(armaBD.ModificarArma(arma)); }
/// <summary> /// Constructor default /// </summary> public FormCarga() { InitializeComponent(); this.a = new Armamento(); evento += this.Limpiar; }
/// <summary> /// Crea un objeto de tipo Producto y lo agrega a la base de datos /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCargar_Click(object sender, EventArgs e) { try { int precio; int stock; this.txtPrecio.Text = this.txtPrecio.Text.Replace(".", ","); if (int.TryParse(this.txtPrecio.Text, out precio) && int.TryParse(this.txtStock.Text, out stock)) { if (precio >= 0 && stock >= 0) { if ((Armamento.ETipo) this.cmbTipo.SelectedValue == Armamento.ETipo.fusil) { a = new Fusil(this.txtNombre.Text, Armamento.ETipo.fusil, this.txtOrigen.Text, precio, stock); if (Inventario.Armas + a) { MessageBox.Show("Cargado con exito"); MessageBox.Show(a.ToString()); } } else if ((Armamento.ETipo) this.cmbTipo.SelectedValue == Armamento.ETipo.pistola) { a = new Pistola(this.txtNombre.Text, Armamento.ETipo.pistola, this.txtOrigen.Text, precio, stock); if (Inventario.Armas + a) { MessageBox.Show("Cargado con exito"); MessageBox.Show(a.ToString()); } } else if ((Armamento.ETipo) this.cmbTipo.SelectedValue == Armamento.ETipo.dron) { a = new Dron(this.txtNombre.Text, Armamento.ETipo.dron, this.txtOrigen.Text, precio, stock); if (Inventario.Armas + a) { MessageBox.Show("Cargado con exito"); MessageBox.Show(a.ToString()); } } else if ((Armamento.ETipo) this.cmbTipo.SelectedValue == Armamento.ETipo.explosivo) { a = new Explosivo(this.txtNombre.Text, Armamento.ETipo.explosivo, this.txtOrigen.Text, precio, stock); if (Inventario.Armas + a) { MessageBox.Show("Cargado con exito"); MessageBox.Show(a.ToString()); } } this.evento.Invoke(); } else { if (int.Parse(this.txtPrecio.Text) < 0) { MessageBox.Show("Error: El precio no puede ser negativo."); this.txtPrecio.Clear(); } else { MessageBox.Show("Error: El stock no puede ser negativo."); this.txtStock.Clear(); } } } else { if (int.TryParse(this.txtPrecio.Text, out precio)) { MessageBox.Show("Error: Verifique que el stock sea un número."); this.txtStock.Clear(); } else { MessageBox.Show("Error: Verifique que el precio sea un número."); this.txtPrecio.Clear(); } } } catch (Exception exc) { MessageBox.Show(exc.Message); this.evento.Invoke(); } this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public string CadastrarArmamento(Armamento armamento) { _armamentoRepository = new ArmamentoRepository(); _armamentoRepository.CadastrarArmamento(armamento); return("Armamento cadastrado com sucesso!"); }