public List<CierreVentasVO> consultarCierresAgrupados(DateTime fecha1, DateTime fecha2) { List<CierreVentasVO> cierresVenta = new List<CierreVentasVO>(); try { string sqlQuery = "Select v.Fecha, sum(v.TotalVentas), sum(v.Creditos), sum(v.Efectivo), sum(v.Sodexo), sum(v.BigPass), sum(v.Otros), sum(v.Tarjetas), sum(v.TarjetaPlus), sum(v.TicketTronik) From EstacionDB.VO.CierreVentasVO v Where Fecha Between :Fecha1 And :Fecha2 Group By v.Fecha"; IQuery query = ConnectionHelper.getCurrentSession(Utilidades.Utilidades.configExpo).CreateQuery(sqlQuery); query.SetParameter("Fecha1", fecha1); query.SetParameter("Fecha2", fecha2); IList tmp = query.List(); foreach (object[] cierre in tmp) { CierreVentasVO cv= new CierreVentasVO(); cv.Fecha = DateTime.Parse(cierre[0].ToString()); cv.TotalVentas = double.Parse(cierre[1].ToString()); cv.Creditos = double.Parse(cierre[2].ToString()); cv.Efectivo = double.Parse(cierre[3].ToString()); cv.Sodexo = double.Parse(cierre[4].ToString()); cv.BigPass = double.Parse(cierre[5].ToString()); cv.Otros = double.Parse(cierre[6].ToString()); cv.Tarjetas = double.Parse(cierre[7].ToString()); cv.TarjetaPlus = double.Parse(cierre[8].ToString()); cv.TicketTronik = double.Parse(cierre[9].ToString()); cierresVenta.Add(cv); } ConnectionHelper.CloseSession(); return cierresVenta; } catch (System.Exception ex) { ConnectionHelper.CloseSession(); throw new EstacionDBException("Error al leer la información de la vista Ventas.", ex); } }
public int guardarCierre(CierreVentasVO cierre) { try { return getCierreDAO().guardarCierre(cierre); } catch (EstacionDBException ex) { throw new PersistenciaException("No se pudo realizar el cierre de ventas para la fecha seleccionada", ex); } }
public int guardarCierre(CierreVentasVO cierre) { int rows = 0; ITransaction tx = null; try { ISession session = ConnectionHelper.getCurrentSession(Utilidades.Utilidades.configExpo); tx = session.BeginTransaction(); if (cierre.IdCierre == 0) { session.Save(cierre); } else { session.Update(cierre); } tx.Commit(); rows++; ConnectionHelper.CloseSession(); return rows; } catch (System.Exception ex) { ConnectionHelper.CloseSession(); throw new EstacionDBException("Error al leer la información de la tabla ventas.", ex); } }
private void cmdGuardar_Click(object sender, EventArgs e) { String resumen = ""; resumen = "Resumen del cierre:\n\n" + "\tCreditos:\t\t\t$ " + String.Format("{0,10:#,0.00}", totalCredito) + "\n" + "\tEfectivo:\t\t\t$ " + String.Format("{0,10:#,0.00}", totalEfectivo) + "\n" + "\tSodexho:\t\t\t$ " + String.Format("{0,10:#,0.00}", totalSodexo) + "\n" + "\tBig Pass:\t\t\t$ " + String.Format("{0,10:#,0.00}", totalBigPass) + "\n" + "\tTarjetas:\t\t\t$ " + String.Format("{0,10:#,0.00}", totalTarjetas) + "\n" + "\tTarjeta Plus:\t\t$ " + String.Format("{0,10:#,0.00}", totalPlus) + "\n" + "\tTicket Prom:\t\t$ " + String.Format("{0,10:#,0.00}", totalTicketTronik) + "\n" + "\tOtros:\t\t\t$ " + String.Format("{0,10:#,0.00}", totalOtros) + "\n" + "TOTAL:\t\t\t$ " + String.Format("{0,10:#,0.00}", totalVentas) + "\n\n" + "¿Desea continuar con el cierre?\n"; DialogResult res = MessageBox.Show(resumen, "Resumen del cierre", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { DateTime fecha = new DateTime(fechaDesdePicker.Value.Year, fechaDesdePicker.Value.Month, fechaDesdePicker.Value.Day); this.UseWaitCursor = true; CierreVentasVO cierre = new CierreVentasVO(); cierre.CodEmpleado = long.Parse(cboEmpleados.SelectedValue.ToString()); cierre.Isla = long.Parse(txtIsla.Text.Trim()); cierre.Turno = long.Parse(txtTurno.Text.Trim()); cierre.Efectivo = totalEfectivo; cierre.Creditos = totalCredito; cierre.Sodexo = totalSodexo; cierre.BigPass = totalBigPass; cierre.Tarjetas = totalTarjetas; cierre.TarjetaPlus = totalPlus; cierre.Otros = totalOtros; cierre.TicketTronik = totalTicketTronik; cierre.TotalVentas = totalVentas; cierre.Fecha = fechaDesdePicker.Value; if (cp.existeCierre(cierre.CodEmpleado, cierre.Turno, cierre.Isla, fecha, fecha) == 0) { int rows = 0; int rowsTurno = 0; rows = cp.guardarCierre(cierre); if (rows > 0) { System.Collections.IList tmpVentas = ventaVOBindingSource.List; VentaVO[] ventas = new VentaVO[tmpVentas.Count]; tmpVentas.CopyTo(ventas, 0); ventasExportar = new List<VentaVO>(ventas); rows = cp.guardarVentasDia(ventasExportar); rowsTurno = cp.guardarProductosTurno(productosTurno); MessageBox.Show("Se guardaron (" + rows + ") ventas en este cierre", "Resultado del cierre ", MessageBoxButtons.OK, MessageBoxIcon.Information); totalEfectivo = 0; totalOtros = 0; totalSodexo = 0; totalBigPass = 0; totalCredito = 0; totalTarjetas = 0; totalPlus = 0; totalTicketTronik = 0; totalVentas = 0; totalConsumos = 0; restaurarCampos(); } else { MessageBox.Show("No se pudo registrar el cierre", "Resultado del cierre ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Ya se ha realizado cierre para la fecha seleccionada", "Resultado del cierre ", MessageBoxButtons.OK, MessageBoxIcon.Error); } UseWaitCursor = false; } }
private double recalcularTotalCierre(CierreVentasVO cierre) { double totalCierre = 0; totalCierre += cierre.Efectivo; totalCierre += cierre.Otros; totalCierre += cierre.Sodexo; totalCierre += cierre.BigPass; totalCierre += cierre.Creditos; totalCierre += cierre.Tarjetas; totalCierre += cierre.TarjetaPlus; totalCierre += cierre.TicketTronik; return totalCierre; }
private void cmdGuardar_Click(object sender, EventArgs e) { System.Collections.IList tmpCierres = cierreVentasVOBindingSource.List; CierreVentasVO[] cierres = new CierreVentasVO[tmpCierres.Count]; tmpCierres.CopyTo(cierres, 0); /*DateTime fecha = DateTime.Parse(txtFechaDesde.Text); DateTime fechaAplica = DateTime.Parse(txtFechaAplica.Text);*/ int res = 0; res = cp.guardarCierres(new List<CierreVentasVO>(cierres)); MessageBox.Show("Cierres guardados para la fecha: " + txtFecha.Text, "Cambios guardados", MessageBoxButtons.OK, MessageBoxIcon.Information); cierreVentasVOBindingSource.Clear(); totalEfectivo = 0; totalOtros = 0; totalSodexo = 0; totalBigPass = 0; totalCredito = 0; totalTarjetas = 0; totalPlus = 0; totalTicketTronik = 0; totalVentas = 0; restaurarCampos(); }