private void BtnSeleccionar_Click(object sender, EventArgs e) { if (DgvProducto.SelectedRows.Count > 0) { int rowindex = DgvProducto.CurrentRow.Index; if (rowindex != -1) { try { Frm_Registrar_Venta frm = Owner as Frm_Registrar_Venta; string codigoproducto = DgvProducto.CurrentRow.Cells[3].Value.ToString(); frm.TxtProducto.Text = codigoproducto; NProducto boProducto = new NProducto(); EProducto producto = boProducto.Seleccionar(codigoproducto); if (string.IsNullOrEmpty(producto.Codigo)) { MessageBox.Show("No Existe Producto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { NInventario boInventario = new NInventario(); EInventario inventario = boInventario.Seleccionar(producto.Codigo); if (!string.IsNullOrEmpty(inventario.Producto)) { if (inventario.Existencias > 0) { double utilidad = Frm_Principal.ValorUtilidad; double precioventa = Math.Round((inventario.ValorUnitario * utilidad), 2); frm.AddItems(producto, 1, precioventa); //Mostrar imagen if (!string.IsNullOrEmpty(producto.Imagen)) { frm.PbxImgProducto.Image = Image.FromFile(CarpetaImagen + "/" + producto.Imagen); } } else { MessageBox.Show("No hay Cantidad Suficiente"); } } } Close(); } catch { // } } } else { MessageBox.Show("Seleccione un registro"); } }
public FListaComponente() { InitializeComponent(); negocio = new NInventario(); List <componente> lista = negocio.lista_comp(); foreach (componente c in lista) { cbxLista.Items.Add(c); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { string respuesta = ""; if (this.txtCantidad.Text == string.Empty || this.txtPrecio.Text == string.Empty || this.txtVehiculo.Text == string.Empty || this.txtIDVehiculo.Text == string.Empty) { MensajeError("Falta ingresar algunos datos relevantes"); errorIcono.SetError(txtCantidad, "Ingrese un Valor"); errorIcono.SetError(txtPrecio, "Ingrese un Valor"); errorIcono.SetError(txtVehiculo, "Ingrese un Valor"); errorIcono.SetError(txtIDVehiculo, "Ingrese un Valor"); } else { if (this.IsNuevo) { respuesta = NInventario.Insertar(Convert.ToInt32(this.txtCantidad.Text), Convert.ToInt32(this.txtIDVehiculo.Text)); } else { respuesta = NInventario.Editar(Convert.ToInt32(this.txtID.Text), Convert.ToInt32(this.txtCantidad.Text)); } if (respuesta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOk("Se Insertó de forma correcta el registro"); } else { this.MensajeOk("Se Actualizó de forma correcta el registro"); } } else { this.MensajeError(respuesta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); } gbxListado.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
public PMantenimiento() { InitializeComponent(); user = Form1.user; negocioM = new NMaquina(); negocioS = new NSolicitud(); negocioMant = new NMantenimiento(); negocioInv = new NInventario(); cargarCMaquina(); cargarGSol(); listac = new List <string[]>(); listam = new List <materialusado>(); }
private void ActualizarCantidad(string operation, int quantity = 1) { if (MLVDetalle.SelectedItems.Count > 0) { string codigoproducto = MLVDetalle.SelectedItems[0].SubItems[0].Text; NInventario boInventario = new NInventario(); EInventario inventario = boInventario.Seleccionar(codigoproducto); //Datos double precio = Convert.ToDouble(MLVDetalle.SelectedItems[0].SubItems[3].Text); int cantidad = Convert.ToInt32(MLVDetalle.SelectedItems[0].SubItems[4].Text); if (operation.Equals("Aumentar")) { if (cantidad < inventario.Existencias) { cantidad += quantity; } else { MessageBox.Show("No hay mas productos"); } } else if (operation.Equals("Disminuir")) { cantidad -= quantity; } else if (operation.Equals("Nueva")) { if (quantity <= inventario.Existencias) { cantidad = quantity; } else { MessageBox.Show("No hay mas productos"); } } double importe = precio * cantidad; MLVDetalle.SelectedItems[0].SubItems[4].Text = cantidad.ToString(); MLVDetalle.SelectedItems[0].SubItems[5].Text = importe.ToString(); TxtCantidadItem.Text = cantidad.ToString(); ActualizarResumen(); } else { MessageBox.Show("Seleccione Item"); } }
private void CargarDatosProducto() { try { string codigoproducto = DgvProducto.CurrentRow.Cells[3].Value.ToString(); NInventario boInventario = new NInventario(); EInventario inventario = boInventario.Seleccionar(codigoproducto); TxtProducto.Text = DgvProducto.CurrentRow.Cells[4].Value.ToString(); TxtExistencias.Text = inventario.Existencias.ToString(); txtPrecioCompra.Text = inventario.ValorUnitario.ToString("N2"); double precioventa = Math.Round((inventario.ValorUnitario * Frm_Principal.ValorUtilidad), 2); TxtPrecioVenta.Text = precioventa.ToString("N2"); } catch { // } }
private void btnEliminar_Click(object sender, EventArgs e) { try { DialogResult Opcion; Opcion = MessageBox.Show("Realmente Desea Eliminar los Registros", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Opcion == DialogResult.OK) { string ID; string respuesta = ""; foreach (DataGridViewRow row in dgvListado.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { ID = Convert.ToString(row.Cells[1].Value); respuesta = NInventario.Eliminar(Convert.ToInt32(ID)); if (respuesta.Equals("OK")) { this.MensajeOk("Se Eliminó Correctamente el registro"); } else { this.MensajeError(respuesta); } } } this.Mostrar(); this.chbEliminar.Checked = false; } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
//Método Buscar private void Buscar() { this.dgvListado.DataSource = NInventario.Buscar(this.txtBusqueda.Text); this.OcultarColumnas(); }
//Método Mostrar private void Mostrar() { this.dgvListado.DataSource = NInventario.Mostrar(); this.OcultarColumnas(); }
private void GuardarVenta() { string tipocomprobante = CbxTipoComprobante.SelectedValue.ToString(); string ventaserie = "####"; string ventacorrelativo = "########"; NVenta venta = new NVenta(); if (venta.ObtenerSerieCorrelativo(tipocomprobante) != null) { DataRow row = venta.ObtenerSerieCorrelativo(tipocomprobante); ventaserie = row["Serie"].ToString(); ventacorrelativo = row["Correlativo"].ToString(); } EVenta beVenta = new EVenta { Cliente = Convert.ToInt32(LblIDCliente.Text), Empleado = Frm_Principal.AccesoUsernameID, TipoComprobante = tipocomprobante, Serie = ventaserie, Numero = ventacorrelativo, Fecha = Convert.ToDateTime(DateTime.Now), Hora = Convert.ToDateTime(DateTime.Now), SubTotal = Venta_SubTotal, Igv = Venta_Igv, Total = Venta_Total, Estado = 1 }; NVenta boVenta = new NVenta(); if (boVenta.Agregar(beVenta) == true) { if (MLVDetalle.Items.Count > 0) { NDetalleVenta boDetalleVenta = new NDetalleVenta(); foreach (ListViewItem items in MLVDetalle.Items) { EDetalleVenta beDetalleVenta = new EDetalleVenta { Serie = beVenta.Serie, Numero = beVenta.Numero, Producto = items.SubItems[0].Text, Precio = Convert.ToDouble(items.SubItems[3].Text), Cantidad = Convert.ToInt32(items.SubItems[4].Text), Importe = Convert.ToDouble(items.SubItems[5].Text) }; //Agregar dettalle compra if (boDetalleVenta.Agregar(beDetalleVenta) == true) { int cantidadfinal = 0; double costounitariofinal = 0; double costototalfinal = 0; //Obteniendo Ultimo Movimiento NMovimiento boM = new NMovimiento(); EMovimiento datos = boM.SeleccionarUltimoMovimientoProducto(beDetalleVenta.Producto); if (!string.IsNullOrEmpty(datos.Producto)) { //Si hay datos cantidadfinal = datos.CantidadFinal - beDetalleVenta.Cantidad; costounitariofinal = datos.CostoUnitarioFinal; double costofinaly = Math.Round((costounitariofinal * beDetalleVenta.Cantidad), 2); costototalfinal = datos.CostoTotalFinal - costofinaly; //Movimiento EMovimiento beMovimiento = new EMovimiento { Fecha = DateTime.Now, TipoComprobante = beVenta.TipoComprobante, Serie = beVenta.Serie, Numero = beVenta.Numero, TipoOperacion = "01", Producto = beDetalleVenta.Producto, CantidadEntrada = 0, CostoUnitarioEntrada = 0, CostoTotalEntrada = 0, CantidadSalida = beDetalleVenta.Cantidad, CostoUnitarioSalida = costounitariofinal, CostoTotalSalida = costofinaly, CantidadFinal = cantidadfinal, CostoUnitarioFinal = costounitariofinal, CostoTotalFinal = costototalfinal }; NMovimiento boMovimiento = new NMovimiento(); if (boMovimiento.Agregar(beMovimiento) == true) { EInventario beInventario = new EInventario { Producto = beMovimiento.Producto, ValorUnitario = beMovimiento.CostoUnitarioFinal, Existencias = beMovimiento.CantidadFinal, ValorInventario = beMovimiento.CostoTotalFinal }; NInventario boInventario = new NInventario(); boInventario.Modificar(beInventario); } } } } } //message Frm_Buscar_venta frm = Owner as Frm_Buscar_venta; frm.Listar(); Close(); Frm_Principal.Main.ChangeMessage("La Venta se ingreso correctamente", "Success"); } else { Frm_Principal.Main.ChangeMessage("Algo salio mal", "Failed"); } }
private void GuardarCompra() { ECompra beCompra = new ECompra { Proveedor = Convert.ToInt32(LblIDProveedor.Text), Empleado = Frm_Principal.AccesoUsernameID, TipoComprobante = CbxTipoComprobante.SelectedValue.ToString(), Serie = TxtSerie.Text, Numero = TxtNumero.Text, Fecha = Convert.ToDateTime(DtpFecha.Text), SubTotal = Compra_SubTotal, Igv = Compra_Igv, Total = Compra_Total, Estado = 1 }; NCompra boCompra = new NCompra(); if (boCompra.Agregar(beCompra) == true) { if (MLVDetalle.Items.Count > 0) { NDetalleCompra boDetalleCompra = new NDetalleCompra(); foreach (ListViewItem items in MLVDetalle.Items) { EDetalleCompra beDetalleCompra = new EDetalleCompra { Serie = beCompra.Serie, Numero = beCompra.Numero, Producto = items.SubItems[0].Text, PrecioUnitario = Convert.ToDouble(items.SubItems[3].Text), Cantidad = Convert.ToInt32(items.SubItems[4].Text), PrecioTotal = Convert.ToDouble(items.SubItems[5].Text) }; //Agregar dettalle compra if (boDetalleCompra.Agregar(beDetalleCompra) == true) { int cantidadfinal = 0; double costounitariofinal = 0; double costototalfinal = 0; //Obteniendo Ultimo Movimiento NMovimiento boM = new NMovimiento(); EMovimiento datos = boM.SeleccionarUltimoMovimientoProducto(beDetalleCompra.Producto); if (string.IsNullOrEmpty(datos.Producto)) { cantidadfinal = beDetalleCompra.Cantidad; costounitariofinal = beDetalleCompra.PrecioUnitario; costototalfinal = beDetalleCompra.PrecioTotal; } else { //Si hay datos cantidadfinal = datos.CantidadFinal + beDetalleCompra.Cantidad; costototalfinal = datos.CostoTotalFinal + beDetalleCompra.PrecioTotal; costounitariofinal = Math.Round((costototalfinal / cantidadfinal), 2); } EMovimiento beMovimiento = new EMovimiento { Fecha = DateTime.Now, TipoComprobante = beCompra.TipoComprobante, Serie = beCompra.Serie, Numero = beCompra.Numero, TipoOperacion = "02", Producto = beDetalleCompra.Producto, CantidadEntrada = beDetalleCompra.Cantidad, CostoUnitarioEntrada = beDetalleCompra.PrecioUnitario, CostoTotalEntrada = beDetalleCompra.PrecioTotal, CantidadSalida = 0, CostoUnitarioSalida = 0, CostoTotalSalida = 0, CantidadFinal = cantidadfinal, CostoUnitarioFinal = costounitariofinal, CostoTotalFinal = costototalfinal }; NMovimiento boMovimiento = new NMovimiento(); if (boMovimiento.Agregar(beMovimiento) == true) { EInventario beInventario = new EInventario { Producto = beMovimiento.Producto, ValorUnitario = beMovimiento.CostoUnitarioFinal, Existencias = beMovimiento.CantidadFinal, ValorInventario = beMovimiento.CostoTotalFinal }; NInventario boInventario = new NInventario(); boInventario.Modificar(beInventario); } } } } //message Frm_Buscar_Compra frm = Owner as Frm_Buscar_Compra; frm.Listar(); Close(); Frm_Principal.Main.ChangeMessage("La Compra se ingreso correctamente", "Success"); } else { Frm_Principal.Main.ChangeMessage("Algo salio mal", "Failed"); } }
public PInventario() { InitializeComponent(); negocio = new NInventario(); cargar_combos(); }