private void btnAnular_Click(object sender, EventArgs e) { if (txtCuota.Text == "") { MessageBox.Show("Debe ingresar una cuota para continuar.", Clases.cMensaje.Mensaje()); return; } if (txtImportePagado.Text == "") { MessageBox.Show("Debe ingresar un monto de la cuota.", Clases.cMensaje.Mensaje()); return; } Clases.cFunciones fun = new Clases.cFunciones(); double Importe = fun.ToDouble(txtImporte.Text); double ImportePagado = fun.ToDouble(txtImportePagado.Text); ImportePagado = ImportePagado * (-1); Int32 CodUsuario = Principal.CodUsuarioLogueado; Int32 Cuota = Convert.ToInt32(txtCuota.Text); Int32 CodVenta = Convert.ToInt32(txtCodVenta.Text); GetPunitorio(CodVenta, Cuota); Double Punitorio = fun.ToDouble(txtPunitorio.Text); Punitorio = Punitorio * (-1); Clases.cCuota objCuota = new Clases.cCuota(); if (objCuota.AnularCuota(CodVenta, Cuota, ImportePagado, CodUsuario, txtPatente.Text, Punitorio)) { MessageBox.Show("Datos grabados correctamente.", Clases.cMensaje.Mensaje()); CargarPlandeCuotas(CodVenta); } }
private double GetSaldoCuotaxCodVenta(Int32 CodVenta) { Clases.cCuota cuota = new Clases.cCuota(); double Saldo = 0; Saldo = cuota.GetSaldoDeudaCuotas(CodVenta); return(Saldo); }
private void CargarPlandeCuotas(Int32 CodVenta) { Clases.cFunciones fun = new Clases.cFunciones(); Clases.cCuota cuota = new Clases.cCuota(); DataTable trdo = cuota.GetCuotasxCodVenta(CodVenta); trdo = fun.TablaaMiles(trdo, "Importe"); trdo = fun.TablaaMiles(trdo, "ImportePagado"); trdo = fun.TablaaMiles(trdo, "Saldo"); GrillaCuotas.DataSource = trdo; }
private void btnPagarSaldo_Click(object sender, EventArgs e) { Clases.cFunciones fun = new Clases.cFunciones(); if (txtImportePagado.Text == "") { MessageBox.Show("Debe ingresar un importe", Clases.cMensaje.Mensaje()); return; } double Saldo = fun.ToDouble(txtSaldo.Text); double Importe = fun.ToDouble(txtImportePagado.Text); Double Punitorio = 0; if (txtPunitorio.Text != "") { Punitorio = fun.ToDouble(txtPunitorio.Text); } if (Importe > Saldo) { MessageBox.Show("El saldo es superior al importe", Clases.cMensaje.Mensaje()); return; } Clases.cMovimiento mov = new Clases.cMovimiento(); Clases.cSaldoCuota saldoCuotas = new Clases.cSaldoCuota(); string Descripcion = "PAGO DE SALDO CUOTA" + txtCuota.Text; Descripcion = Descripcion + ", PATENTE " + txtPatente.Text; Int32 Cuota = Convert.ToInt32(txtCuota.Text); Int32 CodVenta = Convert.ToInt32(txtCodVenta.Text); Clases.cCuota cuota = new Clases.cCuota(); DateTime Fecha = Convert.ToDateTime(txtFecha.Text); cuota.PagarSaldoCuota(CodVenta, Cuota, Importe); mov.RegistrarMovimientoDescripcion(-1, Principal.CodUsuarioLogueado, Importe, 0, 0, 0, 0, Fecha, Descripcion); saldoCuotas.InsertarSaldoCob(CodVenta, Cuota, Fecha, Importe); MessageBox.Show("Datos grabados correctamente", Clases.cMensaje.Mensaje()); }
private void ArmarDataTableDeudores() { string Apellido = null; if (txtApellido.Text != "") { Apellido = txtApellido.Text; } Clases.cVenta objVenta = new Clases.cVenta(); DateTime FechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime FechaHasta = Convert.ToDateTime(txtFechaHasta.Text); Int32 CodVenta = 0; Double Cobranza = 0; Clases.cFunciones fun = new Clases.cFunciones(); cCobranza objCobranza = new cCobranza(); string Col = "CodVenta;Patente;Descripcion;Apellido;ImporteVenta;Cuotas;Cheque;Cobranza;Prenda;Telefono;Tipo"; //Tipo se usa para saber a donde tiene que abrir Clases.cCuota cuota = new Clases.cCuota(); Clases.cCheque objCheque = new Clases.cCheque(); cPrenda objPrenda = new cPrenda(); string telefono = ""; int TieneDeuda = 0; Double Cuotas = 0; Double Prenda = 0; Double Cheque = 0; string val = ""; int TipoPantalla = 1; DataTable tb = new DataTable(); tb = fun.CrearTabla(Col); DataTable trdo = objVenta.GetVentasxFecha(FechaDesde, FechaHasta, txtPatente.Text.Trim(), Apellido); for (int i = 0; i < trdo.Rows.Count; i++) { CodVenta = Convert.ToInt32(trdo.Rows[i]["CodVenta"].ToString()); TieneDeuda = objVenta.TieneDeuda(CodVenta); if (TieneDeuda == 1) { Cuotas = cuota.GetSaldoDeudaCuotas(CodVenta); Cheque = objCheque.GetSaldoCheque(CodVenta); Cobranza = objCobranza.GetSaldoCobranza(CodVenta); Prenda = objPrenda.ImporteAdeudado(CodVenta); telefono = BuscarTelefonoCliente(CodVenta); val = CodVenta.ToString(); val = val + ";" + trdo.Rows[i]["Patente"].ToString(); val = val + ";" + trdo.Rows[i]["Descripcion"].ToString(); val = val + ";" + trdo.Rows[i]["Apellido"].ToString(); val = val + ";" + trdo.Rows[i]["ImporteVenta"].ToString(); val = val + ";" + Cuotas.ToString(); val = val + ";" + Cheque.ToString(); val = val + ";" + Cobranza.ToString(); val = val + ";" + Prenda.ToString(); val = val + ";" + telefono.ToString(); val = val + ";" + TipoPantalla.ToString(); tb = fun.AgregarFilas(tb, val); } } TipoPantalla = 2; //agrego las cuotas anteriores cCuotasAnteriores cuotasAnt = new cCuotasAnteriores(); DataTable tcuotasAnt = cuotasAnt.GetCuotasAnterioresAdeudadesxFecha(txtPatente.Text, txtApellido.Text, FechaDesde, FechaHasta); for (int i = 0; i < tcuotasAnt.Rows.Count; i++) { val = tcuotasAnt.Rows[i]["CodGrupo"].ToString(); val = val + ";" + tcuotasAnt.Rows[i]["Patente"].ToString(); val = val + ";" + tcuotasAnt.Rows[i]["Descripcion"].ToString(); val = val + ";" + tcuotasAnt.Rows[i]["Apellido"].ToString(); val = val + ";" + tcuotasAnt.Rows[i]["Importe"].ToString(); val = val + ";"; val = val + ";"; val = val + ";"; val = val + ";"; val = val + ";" + tcuotasAnt.Rows[i]["Telefono"].ToString(); val = val + ";" + TipoPantalla.ToString(); tb = fun.AgregarFilas(tb, val); } TipoPantalla = 3; //Cobranza general cCobranzaGeneral cobGen = new cCobranzaGeneral(); DataTable tbCobGen = cobGen.GetDedudaCobranzaGeneralxFecha(Apellido, txtPatente.Text, FechaDesde, FechaHasta); for (int i = 0; i < tbCobGen.Rows.Count; i++) { val = tbCobGen.Rows[i]["CodCobranza"].ToString(); val = val + ";" + tbCobGen.Rows[i]["Patente"].ToString(); val = val + ";" + tbCobGen.Rows[i]["Descripcion"].ToString(); val = val + ";" + tbCobGen.Rows[i]["Cliente"].ToString(); val = val + ";" + tbCobGen.Rows[i]["Importe"].ToString(); val = val + ";" + tbCobGen.Rows[i]["Importe"].ToString(); val = val + ";"; val = val + ";" + tbCobGen.Rows[i]["Importe"].ToString(); val = val + ";"; val = val + ";" + tbCobGen.Rows[i]["Telefono"].ToString(); val = val + ";" + TipoPantalla.ToString(); tb = fun.AgregarFilas(tb, val); } // Double TotalVenta = fun.TotalizarColumna(tb, "ImporteVenta"); Double TotalCuotas = fun.TotalizarColumna(tb, "Cuotas"); Double TotalPrenda = fun.TotalizarColumna(tb, "Prenda"); Double TotalCobranza = fun.TotalizarColumna(tb, "Cobranza"); Double TotalCheque = fun.TotalizarColumna(tb, "Cheque"); val = ""; val = val + ";"; val = val + ";"; val = val + ";"; val = val + ";" + TotalVenta.ToString(); val = val + ";" + TotalCuotas.ToString(); val = val + ";" + TotalCheque.ToString(); val = val + ";" + TotalCobranza.ToString(); val = val + ";" + TotalPrenda.ToString(); val = val + ";" + telefono.ToString(); tb = fun.AgregarFilas(tb, val); tb = fun.TablaaMiles(tb, "ImporteVenta"); tb = fun.TablaaMiles(tb, "Cuotas"); tb = fun.TablaaMiles(tb, "Cheque"); tb = fun.TablaaMiles(tb, "Cobranza"); tb = fun.TablaaMiles(tb, "Prenda"); Grilla.DataSource = tb; Grilla.Columns[0].Visible = false; Grilla.Columns[10].Visible = false; Grilla.Columns[4].HeaderText = "Total"; Grilla.Columns[5].HeaderText = "Documentos"; for (int i = 0; i < Grilla.Rows.Count - 1; i++) { if (i == (Grilla.Rows.Count - 2)) { Grilla.Rows[i].DefaultCellStyle.BackColor = Color.LightGreen; } } }
private void Actualizar() { //obtengo el importe de documentos a cobrar GetDeudasxPrestamo(); GetEfectivosaPagar(); GetCobranzaGeneral(); GetChequesPagar(); Clases.cFunciones fun = new Clases.cFunciones(); Clases.cCuota cuota = new Clases.cCuota(); Clases.cCuotasAnteriores cuotasAnt = new Clases.cCuotasAnteriores(); Clases.cCheque cheque = new Clases.cCheque(); Double ImporteCheque = cheque.GetTotalChequesaCobrar(); Clases.cChequeCobrar chequeCob = new Clases.cChequeCobrar(); ImporteCheque = ImporteCheque + chequeCob.GetTotalChequesaCobrar(); Double Importe = cuota.GetMontoCuotasImpagas(); Double ImporteCuotasAnteriores = cuotasAnt.GetMontoCuotasImpagas(); Importe = Importe + ImporteCuotasAnteriores; Double ImporteSinInteres = cuota.GetMontoCuotasImpagasSinInteres(); double ImporteSinInteresCuotasAnt = cuotasAnt.GetMontoCuotasImpagasSinInteres(); ImporteSinInteres = ImporteSinInteres + ImporteSinInteresCuotasAnt; txtDocumentos.Text = fun.TransformarEntero(Importe.ToString().Replace(",", ".")); txtDocumentos.Text = fun.FormatoEnteroMiles(txtDocumentos.Text); txtDocumentosSinInteres.Text = ImporteSinInteres.ToString(); txtDocumentosSinInteres.Text = fun.TransformarEntero(ImporteSinInteres.ToString()); txtDocumentosSinInteres.Text = fun.FormatoEnteroMiles(txtDocumentosSinInteres.Text); txtTotalCheque.Text = fun.FormatoEnteroMiles(ImporteCheque.ToString()); Clases.cResumenCuentas res = new Clases.cResumenCuentas(); DataTable trdo = res.GetResumenCuentas(); if (trdo.Rows.Count > 0) { double ImporteEfectivo = Convert.ToDouble(trdo.Rows[0]["ImporteEfectivo"]); txtEfectivo.Text = fun.TransformarEntero(ImporteEfectivo.ToString().Replace(",", ".")); txtEfectivo.Text = fun.FormatoEnteroMiles(txtEfectivo.Text); double ImporteAuto = Convert.ToDouble(trdo.Rows[0]["ImporteAuto"]); txtVehículo.Text = fun.TransformarEntero(ImporteAuto.ToString().Replace(",", ".")); txtVehículo.Text = fun.FormatoEnteroMiles(txtVehículo.Text); double ImportePrenda = Convert.ToDouble(trdo.Rows[0]["ImportePrenda"]); txtPrenda.Text = fun.TransformarEntero(ImportePrenda.ToString().Replace(",", ".")); txtPrenda.Text = fun.FormatoEnteroMiles(txtPrenda.Text); double ImporteCobranza = Convert.ToDouble(trdo.Rows[0]["ImporteCobranza"]); txtCobranzas.Text = fun.TransformarEntero(ImporteCobranza.ToString().Replace(",", ".")); txtCobranzas.Text = fun.FormatoEnteroMiles(txtCobranzas.Text); double ImporteBanco = Convert.ToDouble(trdo.Rows[0]["ImporteBanco"]); txtBanco.Text = fun.TransformarEntero(ImporteBanco.ToString().Replace(",", ".")); txtBanco.Text = fun.FormatoEnteroMiles(txtBanco.Text); Clases.cComisionVendedor com = new Clases.cComisionVendedor(); txtComisiones.Text = com.GetComisionesPendientes().ToString(); if (txtComisiones.Text != "") { txtComisiones.Text = fun.FormatoEnteroMiles(txtComisiones.Text); } Clases.cGastosPagar gasto = new Clases.cGastosPagar(); txtGastosPendientes.Text = gasto.GetGastosaPagar().ToString(); if (txtGastosPendientes.Text != "") { txtGastosPendientes.Text = fun.FormatoEnteroMiles(txtGastosPendientes.Text); } Clases.cCobranza cob = new Clases.cCobranza(); txtCobranzas.Text = cob.GetTotalDeudaCobranzas().ToString(); txtCobranzas.Text = fun.FormatoEnteroMiles(txtCobranzas.Text); GetPrendas(); GetTotalVehiculo(); GetTarjeta(); } }
private void GetGanancia() { Clases.cFunciones fun = new Clases.cFunciones(); Clases.cVenta objVenta = new Clases.cVenta(); Clases.cPunitorioCobranza objPunitorioCobranza = new Clases.cPunitorioCobranza(); Clases.cPunitorioCuota objPunitorioCuota = new Clases.cPunitorioCuota(); DateTime FechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime FechaHasta = Convert.ToDateTime(txtFechaHasta.Text); DataTable trdo = objVenta.GetVentasxFecha(FechaDesde, FechaHasta, "", null); Clases.cPreVenta objPreVenta = new Clases.cPreVenta(); DataTable trdo2 = objPreVenta.GetPreVentasxFecha(FechaDesde, FechaHasta, "", null); //le agre[g string Dato = ""; Int32 PosPintar = 0; PosPintar = trdo.Rows.Count; for (int i = 0; i < trdo2.Rows.Count; i++) { DataRow fila; fila = trdo.NewRow(); for (int j = 0; j < trdo2.Columns.Count; j++) { Dato = trdo2.Rows[i][j].ToString(); fila[j] = Dato; } trdo.Rows.Add(fila); } Clases.cPunitorioCuotasAnteriores objPunDocAnt = new Clases.cPunitorioCuotasAnteriores(); Int32 Cant = trdo.Rows.Count; txtCantidad.Text = Cant.ToString(); trdo = fun.TablaaMiles(trdo, "ImporteVenta"); trdo = fun.TablaaMiles(trdo, "ImporteEfectivo"); trdo = fun.TablaaMiles(trdo, "ImporteAutoPartePago"); trdo = fun.TablaaMiles(trdo, "ImporteCredito"); trdo = fun.TablaaMiles(trdo, "ImportePrenda"); trdo = fun.TablaaMiles(trdo, "Cheque"); trdo = fun.TablaaMiles(trdo, "ImporteCobranza"); trdo = fun.TablaaMiles(trdo, "Ganancia"); double Utilidad = fun.TotalizarColumna(trdo, "Ganancia"); Double ImportePunitorioCobranza = objPunitorioCobranza.GetImportexFecha(FechaDesde, FechaHasta); Double ImportePunitorioCuota = objPunitorioCuota.GetImportexFecha(FechaDesde, FechaHasta); Double ImportePunitorioCuotasAnterioes = objPunDocAnt.GetImportexFecha(FechaDesde, FechaHasta); Double TotalPunitorio = ImportePunitorioCobranza + ImportePunitorioCuota + ImportePunitorioCuotasAnterioes; txtUtilidad.Text = fun.TotalizarColumna(trdo, "Ganancia").ToString(); txtUtilidad.Text = fun.FormatoEnteroMiles(txtUtilidad.Text); Clases.cGastosNegocio gastos = new Clases.cGastosNegocio(); double TotalGastos = gastos.GetGastosNegocioxFecha(FechaDesde, FechaHasta); txtGastos.Text = fun.SepararDecimales(TotalGastos.ToString()); txtGastos.Text = fun.FormatoEnteroMiles(txtGastos.Text); Clases.cPagoIntereses objpago = new Clases.cPagoIntereses(); double TotalPago = objpago.GetResumenPagosInteresesxFecha(FechaDesde, FechaHasta); txtInteresesPagados.Text = fun.SepararDecimales(TotalPago.ToString()); txtInteresesPagados.Text = fun.FormatoEnteroMiles(txtInteresesPagados.Text); double InteresesGanados = 0; Clases.cCuotasAnteriores cuotasAnt = new Clases.cCuotasAnteriores(); Clases.cCuota cuota = new Clases.cCuota(); InteresesGanados = cuota.GetGanaciaCobroCuotas(FechaDesde, FechaHasta); InteresesGanados = InteresesGanados + cuotasAnt.GetGanaciaCobroCuotas(FechaDesde, FechaHasta); txtInteresesGanados.Text = InteresesGanados.ToString(); txtInteresesGanados.Text = fun.FormatoEnteroMiles(txtInteresesGanados.Text); double Ganancia = Utilidad + TotalPunitorio - TotalPago - TotalGastos + InteresesGanados; txtResultado.Text = fun.SepararDecimales(Ganancia.ToString()); txtResultado.Text = fun.FormatoEnteroMiles(txtResultado.Text); txtPunitorio.Text = TotalPunitorio.ToString(); txtPunitorio.Text = fun.FormatoEnteroMiles(txtPunitorio.Text); }
private void btnBuscar_Click(object sender, EventArgs e) { Clases.cFunciones fun = new Clases.cFunciones(); if (fun.ValidarFecha(txtFechaDesde.Text) == false) { MessageBox.Show("Fecha desde incorrecta", Clases.cMensaje.Mensaje()); return; } if (fun.ValidarFecha(txtFechaHasta.Text) == false) { MessageBox.Show("Fecha hasta incorrecta", Clases.cMensaje.Mensaje()); return; } if (Convert.ToDateTime(txtFechaDesde.Text) > Convert.ToDateTime(txtFechaHasta.Text)) { MessageBox.Show("La fecha desde debe ser inferior a la fecha hasta", Clases.cMensaje.Mensaje()); return; } Boolean SoloImpago = false; if (chkImpagos.Checked == true) { SoloImpago = true; } //Clases.cFunciones fun = new Clases.cFunciones(); Clases.cCuota cuota = new Clases.cCuota(); DateTime FechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime FechaHasta = Convert.ToDateTime(txtFechaHasta.Text); DataTable trdo = cuota.GetDeuda(FechaDesde, FechaHasta, SoloImpago, txtPatente.Text, txtApellido.Text); trdo = fun.TablaaMiles(trdo, "Saldo"); txtTotal.Text = fun.TotalizarColumna(trdo, "Importe").ToString(); if (txtTotal.Text != "") { txtTotal.Text = fun.SepararDecimales(txtTotal.Text); txtTotal.Text = fun.FormatoEnteroMiles(txtTotal.Text); } else { txtTotal.Text = "0"; } trdo = fun.TablaaMiles(trdo, "Importe"); trdo = fun.TablaaMiles(trdo, "ImportePagado"); Grilla.DataSource = trdo; Grilla.Columns[2].HeaderText = "Importe Pagado"; Grilla.Columns[6].HeaderText = "Teléfono"; Grilla.Columns[1].Width = 150; Grilla.Columns[2].Width = 150; Grilla.Columns[3].Width = 150; Grilla.Columns[0].Width = 78; Grilla.Columns[5].Width = 150; Grilla.Columns[6].Width = 150; Grilla.Columns[7].Width = 150; Grilla.Columns[8].Width = 150; Grilla.Columns[6].Visible = false; Grilla.Columns[7].Visible = false; Grilla.Columns[8].Width = 120; Grilla.Columns[3].Width = 80; Grilla.Columns[9].Width = 100; Grilla.Columns[10].Width = 220; }
private void btnAnular_Click(object sender, EventArgs e) { if (Grilla.CurrentRow == null) { MessageBox.Show("Debe seleccionar un registro para continuar ", Clases.cMensaje.Mensaje()); return; } string msj = "Confirma anular la venta "; var result = MessageBox.Show(msj, "Información", MessageBoxButtons.YesNo, MessageBoxIcon.Question); // If the no button was pressed ... if (result == DialogResult.No) { return; } string Patente = Grilla.CurrentRow.Cells[4].Value.ToString(); string CodVenta = Grilla.CurrentRow.Cells[0].Value.ToString(); // Int32 CodAutoPartePago1 = 0; Int32 CodAutoPartePago2 = 0; double ImportePagadoCobranza = 0; double ImportePagadoCuotas = 0; double ImportePagadoPrenda = 0; double ImportePagadoCheque = 0; Clases.cVenta objVenta2 = new Clases.cVenta(); Clases.cCobranza cobranza = new Clases.cCobranza(); Clases.cPrenda prenda = new Clases.cPrenda(); ImportePagadoCobranza = cobranza.GetImportePagado(Convert.ToInt32(CodVenta)); Clases.cCuota cuota = new Clases.cCuota(); Clases.cCheque cheque = new Clases.cCheque(); ImportePagadoCuotas = cuota.ImportePagado(Convert.ToInt32(CodVenta)); ImportePagadoPrenda = prenda.ImportePagado(Convert.ToInt32(CodVenta)); ImportePagadoCheque = cheque.ImportePagado(Convert.ToInt32(CodVenta)); DataTable tresult2 = objVenta2.GetAutosPartePago(Convert.ToInt32(CodVenta)); for (int z = 0; z < tresult2.Rows.Count; z++) { if (z == 0) { if (tresult2.Rows[0]["CodAuto"].ToString() != "") { CodAutoPartePago1 = Convert.ToInt32(tresult2.Rows[0]["CodAuto"].ToString()); } } if (z == 1) { if (tresult2.Rows[0]["CodAuto"].ToString() != "") { CodAutoPartePago2 = Convert.ToInt32(tresult2.Rows[0]["CodAuto"].ToString()); } } } double ImporteAutoPartePago = 0; double ImporteCredito = 0; double ImporteEfectivo = 0; double ImportePrenda = 0; double ImporteCobranza = 0; double ImporteBanco = 0; double CodAutoVendido = -1; double CodAutoPartePago = -1; double ImporteAutoNegativo = 0; double ImporteSenia = 0; Clases.cVenta objVenta = new Clases.cVenta(); if (CodVenta != "") { Clases.cMovimiento objMov = new Clases.cMovimiento(); ImporteAutoNegativo = objMov.GetImporteAutoNegativoxCodVenta(Convert.ToInt32(CodVenta)); ImporteAutoNegativo = -1 * ImporteAutoNegativo; DataTable trdo = objVenta.GetVentaxCodigo(Convert.ToInt32(CodVenta)); if (trdo.Rows.Count > 0) { ImporteCredito = Convert.ToDouble(trdo.Rows[0]["ImporteCredito"].ToString()); ImporteEfectivo = Convert.ToDouble(trdo.Rows[0]["ImporteEfectivo"].ToString()); ImportePrenda = Convert.ToDouble(trdo.Rows[0]["ImportePrenda"].ToString()); ImporteCobranza = Convert.ToDouble(trdo.Rows[0]["ImporteCobranza"].ToString()); if (trdo.Rows[0]["PrecioSenia"].ToString() != "") { ImporteSenia = Convert.ToDouble(trdo.Rows[0]["PrecioSenia"].ToString()); } ImporteEfectivo = ImporteEfectivo + ImporteSenia; if (trdo.Rows[0]["CodAutoVendido"].ToString() != "") { CodAutoVendido = Convert.ToInt32(trdo.Rows[0]["CodAutoVendido"].ToString()); } if (trdo.Rows[0]["CodAutoPartePago"].ToString() != "") { CodAutoPartePago = Convert.ToInt32(trdo.Rows[0]["CodAutoPartePago"].ToString()); } if (trdo.Rows[0]["ImporteAutoPartePago"].ToString() != "") { ImporteAutoPartePago = Convert.ToDouble(trdo.Rows[0]["ImporteAutoPartePago"].ToString()); } if (trdo.Rows[0]["ImporteBanco"].ToString() != "") { ImporteBanco = Convert.ToDouble(trdo.Rows[0]["ImporteBanco"].ToString()); } } //importe total del credito en documentos usado mas abajo double ImporteTotalDocumento = 0; Clases.cCuota objCuotas = new Clases.cCuota(); ImporteTotalDocumento = objCuotas.GetSaldoDeudaCuotas(Convert.ToInt32(CodVenta)); SqlConnection con = new SqlConnection(); con.ConnectionString = Clases.cConexion.Cadenacon(); con.Open(); SqlTransaction Transaccion; Transaccion = con.BeginTransaction(); SqlCommand Comand = new SqlCommand(); Comand.Connection = con; Comand.Transaction = Transaccion; try { //vuelvo el auto al stock //string sql = "insert into StockAuto(CodAuto,FechaAlta,CodUsuario)"; //sql = sql + " values(" + CodAutoVendido.ToString(); //sql = sql + "," + "'" + DateTime.Now.ToShortDateString() + "'"; //sql = sql + "," + Principal.CodUsuarioLogueado; //sql = sql + ")"; string sql = "update StockAuto set FechaBaja = null"; sql = sql + " where CodStock="; sql = sql + " (select max(CodStock) from StockAuto sa "; sql = sql + " where sa.CodAuto =" + CodAutoVendido.ToString(); sql = sql + ")"; Comand.CommandText = sql; Comand.ExecuteNonQuery(); //si pago con un auto le doy de baja if (CodAutoPartePago > 0) { SqlCommand Comand2 = new SqlCommand(); Comand2.Connection = con; Comand2.Transaction = Transaccion; string sqlStock = "update StockAuto"; sqlStock = sqlStock + " set FechaBaja =" + "'" + DateTime.Now.ToShortDateString() + "'"; sqlStock = sqlStock + " where CodAuto =" + CodAutoPartePago; Comand2.CommandText = sqlStock; Comand2.ExecuteNonQuery(); } //borro la venta string sql3 = "delete from venta where CodVenta=" + CodVenta.ToString(); SqlCommand Comand3 = new SqlCommand(); Comand3.Connection = con; Comand3.Transaction = Transaccion; Comand3.CommandText = sql3; Comand3.ExecuteNonQuery(); //borro las cuotas string sql4 = "delete from cuotas where CodVenta=" + CodVenta.ToString(); SqlCommand Comand4 = new SqlCommand(); Comand4.Connection = con; Comand4.Transaction = Transaccion; Comand4.CommandText = sql4; Comand4.ExecuteNonQuery(); //borro la prenda string sqlPrenda = "delete from Prenda where CodVenta=" + CodVenta.ToString(); SqlCommand ComandPrenda = new SqlCommand(); ComandPrenda.Connection = con; ComandPrenda.Transaction = Transaccion; ComandPrenda.CommandText = sqlPrenda; ComandPrenda.ExecuteNonQuery(); //borro los cheques string sqlCheque = "delete from Cheque where CodVenta=" + CodVenta.ToString(); SqlCommand ComandCheque = new SqlCommand(); ComandCheque.Connection = con; ComandCheque.Transaction = Transaccion; ComandCheque.CommandText = sqlCheque; ComandCheque.ExecuteNonQuery(); //si hubo un saldo de cobranza tb lo anulo //ya que significa que habia pagado una cobranza //y debo volver a sacar el efectivo cobrado //borro las cobranzas string sqlCobranza = "delete from Cobranza where CodVenta=" + CodVenta.ToString(); SqlCommand ComandCobranza = new SqlCommand(); ComandCobranza.Connection = con; ComandCobranza.Transaction = Transaccion; ComandCobranza.CommandText = sqlCobranza; ComandCobranza.ExecuteNonQuery(); //borro las comisiones if (ImportePagadoCobranza > 0) { //vuelvo el efectivo atraz ImporteEfectivo = ImporteEfectivo + ImportePagadoCobranza; // } if (ImportePagadoCuotas > 0) { ImporteEfectivo = ImporteEfectivo + ImportePagadoCuotas; } if (ImportePagadoPrenda > 0) { ImporteEfectivo = ImporteEfectivo + ImportePagadoPrenda; } if (ImportePagadoCheque > 0) { ImporteEfectivo = ImporteEfectivo + ImportePagadoCheque; } string sqlComision = "delete from ComisionVendedor where CodVenta=" + CodVenta.ToString(); SqlCommand ComandComision = new SqlCommand(); ComandComision.Connection = con; ComandComision.Transaction = Transaccion; ComandComision.CommandText = sqlComision; ComandComision.ExecuteNonQuery(); //Inserto el movimiento con los valores opuesto ImporteCredito = ImporteCredito * (-1); ImporteTotalDocumento = ImporteTotalDocumento * (-1); ImporteEfectivo = ImporteEfectivo * (-1); ImportePrenda = ImportePrenda * (-1); ImporteCobranza = ImporteCobranza * (-1); ImporteBanco = ImporteBanco * (-1); ImporteAutoPartePago = (-1) * ImporteAutoPartePago; string Descrip = "ANULACION VENTA " + Patente.ToString(); string sql5 = "Insert into Movimiento(ImporteDocumento,ImporteEfectivo"; sql5 = sql5 + ",ImportePrenda,ImporteCobranza,CodUsuario,Fecha,ImporteAuto,ImporteBanco,Descripcion)"; sql5 = sql5 + "Values(" + ImporteTotalDocumento.ToString().Replace(",", "."); sql5 = sql5 + "," + ImporteEfectivo.ToString().Replace(",", "."); sql5 = sql5 + "," + ImportePrenda.ToString().Replace(",", "."); sql5 = sql5 + "," + ImporteCobranza.ToString().Replace(",", "."); sql5 = sql5 + "," + Principal.CodUsuarioLogueado.ToString(); sql5 = sql5 + "," + "'" + DateTime.Now.ToShortDateString() + "'"; sql5 = sql5 + "," + ImporteAutoPartePago.ToString().Replace(",", "."); sql5 = sql5 + "," + ImporteBanco.ToString().Replace(",", "."); sql5 = sql5 + "," + "'" + Descrip + "'"; sql5 = sql5 + ")"; //finalmente inserto el movimiento opuesto //para que vuelva el valor de la cuenta vehiculo SqlCommand Comand5 = new SqlCommand(); Comand5.Connection = con; Comand5.Transaction = Transaccion; Comand5.CommandText = sql5; Comand5.ExecuteNonQuery(); string sql5b = "Insert into Movimiento(ImporteDocumento,ImporteEfectivo"; sql5b = sql5b + ",ImportePrenda,ImporteCobranza,CodUsuario,Fecha,ImporteAuto,ImporteBanco)"; sql5b = sql5b + "Values(" + ImporteTotalDocumento.ToString().Replace(",", "."); sql5b = sql5b + ",0"; sql5b = sql5b + ",0"; sql5b = sql5b + ",0"; sql5b = sql5b + "," + Principal.CodUsuarioLogueado.ToString(); sql5b = sql5b + "," + "'" + DateTime.Now.ToShortDateString() + "'"; sql5b = sql5b + "," + ImporteAutoNegativo.ToString().Replace(",", "."); sql5b = sql5b + ",0"; sql5b = sql5b + ")"; //finalmente inserto el movimiento opuesto del auto //para que vuelva el valor de la cuenta vehiculo SqlCommand Comand5b = new SqlCommand(); Comand5b.Connection = con; Comand5b.Transaction = Transaccion; Comand5b.CommandText = sql5b; Comand5b.ExecuteNonQuery(); string sql6 = "delete from VentasxAuto where CodVenta =" + CodVenta.ToString(); SqlCommand Comand6 = new SqlCommand(); Comand6.Connection = con; Comand6.Transaction = Transaccion; Comand6.CommandText = sql6; Comand6.ExecuteNonQuery(); string sql7 = "delete from GastosPagar where CodVenta =" + CodVenta.ToString(); SqlCommand Comand7 = new SqlCommand(); Comand7.Connection = con; Comand7.Transaction = Transaccion; Comand7.CommandText = sql7; Comand7.ExecuteNonQuery(); // doy de baja los autos del stock que ingresaron // como parte de pago if (CodAutoPartePago1 > 0) { string sql8 = "update StockAuto set FechaBaja=" + "'" + DateTime.Now.ToShortDateString() + "'"; sql8 = sql8 + " where CodAuto=" + CodAutoPartePago1.ToString(); SqlCommand Comand8 = new SqlCommand(); Comand8.Connection = con; Comand8.Transaction = Transaccion; Comand8.CommandText = sql8; Comand8.ExecuteNonQuery(); } Transaccion.Commit(); con.Close(); GetVentas(); MessageBox.Show("Venta anulada correctamente", Clases.cMensaje.Mensaje()); } catch (Exception ex) { Transaccion.Rollback(); MessageBox.Show("Hubo un error en el proceso de anulación de venta", Clases.cMensaje.Mensaje()); } } }
private void btnGrabar_Click(object sender, EventArgs e) { if (txtCuota.Text == "") { MessageBox.Show("Debe ingresar una cuota para continuar.", Clases.cMensaje.Mensaje()); return; } if (txtImportePagado.Text == "") { MessageBox.Show("Debe ingresar un monto de la cuota.", Clases.cMensaje.Mensaje()); return; } Clases.cFunciones fun = new Clases.cFunciones(); double Importe = fun.ToDouble(txtImporte.Text); double ImportePagado = fun.ToDouble(txtImportePagado.Text); double Saldo = fun.ToDouble(txtSaldo.Text); if (ImportePagado > Saldo) { MessageBox.Show("El importe pagado supera el saldo", Clases.cMensaje.Mensaje()); return; } Int32 CodUsuario = Principal.CodUsuarioLogueado; if (ImportePagado > Importe) { MessageBox.Show("El importe a abonar es superior al valor de la cuota", Clases.cMensaje.Mensaje()); return; } if (ImportePagado < Importe) { var result = MessageBox.Show("El importe abonado es inferior al valor de la cuota, Confirma Pago de la cuota?", Clases.cMensaje.Mensaje(), MessageBoxButtons.YesNo, MessageBoxIcon.Question); // If the no button was pressed ... if (result == DialogResult.No) { return; } } Double Punitorio = 0; if (txtPunitorio.Text != "") { Punitorio = fun.ToDouble(txtPunitorio.Text); } Int32 CodVenta = Convert.ToInt32(txtCodVenta.Text); Int32 Cuota = Convert.ToInt32(txtCuota.Text); DateTime FechaPago = Convert.ToDateTime(txtFecha.Text); Saldo = Importe - ImportePagado; Clases.cCuota objCuota = new Clases.cCuota(); if (objCuota.GrabarCuota(CodVenta, Cuota, FechaPago, ImportePagado, Saldo, CodUsuario, txtPatente.Text, Punitorio)) { MessageBox.Show("Cuota grabada correctamente.", Clases.cMensaje.Mensaje()); CargarPlandeCuotas(Convert.ToInt32(CodVenta)); txtTotalDeuda.Text = objCuota.GetSaldoDeudaCuotas(Convert.ToInt32(CodVenta)).ToString(); if (txtTotalDeuda.Text != "") { txtTotalDeuda.Text = fun.TransformarEntero(txtTotalDeuda.Text); txtTotalDeuda.Text = fun.FormatoEnteroMiles(txtTotalDeuda.Text); } LimpiarTextCuotas(); } else { MessageBox.Show("Hubo un error en el proceso de grabación.", Clases.cMensaje.Mensaje()); } }
private void GrillaCuotas_CellClick(object sender, DataGridViewCellEventArgs e) { string Cuota = GrillaCuotas.CurrentRow.Cells[1].Value.ToString(); string Importe = GrillaCuotas.CurrentRow.Cells[3].Value.ToString(); string ImportePagado = GrillaCuotas.CurrentRow.Cells[5].Value.ToString(); string Fecha = GrillaCuotas.CurrentRow.Cells[2].Value.ToString(); string CodVenta = GrillaCuotas.CurrentRow.Cells[0].Value.ToString(); string sSaldo = GrillaCuotas.CurrentRow.Cells[6].Value.ToString(); string FechaPago = GrillaCuotas.CurrentRow.Cells[4].Value.ToString(); GetPunitorio(Convert.ToInt32(CodVenta), Convert.ToInt32(Cuota)); Clases.cFunciones fun = new Clases.cFunciones(); if (Cuota != "") { txtCuota.Text = Cuota; txtImporte.Text = Importe; txtImportePagado.Text = ImportePagado; txtFecha.Text = Fecha; txtSaldo.Text = sSaldo.ToString(); if (txtImporte.Text != "") { //string xx = trdo.Rows[0]["Importe"].ToString().Replace (",",".").ToString(); //txtImporte.Text = fun.TransformarEntero(Importe); txtImporte.Text = fun.FormatoEnteroMiles(txtImporte.Text); txtCodVenta.Text = CodVenta.ToString(); if (txtImportePagado.Text != "") { btnAnular.Enabled = true; txtImportePagado.ReadOnly = true; btnGrabar.Enabled = false; //txtImportePagado.Text = fun.TransformarEntero(txtImportePagado.Text); txtImportePagado.Text = fun.FormatoEnteroMiles(txtImportePagado.Text); txtSaldo.Text = (fun.ToDouble(txtImporte.Text) - fun.ToDouble(txtImportePagado.Text)).ToString(); } else { btnAnular.Enabled = false; btnGrabar.Enabled = true; txtImportePagado.ReadOnly = false; } } //obtengo la deuda total Clases.cCuota objCuota = new Clases.cCuota(); txtTotalDeuda.Text = objCuota.GetSaldoDeudaCuotas(Convert.ToInt32(CodVenta)).ToString(); if (txtTotalDeuda.Text != "") { txtTotalDeuda.Text = fun.TransformarEntero(txtTotalDeuda.Text); txtTotalDeuda.Text = fun.FormatoEnteroMiles(txtTotalDeuda.Text); } } int ban = 0; if (txtSaldo.Text != "0") { if (txtSaldo.Text != "") { btnPagarSaldo.Visible = true; txtImportePagado.ReadOnly = false; ban = 1; } } if (ban == 0) { txtImportePagado.ReadOnly = true; btnPagarSaldo.Visible = false; } if (FechaPago != "") { btnPagarSaldo.Visible = true; } else { btnPagarSaldo.Visible = false; } }