public frmEdicion(EArticulos articulo) : this() { this.Text = "Edición del Artículo"; txtCodBarra.Text = articulo.CodBarra; txtDescripcion.Text = articulo.Descripcion; cbMarca.SelectedIndex = cbMarca.FindString(MarcasRepository.ObtenerMarcaStringPorId(articulo.IdMarca)); cbRubro.SelectedIndex = cbRubro.FindString(RubrosRepository.ObtenerRubroStringPorId(articulo.IdRubro)); cbProveedores.SelectedIndex = cbProveedores.FindString(ProveedoresRepository.ObtenerProveedorStringPorID(articulo.IdProveedor)); cbUnidad.SelectedIndex = cbUnidad.FindString(UnidadesRepository.ObtenerUnidadStringPorId(articulo.IdUnidad)); //txtCostoInicial2.Text = Convert.ToString(articulo.CostoInicial); //txtCostoInicial.Value = articulo.CostoInicial.Value; txtDescPorc1.Value = articulo.DescuentoPorc1.Value; //txtDesc1.Value = articulo.Descuento1.Value; txtDescPorc2.Value = articulo.DescuentoPorc2.Value; //txtDesc2.Value = articulo.Descuento2.Value; txtDescPorc3.Value = articulo.DescuentoPorc3.Value; //txtDesc3.Value = articulo.Descuento3.Value; txtCosto.Value = articulo.Costo; txtListaPorc1.Value = articulo.PrecioPorcL1.Value; txtLista1.Value = articulo.PrecioL1.Value; txtListaPorc2.Value = articulo.PrecioPorcL2.Value; txtLista2.Value = articulo.PrecioL2.Value; txtListaPorc3.Value = articulo.PrecioPorcL3.Value; txtLista3.Value = articulo.PrecioL3.Value; txtIVA.Value = articulo.IVA.Value; txtStock.Value = articulo.Stock.Value; txtStockMinimo.Value = articulo.StockMinimo; txtObservaciones.Text = Convert.ToString(articulo.Observaciones); ckEstado.Checked = articulo.Estado == 1; }
private void ConsultarDatos() { dgvDatos.SetDataSource(from u in MarcasRepository.ObtenerMarcas() select new { u.Id, u.Marca, u.Observaciones }); dgvDatos.Columns[0].Visible = false; }
private void CargaMarcas() { var m = MarcasRepository.ObtenerMarcas();; cbMarca.DataSource = m; cbMarca.DisplayMember = "Marca"; cbMarca.ValueMember = "Id"; if (m.Any()) { cbMarca.SelectedIndex = 0; } }
private Models.EMarcas ObtenerMarcaSeleccionada() { try { int rowindex = dgvDatos.CurrentCell.RowIndex; var id = (Int32)dgvDatos.Rows[rowindex].Cells[0].Value; var a = MarcasRepository.ObtenerMarcaPorId(id); return(a); } catch (Exception) { return(null); } }
private void btnNuevo_Click(object sender, EventArgs e) { using (var f = new Forms.Marcas.frmEdición()) { if (f.ShowDialog() == DialogResult.OK) { try { var a = MarcasRepository.Insertar(f.Marca, f.Observaciones); ConsultarDatos(); dgvDatos.SetRow(r => Convert.ToDecimal(r.Cells[0].Value) == a.Id); } catch (Exception ex) { ShowError("Error al intentar grabar los datos: \n" + ex.Message); } } } }
private void btnEliminar_Click(object sender, EventArgs e) { var a = ObtenerMarcaSeleccionada(); if (MessageBox.Show("¿Está seguro de que desea eliminar la marca seleccionada?", "Eliminar Marca", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { MarcasRepository.Eliminar(a.Id); ConsultarDatos(); dgvDatos.SetRow(r => Convert.ToDecimal(r.Cells[0].Value) == a.Id); } catch (Exception ex) { ShowError(ex.Message); } } }
private void dgvDatos_SelectionChanged(object sender, EventArgs e) { var a = ObtenerArticuloSeleccionado(); if (a == null) { txtDescripcion.Text = ""; txtCodBarra.Text = ""; txtMarca.Text = ""; txtRubro.Text = ""; txtProveedor.Text = ""; txtStock.Text = ""; txtStockMin.Text = ""; txtCostoInicial.Text = ""; txtDesc1.Text = ""; txtDesc2.Text = ""; txtDesc3.Text = ""; txtCosto.Text = ""; txtLista1.Text = ""; txtLista2.Text = ""; txtLista3.Text = ""; txtIVA.Text = ""; return; } txtDescripcion.Text = a.Descripcion; txtCodBarra.Text = a.CodBarra; txtMarca.Text = MarcasRepository.ObtenerMarcaPorId(Convert.ToInt16(a.IdMarca)).Marca; txtRubro.Text = RubrosRepository.ObtenerRubroPorId(Convert.ToInt16(a.IdRubro)).Rubro; txtProveedor.Text = ProveedoresRepository.ObtenerProveedorPorId(Convert.ToInt16(a.IdProveedor)).RazonSocial; txtStock.Text = Convert.ToString(a.Stock); txtStockMin.Text = Convert.ToString(a.StockMinimo); txtCostoInicial.Text = "$ " + Convert.ToString(a.CostoInicial); txtDesc1.Text = "$ " + Convert.ToString(a.Descuento1) + " (" + Convert.ToString(a.DescuentoPorc1) + "%)"; txtDesc2.Text = "$ " + Convert.ToString(a.Descuento2) + " (" + Convert.ToString(a.DescuentoPorc2) + "%)";; txtDesc3.Text = "$ " + Convert.ToString(a.Descuento3) + " (" + Convert.ToString(a.DescuentoPorc3) + "%)";; txtCosto.Text = "$ " + Convert.ToString(a.Costo); txtLista1.Text = "$ " + Convert.ToString(a.PrecioL1) + " (" + Convert.ToString(a.PrecioPorcL1) + "%)"; txtLista2.Text = "$ " + Convert.ToString(a.PrecioL2) + " (" + Convert.ToString(a.PrecioPorcL2) + "%)"; txtLista3.Text = "$ " + Convert.ToString(a.PrecioL3) + " (" + Convert.ToString(a.PrecioPorcL3) + "%)"; txtIVA.Text = Convert.ToString(a.IVA); }
private void btnEditar_Click(object sender, EventArgs e) { Models.EMarcas a = ObtenerMarcaSeleccionada(); using (var f = new frmEdición(a)) { if (f.ShowDialog() == DialogResult.OK) { try { int IdEmpresa = Lib.Configuration.IdEmpresa; MarcasRepository.Actualizar(a.Id, f.Marca, f.Observaciones); ConsultarDatos(); dgvDatos.SetRow(r => Convert.ToDecimal(r.Cells[0].Value) == a.Id); } catch (Exception ex) { ShowError("Error al intentar grabar los datos: \n" + ex.Message); } } } }
public MarcasController() { _repo = new MarcasRepository(); }