private void gridBuscarClientes_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (gridBuscarClientes.RowCount > 0) { /* if (boOtraPantalla) * { * intCodigo = Convert.ToInt32(gridBuscarClientes.CurrentRow.Cells[0].Value.ToString()); * this.Close(); * } * else * {*/ ManejaVentas objManejaVentas = new ManejaVentas(); int intCodigo = Convert.ToInt32(gridBuscarClientes.CurrentRow.Cells[0].Value.ToString()); Ventas objVentas = objManejaVentas.BuscarVentas(intCodigo); frmVentas objfrmVentas = new frmVentas(objVentas); if (frmLogin.PermiteEntrar("VENTAS", "VENTA_NUEVA")) { objfrmVentas.Show(); objfrmVentas.Activate(); CargoGrilla(); } //} } }
public frmSeguimiento(Int32 facturaid) { InitializeComponent(); objManejaVentas = new ManejaVentas(); list = new List <Seguimiento>(); list = objManejaVentas.BuscoSeguimiento(facturaid); CargoGrilla(); }
//Este es el total en efectivo private decimal CalculoTotalenEfectivo() { decimal deTotalEfectivo; ManejaVentas objManejaVentas = new ManejaVentas(); deTotalEfectivo = Redondeo(Convert.ToDecimal(objManejaVentas.BuscoTotalDineroEnEfectivo(idCierreCaja, dtpFechaIngreso.Text))); if ((Convert.ToDecimal(txtDineroInicial.Text) + deTotalEfectivo) - Convert.ToDecimal(txtComprasEnEfectivo.Text) - Convert.ToDecimal(txtDevoluciones.Text) < 0) { return(0); } else { return((Convert.ToDecimal(txtDineroInicial.Text.Replace('.', ',')) + deTotalEfectivo) - Convert.ToDecimal(txtComprasEnEfectivo.Text) - Convert.ToDecimal(txtDevoluciones.Text)); } }
private void CargoDatos() { string strSql = ""; strSql = "select * from ("; if (ckPagos.Checked) { strSql += ArmoPagos(); if (ckDevoluciones.Checked) { strSql += " UNION "; strSql += ArmoDevoluciones(); } } else { strSql += ArmoDevoluciones(); } strSql += " ) tabla order by fecha"; LlenaCombos objLlenaCombos = new LlenaCombos(); DataTable dt = objLlenaCombos.GetSqlDataAdapterbySql(strSql); ManejaVentas objManejaVentas = new ManejaVentas(); frmReportes objfrmReporte; objfrmReporte = new frmReportes("ReportePagosDevoluciones.rdlc", objManejaVentas.ReporteDePagosDevoluciones(dt), "VentasReportePago"); objfrmReporte.Show(); }
private void CargoGrilla() { int i = 0; ManejaVentas objManejaVentas = new ManejaVentas(); grid_Pagos.DataSource = null; grid_Pagos.Rows.Clear(); decimal dePagado = 0; CargoTituloGrilla(); if (list.Count != 0) { foreach (Ventas_Pagos element in list) { /* if (element.IntEstado != 3) * {*/ grid_Pagos.Rows.Add(); grid_Pagos[0, i].Value = element.DtFecha; grid_Pagos[1, i].Value = Convert.ToString(Redondeo(element.DeImporte)); grid_Pagos[2, i].Value = element.IntMedioPago; grid_Pagos[3, i].Value = objManejaVentas.BuscoNombreDeMedioDePago(element.IntMedioPago); if (element.IntEstado == 3) { grid_Pagos.Rows[i].Visible = false; } i++; //} if (element.IntEstado != 3) { dePagado = dePagado + element.DeImporte; } } txtDebe.Text = Convert.ToString(Redondeo(deTotalFactura - dePagado)); } }
private void btnAceptar_Click(object sender, EventArgs e) { string message; string caption = "Mensaje"; //Primero me tengo que fijar si el cliente tiene alguna Carta de Porte asociada message = "Esta seguro que quiere descontar: $" + Convert.ToString(Redondeo(Convert.ToDecimal(txtImporte.Text.Replace('.', ',')))); if (!VerificoCamposAntesDeGrabar()) { MessageBox.Show("Campos Obligatorios Incompletos"); return; } else { if (deDebe < Convert.ToDecimal(txtImporte.Text.Replace('.', ','))) { MessageBox.Show("El cambo Importe no puede se mayor a lo que debe"); return; } MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; // Displays the MessageBox. result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { ManejaVentas objManejaVentas = new ManejaVentas(); List <Ventas> list = new List <Ventas>(); List <Ventas_Pagos> listPagos = new List <Ventas_Pagos>(); decimal deDiferencia = deDebe; int i = 0; //Debo buscar las facturas impagas que tiene //y descontar del total //Si el total supera el de la factura, descontar de la siguiente y asi sucesivamente //Busco las facturas impagas list = objManejaVentas.BuscoFacturasConDeuda(intClienteid); //Las recorro y voy descontando foreach (var item in list) { if (deDiferencia > 0) { i++; objPagos = new Ventas_Pagos(); objPagos.IntEstado = 1;//Alta objPagos.DtFecha = Convert.ToDateTime(dtpFecha.Value); objPagos.IntMedioPago = Convert.ToInt32(cboMedioDePago.SelectedValue); objPagos.IntNumeroCaja = objConfiguracion.IntNumeroCaja; if (i == 1) { if (item.DoDebe > Convert.ToDecimal(txtImporte.Text.Replace('.', ','))) { objPagos.DeImporte = Convert.ToDecimal(txtImporte.Text.Replace('.', ',')); deDiferencia = 0; deDebe = deDebe - objPagos.DeImporte; } else { objPagos.DeImporte = item.DoDebe; deDiferencia = Convert.ToDecimal(txtImporte.Text.Replace('.', ',')) - item.DoDebe; deDebe = deDebe - item.DoDebe; } } else { if (item.DoDebe > deDiferencia) { objPagos.DeImporte = deDiferencia;; deDebe = deDebe - deDiferencia; deDiferencia = 0; } else { objPagos.DeImporte = item.DoDebe; deDiferencia = deDiferencia - item.DoDebe; deDebe = deDebe - item.DoDebe; } } //Grabo el pago objManejaVentas.GrabarVentasPagos(objPagos, item.IntCodigo); //Grabo el detalle de venta item.DoPago = item.DoPago + objPagos.DeImporte; item.DoDebe = item.DoDebe - objPagos.DeImporte; objManejaVentas.ModificaVentas(item); } } } } // LimpiarControles(); // ActualizarControles(); MessageBox.Show("El saldo se ha actualizado correctamente"); this.Close(); }
private void CargoDatos() { string strSql; //Tengo 3 formas de busqueda //1-Detallado por Cantidad total de articulos //2-Detallado de articulos //3-Totales if (rbInformeDetallado.Checked && rbArticulosCantidadTotal.Checked) { strSql = " select f.facturaid, f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido as empleado, c.cli_nombre + ' '+ c.cli_apellido as cliente, isnull( sum(d.cantidad),0) as cantidad, "; strSql += " isnull(f.efectivoabona,0) as efectivo, isnull((select sum(d.tarjetaabona) from dbo.Tarjetas_Detalle d where d.facturaid =f.facturaid),0) as tarjeta , isnull( (select sum(d.chequeabona) from dbo.Cheques_Detalle d where d.facturaid =f.facturaid),0) as cheque , isnull(f.ctacte,0) as Ctacte, isnull(f.total,0) as total, f.descuento, f.neto "; strSql += " from dbo.Factura f, dbo.Empleados e, dbo.Clientes c, dbo.Factura_Detalle d "; strSql += " where f.empleadoid= e.emp_id and f.clienteid = c.cli_id and f.facturaid = d.facturaid "; } else if (rbInformeDetallado.Checked && rbArticulosDetallado.Checked) { strSql = " select f.facturaid, f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido as empleado, c.cli_nombre + ' '+ c.cli_apellido as cliente, d.cantidad,a.descripcion, d.descuento, d.puni, d.total "; strSql += " from dbo.Factura f, dbo.Empleados e, dbo.Clientes c, dbo.Factura_Detalle d, dbo.Articulos a "; strSql += " where f.empleadoid= e.emp_id and f.clienteid = c.cli_id and f.facturaid = d.facturaid and a.id = d.articuloid "; } else if (rbInformeDetallado.Checked && rbDetalladoMedioDePago.Checked) { strSql = " select f.facturaid, f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido as empleado, c.cli_nombre + ' '+ c.cli_apellido as cliente, a.numero_caja, m.descripcion, sum (p.importe) as total, p.mediopago, p.fecha "; strSql += " from dbo.Factura f, dbo.Empleados e, dbo.Clientes c, dbo.Ventas_Pagos p, dbo.Medio_Pago m, Cierre_Caja a"; strSql += " where f.empleadoid= e.emp_id and f.clienteid = c.cli_id and f.facturaid = ventas_id and p.mediopago = m.mediopago and p.cierrecajaid = a.cierrecajaid "; } else { /* strSql = " select f.facturaid, f.empleadoid, f.clienteid, f.subtotal as efectivo,f.ctacte as Ctacte, f.total, "; * strSql += " (select sum(cantidad) from dbo.Factura_Detalle d where f.facturaid = d.facturaid) as cantidad "; * strSql += " from dbo.Factura f "; * strSql += " LEFT OUTER JOIN dbo.Tarjetas_Detalle t ON f.facturaid = t.facturaid "; * strSql += " LEFT OUTER JOIN dbo.Cheques_Detalle che ON f.facturaid = che.facturaid,"; * strSql += " dbo.Empleados e, dbo.Clientes c,dbo.Factura_Detalle d "; * strSql += " where f.empleadoid= e.emp_id "; * strSql += " and f.clienteid = c.cli_id "; * strSql += " and f.facturaid = d.facturaid ";*/ strSql = " select f.facturaid, f.empleadoid, f.clienteid, "; strSql += " isnull((select sum(importe) from dbo.Ventas_Pagos p where f.facturaid = p.ventas_id and p.fecha between DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaPagoDesde.Text + "'))" + " and DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaPagoHasta.Text + "')+1)"; strSql += " ),0) as pagado,f.ctacte as Ctacte, f.total, "; strSql += " (select sum(cantidad) from dbo.Factura_Detalle d where f.facturaid = d.facturaid) as cantidad "; strSql += " from dbo.Factura f, dbo.Empleados e, dbo.Clientes c,dbo.Factura_Detalle d "; strSql += " where f.empleadoid= e.emp_id "; strSql += " and f.clienteid = c.cli_id "; strSql += " and f.facturaid = d.facturaid "; } if (txtCodigoVenta.Text != "") { strSql += " and f.facturaid " + cboCodigoVenta.Text + txtCodigoVenta.Text; } if (cboVendedor.Text != "") { strSql += " and e.emp_id =" + cboVendedor.SelectedValue; } if (cboCliente.Text != "") { strSql += " and c.cli_id =" + cboCliente.SelectedValue; } if (cboEstado.Text != "") { strSql += " and f.estado = '" + cboEstado.Text + "'"; } if (cboFaltaDePago.Text != "") { if (cboFaltaDePago.Text == "CON DEUDA") { strSql += " and f.ctacte > 0"; } else { strSql += " and f.ctacte = 0"; } } if (rbInformeDetallado.Checked && rbDetalladoMedioDePago.Checked) { strSql += " and p.fecha between DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaPagoDesde.Text + "'))" + " and DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaPagoHasta.Text + "')+1)"; } strSql += " and f.fechaalta between DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaVentaDesde.Text + "'))" + " and DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechadeVentaHasta.Text + "')+1)"; if (txtCodigoArticulo.Text != "") { if (txtCodigoArticulo.Text.Length > 1) { if (txtCodigoArticulo.Text.Substring(0, 2).Trim() == "20" && txtCodigoArticulo.Text.Trim().Length == 13) //Los dos primeros digitos tienen que se 20 y el ancho del codigo de barra tiene que ser de 12 digitos { //Si es un codigo de balanza electronica strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and SUBSTRING(a.idextra,1,6)= '" + txtCodigoArticulo.Text.Substring(0, 6) + "')"; if (cboCodigoArticulo.Text == "like") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and SUBSTRING(a.idextra,1,6) like '" + txtCodigoArticulo.Text.Substring(0, 6) + "%' )"; } if (cboCodigoArticulo.Text == "path") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and SUBSTRING(a.idextra,1,6) like '%" + txtCodigoArticulo.Text.Substring(0, 6) + "%' )"; } } } else { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and a.idextra= '" + txtCodigoArticulo.Text + "')"; if (cboCodigoArticulo.Text == "like") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and a.idextra like '" + txtCodigoArticulo.Text + "%' )"; } if (cboCodigoArticulo.Text == "path") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and a.idextra like '%" + txtCodigoArticulo.Text + "%' )"; } } } if (txtDescripcionArticulo.Text != "") { if (cboDescripcionArticulo.Text == "=") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d, dbo.Articulos a where a.id = d.articuloid and a.descripcion = '" + txtDescripcionArticulo.Text + "')"; } if (cboDescripcionArticulo.Text == "like") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d, dbo.Articulos a where a.id = d.articuloid and a.descripcion like '" + txtDescripcionArticulo.Text + "%' )"; } if (cboDescripcionArticulo.Text == "path") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d, dbo.Articulos a where a.id = d.articuloid and a.descripcion like '%" + txtDescripcionArticulo.Text + "%' )"; } } if (cboMedioPago.Text != "") { strSql += " and p.mediopago =" + cboMedioPago.SelectedValue; } if (rbInformeDetallado.Checked && rbArticulosCantidadTotal.Checked) { strSql += " group by f.facturaid,f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido, c.cli_nombre + ' '+ c.cli_apellido, f.descuento, f.neto, f.efectivoabona,f.total,ctacte "; } else { if (rbInformeDetallado.Checked && rbArticulosDetallado.Checked) { strSql += " group by f.facturaid, f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido, c.cli_nombre + ' '+ c.cli_apellido , d.cantidad,a.descripcion, d.descuento, d.puni, d.total "; } else if (rbInformeDetallado.Checked && rbDetalladoMedioDePago.Checked) { strSql += " group by f.facturaid,f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido, c.cli_nombre + ' '+ c.cli_apellido, a.numero_caja, m.descripcion, p.mediopago, p.fecha "; } else { strSql += " group by f.facturaid, f.empleadoid, f.clienteid, f.subtotal,f.ctacte, f.total "; } } //Seteo los checks de ordenamiento if (rbInformeDetallado.Checked) { if (rbOrden2CantidadDeArticulos.Checked) { strSql += " order by cantidad"; } else if (rbOrden2Fecha.Checked) { strSql += " order by f.fechaalta"; } else if (rbOrden2MayorGanancia.Checked) { strSql += " order by total desc"; } else if (rbOrden2MenorGanancia.Checked) { strSql += " order by total asc"; } else if (rbOrden2NumeroFactura.Checked) { strSql += " order by f.facturaid asc"; } } LlenaCombos objLlenaCombos = new LlenaCombos(); DataTable dt = objLlenaCombos.GetSqlDataAdapterbySql(strSql); ManejaVentas objManejaVentas = new ManejaVentas(); frmReportes objfrmReporte; if (rbInformeDetallado.Checked && rbArticulosCantidadTotal.Checked) { objfrmReporte = new frmReportes("ReportePorCantidadDeArticulos.rdlc", objManejaVentas.ReporteDeCantidadTotalesDeArticulos(dt), "VentasReporte"); } else if (rbInformeDetallado.Checked && rbArticulosDetallado.Checked) { objfrmReporte = new frmReportes("ReporteDetalladoPorArticulos.rdlc", objManejaVentas.ReporteDetalladoPorArticulos(dt), "VentasReporte"); } else if (rbInformeDetallado.Checked && rbDetalladoMedioDePago.Checked) { objfrmReporte = new frmReportes("ReporteDetalladoPorMedioDePago.rdlc", objManejaVentas.ReporteDetalladoPorMedioDePago(dt), "VentasReporte"); } else { objfrmReporte = new frmReportes("ReporteTotales.rdlc", objManejaVentas.ReporteTotales(dt, Convert.ToDateTime(dtpFechaVentaDesde.Text), Convert.ToDateTime(dtpFechadeVentaHasta.Text)), "VentasReporte"); } objfrmReporte.Show(); }