private bool GuardarCompraSerial(int accion) { C_Compra objetoCompra = new C_Compra(); objetoCompra.NumeroDocumento = Txt_I_NroDocumento.Text; objetoCompra.CodigoProveedor = Int32.Parse(Cmb_I_Proveedor.SelectedValue.ToString()); C_SerialProducto objetoSerialProducto = new C_SerialProducto(); objetoSerialProducto.CodigoCompra = _shalong.CompraCodigo(objetoCompra); if (accion == 2) { objetoSerialProducto.CodigoSerie = 0; objetoSerialProducto.CodigoBarras = 0; if (_shalong.CompraSerial(2, objetoSerialProducto)) { foreach (DataGridViewRow row in dtg_CG_Compras.Rows) { if (row.Cells["Cg_Codigo"].Value != null && row.Cells["Cg_Serial"].Value != null) { objetoSerialProducto.Serial = row.Cells["Cg_Serial"].Value.ToString(); objetoSerialProducto.CodigoBarras = Int32.Parse(row.Cells["Cg_Codigo"].Value.ToString()); if (_shalong.CompraSerial(1, objetoSerialProducto)) { } else { MessageBox.Show("Error al Guardar el Serial"); } } } } } else if (accion == 1) { foreach (DataGridViewRow row in dtg_CG_Compras.Rows) { if (row.Cells["Cg_Codigo"].Value != null && row.Cells["Cg_Serial"].Value != null) { objetoSerialProducto.Serial = row.Cells["Cg_Serial"].Value.ToString(); objetoSerialProducto.CodigoBarras = Int32.Parse(row.Cells["Cg_Codigo"].Value.ToString()); if (!_shalong.CompraSerial(1, objetoSerialProducto)) { return(false); } } } } return(true); }
private void Cmb_M_NroDocumento_SelectionChangeCommitted(object sender, EventArgs e) { if (Cmb_M_NroDocumento.SelectedIndex != -1) { C_Compra obj = _shalong.DocumentoPorFecha1(Int32.Parse(Cmb_M_NroDocumento.SelectedValue.ToString())); Txt_I_NroDocumento.Text = obj.NumeroDocumento; dtp_I_Fecha.Value = obj.FechaCompra; Cmb_I_TipoDocumento.SelectedValue = obj.CodigoTipoDocumento; Cmb_I_TipoMoneda.SelectedValue = obj.CodigoMoneda; Txt_I_TipoCambio.Text = "" + obj.ValorTipoCambio; Cmb_I_Proveedor.SelectedValue = obj.CodigoProveedor; Txt_I_Total.Text = "" + obj.MontoTotal; CargarDataGridView(); } dtg_SG_Compras.CommitEdit(DataGridViewDataErrorContexts.Commit); }
private void Btn_Guardar_Click(object sender, EventArgs e) { if (Cmb_SelectCredito.SelectedIndex == -1) { MessageBox.Show("Ingrese un Tipo de Credito Por Favor", "Gestion Ventas", MessageBoxButtons.OK); return; } else { C_Credito objetoCredito = new C_Credito(); C_Compra objetoCompra = new C_Compra(); C_Venta objetoVenta = new C_Venta(); if (Cmb_SelectCredito.Text == "Credito de Compra") { if (Cmb_I_Proveedor.SelectedIndex == -1) { MessageBox.Show("Ingrese un Proveedor Por Favor", "Gestion Ventas", MessageBoxButtons.OK); return; } else { objetoCompra.CodigoProveedor = Int32.Parse(Cmb_I_Proveedor.SelectedValue.ToString()); } objetoCompra.NumeroDocumento = Txt_I_NumDocumento.Text; objetoCredito.CodigoCompra = _shalong.CompraCodigo(objetoCompra); objetoCredito.CodigoVenta = -1; MessageBox.Show("Se Ingreso Correctamente el Credito de Compra", "Gestion Ventas", MessageBoxButtons.OK); } else if (Cmb_SelectCredito.Text == "Credito de Venta") { objetoVenta.NumeroDocumentoVenta = Txt_I_NumDocumento.Text; objetoCredito.CodigoVenta = _codigoVenta; objetoCredito.CodigoCompra = -1; objetoCredito.CodigoTrabajador = -1; objetoCredito.FechaProxPago = dtp_proximoPago.Value; objetoCredito.TotalDeuda = Double.Parse(Txt_I_TotalDeuda.Text); objetoCredito.Monto = Double.Parse(Txt_I_MontoPagado.Text); objetoCredito.CodigoCaja = _objetoParametros.CodigoCaja; objetoCredito.CodigoTipoPago = 10; _shalong.CreditoCompraVenta(1, objetoCredito); MessageBox.Show("Se Ingreso Correctamente el Credito de Venta", "Gestion Ventas", MessageBoxButtons.OK); this.Hide(); } } }
private bool GuardarCompraDetalle(int accion) { C_Compra objetoCompra = new C_Compra(); objetoCompra.NumeroDocumento = Txt_I_NroDocumento.Text; objetoCompra.CodigoProveedor = Int32.Parse(Cmb_I_Proveedor.SelectedValue.ToString()); C_CompraDetalle objetoCompraDetalle = new C_CompraDetalle(); //objetoCompraDetalle.CodigoCompraDetalle = 1; objetoCompraDetalle.CodigoCompra = _shalong.CompraCodigo(objetoCompra); objetoCompraDetalle.CodigoProducto = "0"; objetoCompraDetalle.CostoUnitario = 0.0; objetoCompraDetalle.CostoTotal = 0.0; objetoCompraDetalle.Cantidad = 0.0; objetoCompraDetalle.CodigoUnidad = 1; if (accion == 2) { if (_shalong.CompraDetalle(2, objetoCompraDetalle)) { foreach (DataGridViewRow row in dtg_SG_Compras.Rows) { if (row.Cells["Codigo"].Value != null) { objetoCompraDetalle.CodigoProducto = row.Cells["Codigo"].Value.ToString(); objetoCompraDetalle.CostoUnitario = Double.Parse(row.Cells["Costo_Unitario"].Value.ToString()); objetoCompraDetalle.CostoTotal = Double.Parse(row.Cells["Costo_Total"].Value.ToString()); objetoCompraDetalle.CodigoUnidad = Int32.Parse(row.Cells["Unidad"].Value.ToString()); C_Producto obj = _shalong.ProductoMostrar1(objetoCompraDetalle.CodigoProducto); double valorUnidad = _shalong.UnidadesEquivalencia(obj.CodigoUnidad, Int32.Parse(row.Cells["Unidad"].Value.ToString())); if (valorUnidad == 0.0) { MessageBox.Show("No existe la equivalencia con la Unidad del Producto", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { objetoCompraDetalle.Cantidad = Double.Parse(row.Cells["Cantidad"].Value.ToString()); objetoCompraDetalle.Cantidad = objetoCompraDetalle.Cantidad * valorUnidad; } if (_shalong.CompraDetalle(1, objetoCompraDetalle)) { } else { MessageBox.Show("Error al actualizar Detalle de la Compra", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } } } } else if (accion == 1) { foreach (DataGridViewRow row in dtg_SG_Compras.Rows) { if (row.Cells["Codigo"].Value != null) { objetoCompraDetalle.CodigoProducto = row.Cells["Codigo"].Value.ToString(); objetoCompraDetalle.CostoUnitario = Double.Parse(row.Cells["Costo_Unitario"].Value.ToString()); objetoCompraDetalle.CostoTotal = Double.Parse(row.Cells["Costo_Total"].Value.ToString()); objetoCompraDetalle.Cantidad = Double.Parse(row.Cells["Cantidad"].Value.ToString()); objetoCompraDetalle.CodigoUnidad = Int32.Parse(row.Cells["Unidad"].Value.ToString()); if (!_shalong.CompraDetalle(1, objetoCompraDetalle)) { MessageBox.Show("Error al ingresar el Detalle de la Compra", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } } } return(true); }
private void GuardarCompraCabezera() { int accion = 1; C_Compra objetoCliente = new C_Compra(); //PROVEEDOR if (Cmb_I_Proveedor.SelectedIndex == -1) { MessageBox.Show("Seleccione un Proveedor", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { objetoCliente.CodigoProveedor = Int32.Parse(Cmb_I_Proveedor.SelectedValue.ToString()); } //TIPO DE CAMBIO objetoCliente.CodigoTipoCambio = _codigoTipoCambio; // MONEDA if (Cmb_I_TipoMoneda.SelectedIndex == -1) { MessageBox.Show("Ingrese un Tipo de Moneda", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { objetoCliente.CodigoMoneda = Int32.Parse(Cmb_I_TipoMoneda.SelectedValue.ToString()); } // TIPO DE DOCUMENTO if (Cmb_I_TipoDocumento.SelectedIndex == -1) { MessageBox.Show("Ingrese un tipo de documento", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { objetoCliente.CodigoTipoDocumento = Int32.Parse(Cmb_I_TipoDocumento.SelectedValue.ToString()); } // FECHA COMPRA if (dtp_I_Fecha.Value == null) { MessageBox.Show("Ingrese una fecha", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { objetoCliente.FechaCompra = dtp_I_Fecha.Value; } //MONTO TOTAL if (Txt_I_Total.Text == String.Empty) { MessageBox.Show("No existe un Monto Total de Compra, Revise los datos", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; //objetoCliente.MontoTotal = 0.0; } else { if (Int32.Parse(Cmb_I_TipoMoneda.SelectedValue.ToString()) == 2) { objetoCliente.MontoTotal = (Double.Parse(Txt_I_Total.Text) * Double.Parse(Txt_I_TipoCambio.Text)); } else { objetoCliente.MontoTotal = Double.Parse(Txt_I_Total.Text); } } //NUMERO DE DOCUMENTO if (Txt_I_NroDocumento.Text == string.Empty) { MessageBox.Show("Ingrese un Numero de Documento", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { objetoCliente.NumeroDocumento = Txt_I_NroDocumento.Text; } // SELECCIONAR PESTAÑA MODIFICAR if (Txt_I_NroDocumento.Text == Cmb_M_NroDocumento.Text) { accion = 2; objetoCliente.Codigo = Int32.Parse(Cmb_M_NroDocumento.SelectedValue.ToString()); } // INGRESAR COMO CREDITO if (_shalong.Compra(accion, objetoCliente)) { if (GuardarAlmacen()) { if (GuardarCompraSerial(accion)) { if (GuardarCompraDetalle(accion)) { GuardarCreditoCompra(); MessageBox.Show("Se Ingreso la compra correctamente", "Gestion Ventas", MessageBoxButtons.OK); if (accion == 1) { CargarComboBoxDocumento(); Cmb_M_NroDocumento.SelectedIndex = -1; Cmb_M_NroDocumento.ResetText(); } if (accion == 2) { } } else { MessageBox.Show("Revisar los Datos del Detalle", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { MessageBox.Show("Revisar los Datos del Serial", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { MessageBox.Show("No se puedo guardar en Almacen, Revise los Datos Por Favor", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } }
//BOTONES // GUARDA EN CREDITO COMO COMPRA private void GuardarCreditoCompra() { C_Credito objetoCredito = new C_Credito(); // Datos para SumaFecha if (Cmb_I_Proveedor.SelectedIndex == -1) { MessageBox.Show("Ingrese un Proveedor", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { objetoCredito.CodigoProveedor = Int32.Parse(Cmb_I_Proveedor.SelectedValue.ToString()); } objetoCredito.Fecha = dtp_I_Fecha.Value; // ---------- // Datos para CompraCodigo C_Compra objetoCompra = new C_Compra(); if (Txt_I_NroDocumento.Text == string.Empty) { MessageBox.Show("Ingrese un Nro de Documento", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { objetoCompra.NumeroDocumento = Txt_I_NroDocumento.Text; } objetoCompra.CodigoProveedor = Int32.Parse(Cmb_I_Proveedor.SelectedValue.ToString()); // ------------- objetoCredito.CodigoCompra = _shalong.CompraCodigo(objetoCompra); objetoCredito.CodigoVenta = -1; objetoCredito.CodigoTrabajador = -1; objetoCredito.FechaProxPago = _shalong.SumaFecha(objetoCredito); if (chk_Credito.Checked == true) { if (Txt_I_Total.Text == string.Empty) { MessageBox.Show("Ingrese un Producto", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { objetoCredito.TotalDeuda = double.Parse(Txt_I_Total.Text); objetoCredito.Monto = 0; } } else { if (Txt_I_Total.Text == string.Empty) { MessageBox.Show("Ingrese un Producto", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { objetoCredito.TotalDeuda = 0.0; objetoCredito.Monto = double.Parse(Txt_I_Total.Text); } } if (_codigoCaja == null) { MessageBox.Show("No se ingreso desde una caja", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { objetoCredito.CodigoCaja = _codigoCaja; } objetoCredito.CodigoTipoPago = 10; if (_shalong.CreditoCompraVenta(1, objetoCredito)) { } else { MessageBox.Show("No se pudo guardar la Compra", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }