private void Buscar() { DateTime FechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime FechaHasta = Convert.ToDateTime(txtFechaHasta.Text); cTransferencia tra = new cTransferencia(); DataTable trdo = tra.GetTransferencia(FechaDesde, FechaHasta); trdo = fun.TablaaMiles(trdo, "Importe"); trdo = fun.TablaaFechas(trdo, "FechaCobro"); Grilla.DataSource = trdo; fun.AnchoColumnas(Grilla, "0;30;30;20;20;0"); Grilla.Columns[3].HeaderText = "Fecha Cobro"; }
private void btnCobrar_Click(object sender, EventArgs e) { if (fun.ValidarFecha(txtFechaCobro.Text) == false) { Mensaje("La fecha de cobro es incorrecta"); return; } if (Grilla.CurrentRow == null) { Mensaje("Debe seleccionar un elemento"); return; } if (Grilla.CurrentRow.Cells[3].Value.ToString() != "") { Mensaje("Ya se ha cobrado la transferencia"); return; } Int32 Codigo = Convert.ToInt32(Grilla.CurrentRow.Cells[0].Value.ToString()); Double Importe = fun.ToDouble(Grilla.CurrentRow.Cells[4].Value.ToString()); Int32 CodOrden = Convert.ToInt32(Grilla.CurrentRow.Cells[5].Value.ToString()); DateTime Fecha = Convert.ToDateTime(txtFechaCobro.Text); cMovimiento mov = new cMovimiento(); cTransferencia transfer = new cTransferencia(); SqlConnection con = new SqlConnection(cConexion.Cadenacon()); SqlTransaction tran; con.Open(); tran = con.BeginTransaction(); try { transfer.ActualizarFechaCobro(con, tran, Codigo, Fecha); mov.GrabarMovimientoTransaccion(con, tran, Importe, "Cobro de transferencia", Fecha, Principal.CodUsuarioLogueado, CodOrden); tran.Commit(); con.Close(); Mensaje("Datos grabados correctamente"); Buscar(); } catch (Exception ex) { tran.Rollback(); con.Close(); Mensaje("Hubo un error en el proceso de grabación"); } }
private void GetRentabilidad() { cCobroTarjeta objCobro = new cCobroTarjeta(); Clases.cFunciones fun = new Clases.cFunciones(); DateTime FechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime FechaHasta = Convert.ToDateTime(txtFechaHasta.Text); cOrden orden = new cOrden(); txtCantidad.Text = orden.CantidadOrdenes(FechaDesde, FechaHasta).ToString(); double Efectivo = orden.GetTotalEfectivo(FechaDesde, FechaHasta); txtEfectivo.Text = Efectivo.ToString(); if (txtEfectivo.Text != "") { txtEfectivo.Text = fun.FormatoEnteroMiles(txtEfectivo.Text); } double TotalTarjeta = 0; cCobroTarjeta cobro = new cCobroTarjeta(); TotalTarjeta = cobro.GetTotalTarjeta(FechaDesde, FechaHasta); // Double Saldo = cobro.GetSaldoxFecha(FechaDesde, FechaHasta); txtDiferenciaTarjeta.Text = Saldo.ToString(); TotalTarjeta = TotalTarjeta - Saldo; txtTarjeta.Text = TotalTarjeta.ToString(); if (txtTarjeta.Text != "") { txtTarjeta.Text = fun.FormatoEnteroMiles(txtTarjeta.Text); } if (txtDiferenciaTarjeta.Text != "") { txtDiferenciaTarjeta.Text = fun.FormatoEnteroMiles(txtDiferenciaTarjeta.Text); } cDocumento doc = new cDocumento(); double ImporteDocu = doc.GetTotalDocumento(FechaDesde, FechaHasta); txtImporteDocumento.Text = ImporteDocu.ToString(); if (txtImporteDocumento.Text != "") { txtImporteDocumento.Text = fun.FormatoEnteroMiles(txtImporteDocumento.Text); } cCheque cheque = new cCheque(); double ImporteCheque = cheque.GetTotalChequexFecha(FechaDesde, FechaHasta); txtcheque.Text = ImporteCheque.ToString(); if (txtcheque.Text != "") { txtcheque.Text = fun.FormatoEnteroMiles(txtcheque.Text); } cGarantia garantia = new cGarantia(); double ImporteGarantia = garantia.GetTotalGarantiaxFecha(FechaDesde, FechaHasta); txtGarantia.Text = ImporteGarantia.ToString(); if (txtGarantia.Text != "") { txtGarantia.Text = fun.FormatoEnteroMiles(txtGarantia.Text); } cCuentaCorriente cc = new cCuentaCorriente(); Double ImporteCuentaCorriene = 0; ImporteCuentaCorriene = cc.GetTotalCuentaxFecha(FechaDesde, FechaHasta); txtTotalCuentaCorriente.Text = ImporteCuentaCorriene.ToString(); if (txtTotalCuentaCorriente.Text != "") { txtTotalCuentaCorriente.Text = fun.FormatoEnteroMiles(txtTotalCuentaCorriente.Text); } cTransferencia tranfer = new cTransferencia(); Double ImporteTransferencia = tranfer.GetTotalTransferencia(FechaDesde, FechaHasta); txtTotalTransferencia.Text = ImporteTransferencia.ToString(); if (txtTotalTransferencia.Text != "") { txtTotalTransferencia.Text = fun.FormatoEnteroMiles(txtTotalTransferencia.Text); } double TotalFacturado = Efectivo + TotalTarjeta + ImporteDocu + ImporteCheque + ImporteGarantia + ImporteCuentaCorriene + ImporteTransferencia; txtTotalFacturado.Text = TotalFacturado.ToString(); if (txtTotalFacturado.Text != "") { txtTotalFacturado.Text = fun.FormatoEnteroMiles(txtTotalFacturado.Text); } double GananciaInsumos = orden.GetGananciaInsumo(FechaDesde, FechaHasta); double RecargoTarjeta = objCobro.GetTotalRecargoTarjeta(FechaDesde, FechaHasta); double VentaInsumo = orden.GetVentaInsumo(FechaDesde, FechaHasta); double CostoInsumo = orden.GetCostoInsumo(FechaDesde, FechaHasta); txtVentaInsumos.Text = VentaInsumo.ToString(); txtCostoInsumo.Text = CostoInsumo.ToString(); double GananciaInsuloMostrador = 0; cVenta objVenta = new cVenta(); double CostoMostrador = 0; CostoMostrador = objVenta.GetCostoInsumoVenta(FechaDesde, FechaHasta); txtCostoInsumoMostrador.Text = CostoMostrador.ToString(); //GetVentaInsumoVenta double VentaMostrador = 0; VentaMostrador = objVenta.GetVentaInsumoVenta(FechaDesde, FechaHasta); txtVentaMostrador.Text = VentaMostrador.ToString(); if (txtCostoInsumoMostrador.Text != "") { txtCostoInsumoMostrador.Text = fun.FormatoEnteroMiles(txtCostoInsumoMostrador.Text); } if (txtVentaMostrador.Text != "") { txtVentaMostrador.Text = fun.FormatoEnteroMiles(txtVentaMostrador.Text); } if (txtVentaInsumos.Text != "") { txtVentaInsumos.Text = fun.FormatoEnteroMiles(txtVentaInsumos.Text); } if (txtCostoInsumo.Text != "") { txtCostoInsumo.Text = fun.FormatoEnteroMiles(txtCostoInsumo.Text); } txtGananciaInsumos.Text = GananciaInsumos.ToString(); if (txtGananciaInsumos.Text != "") { txtGananciaInsumos.Text = fun.FormatoEnteroMiles(txtGananciaInsumos.Text); } GananciaInsuloMostrador = VentaMostrador - CostoMostrador; txtGananciaMostrador.Text = GananciaInsuloMostrador.ToString(); if (txtGananciaMostrador.Text != "") { txtGananciaMostrador.Text = fun.FormatoEnteroMiles(txtGananciaMostrador.Text); } double GananciaMo = orden.GetGananciaManoObra(FechaDesde, FechaHasta); txtManoObra.Text = GananciaMo.ToString(); if (txtManoObra.Text != "") { txtManoObra.Text = fun.FormatoEnteroMiles(txtManoObra.Text); } double TotalGanancia = GananciaInsumos + GananciaMo + RecargoTarjeta + GananciaInsuloMostrador - Saldo; txtTotalGanancia.Text = TotalGanancia.ToString(); if (txtTotalGanancia.Text != "") { txtTotalGanancia.Text = fun.FormatoEnteroMiles(txtTotalGanancia.Text); } double GastoAlquiler = 0; cGastosNegocio gasto = new cGastosNegocio(); Int32? CodEntidad = 11; GastoAlquiler = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); txtGastoAlquiler.Text = GastoAlquiler.ToString(); if (txtGastoAlquiler.Text != "") { txtGastoAlquiler.Text = fun.FormatoEnteroMiles(txtGastoAlquiler.Text); } double Sueldos = 0; CodEntidad = 6; Sueldos = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); txtSueldo.Text = Sueldos.ToString(); if (txtSueldo.Text != "") { txtSueldo.Text = fun.FormatoEnteroMiles(txtSueldo.Text); } double Combustible = 0; CodEntidad = 13; Combustible = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); txtCombustible.Text = Combustible.ToString(); if (txtCombustible.Text != "") { txtCombustible.Text = fun.FormatoEnteroMiles(txtCombustible.Text); } double Impuestos = 0; CodEntidad = 2; Impuestos = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); txtImpuesto.Text = Impuestos.ToString(); if (txtImpuesto.Text != "") { txtImpuesto.Text = fun.FormatoEnteroMiles(txtImpuesto.Text); } double Varios = 0; CodEntidad = null; Varios = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); Varios = Varios - Sueldos - Impuestos - Combustible - GastoAlquiler; txtOtrosGastos.Text = Varios.ToString(); if (txtOtrosGastos.Text != "") { txtOtrosGastos.Text = fun.FormatoEnteroMiles(txtOtrosGastos.Text); } double TotalGastos = 0; TotalGastos = Varios + Sueldos + Impuestos + Combustible + GastoAlquiler; //+Saldo; txtTotalGastos.Text = TotalGastos.ToString(); if (txtTotalGastos.Text != "") { txtTotalGastos.Text = fun.FormatoEnteroMiles(txtTotalGastos.Text); } double Rentabilidad = TotalGanancia - TotalGastos; txtRentabilidad.Text = Rentabilidad.ToString(); if (txtRentabilidad.Text != "") { txtRentabilidad.Text = fun.FormatoEnteroMiles(txtRentabilidad.Text); } double SaldoGarantia = garantia.GetTotalSaldoGarantiaxFecha(FechaDesde, FechaHasta); txtSaldoGarantia.Text = SaldoGarantia.ToString(); if (txtSaldoGarantia.Text != "") { txtSaldoGarantia.Text = fun.FormatoEnteroMiles(txtSaldoGarantia.Text); } double TotalSaldoTarjeta = cobro.GetTotalSaldoTarjeta(FechaDesde, FechaHasta); txtSaldoTarjeta.Text = TotalSaldoTarjeta.ToString(); if (txtSaldoTarjeta.Text != "") { txtSaldoTarjeta.Text = fun.FormatoEnteroMiles(txtSaldoTarjeta.Text); } double ImporteSaldoDoc = doc.GetTotalSaldoDocumento(FechaDesde, FechaHasta); txtSaldoDocumento.Text = ImporteSaldoDoc.ToString(); if (txtSaldoDocumento.Text != "") { txtSaldoDocumento.Text = fun.FormatoEnteroMiles(txtSaldoDocumento.Text); } double ImporteSaldoCheque = cheque.GetTotalSaldoChequexFecha(FechaDesde, FechaHasta); txtSaldoCheque.Text = ImporteSaldoCheque.ToString(); if (txtSaldoCheque.Text != "") { txtSaldoCheque.Text = fun.FormatoEnteroMiles(txtSaldoCheque.Text); } }
private void EliminarOrden(Int32 CodOrden) { Double ImporteCobrodoDocumento = 0; Int32 CodDocumentoa = 0; Double ImporteEfectivoOrden = 0; Double ImporteCobradoTarjeta = 0; Double ImporteGatantia = 0; Double ImporteCheque = 0; cOrden orden = new cOrden(); cCobroDocumento cob = new cCobroDocumento(); cCobroTarjeta cobTarj = new cCobroTarjeta(); cGarantia garantia = new Clases.cGarantia(); cCobroCheque cobroCheque = new cCobroCheque(); cCheque cheque = new cCheque(); ImporteEfectivoOrden = orden.GetTotalEfectivoOrden(CodOrden); ImporteCobrodoDocumento = cob.GetTotalDocumentoCobrado(CodOrden); CodDocumentoa = cob.GetCodDocumentoxCodOrden(CodOrden); ImporteCobradoTarjeta = cobTarj.GetImporteCobradoxCodOrden(CodOrden); ImporteGatantia = garantia.GetImporteCobradoxCodOrden(CodOrden); ImporteCheque = cobroCheque.GetTotalChequeCobrado(CodOrden); cMovimiento mov = new cMovimiento(); cDocumento doc = new cDocumento(); SqlConnection con = new SqlConnection(cConexion.Cadenacon()); DateTime Fecha = DateTime.Now; string Descripcion = ""; con.Open(); SqlTransaction tran; tran = con.BeginTransaction("TranOrden"); try { if (ImporteEfectivoOrden > 0) { Descripcion = "Anulación Cobro de efectivo, Orden " + CodOrden.ToString(); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteEfectivoOrden, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } if (ImporteCobradoTarjeta > 0) { Descripcion = "Anulación Cobro de tarjeta, Orden " + CodOrden.ToString(); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteCobradoTarjeta, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } if (ImporteGatantia > 0) { Descripcion = "Anulación Cobro de garantía, Orden " + CodOrden.ToString(); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteGatantia, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } if (ImporteCheque > 0) { //saco los codcheque para borrar los cobros cheques DataTable tbcheque = cheque.GetChquesxCodOrden(CodOrden); if (tbcheque.Rows.Count > 0) { for (int i = 0; i < tbcheque.Rows.Count; i++) { if (tbcheque.Rows[i]["CodCheque"].ToString() != "") { Int32 CodCheque = Convert.ToInt32(tbcheque.Rows[i]["CodCheque"].ToString()); cobroCheque.BorrarCobroCheque(con, tran, CodCheque); } } } Descripcion = "Anulación Cobro de cheque, Orden " + CodOrden.ToString(); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteCheque, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } if (ImporteCobrodoDocumento > 0) { Descripcion = "Anulación Cobro de Documento, Orden " + CodOrden.ToString(); cob.BorrarCobroDocumentoxCodDocumento(con, tran, CodDocumentoa); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteCobrodoDocumento, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } cTransferencia transferencia = new cTransferencia(); garantia.BorrarGarantia(con, tran, CodOrden); cheque.BorrarchquexCodOrden(con, tran, CodOrden); doc.BorrarDocumentoxCodOrden(con, tran, CodOrden); cobTarj.BorrarCobroTarjeta(con, tran, CodOrden); orden.EliminarOrden(con, tran, CodOrden); transferencia.BorrarTransferencia(con, tran, CodOrden); tran.Commit(); Mensaje("Orden de Trabajo eliminada correctamente, se actualizaron las cuentas"); con.Close(); Buscar(); } catch (Exception) { tran.Rollback(); con.Close(); Mensaje("Hubo un error en el proceso de anulación"); throw; } }