Пример #1
0
        private double GetSaldoCuotaxCodVenta(Int32 CodVenta)
        {
            Clases.cCuota cuota = new Clases.cCuota();
            double        Saldo = 0;

            Saldo = cuota.GetSaldoDeudaCuotas(CodVenta);
            return(Saldo);
        }
Пример #2
0
        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;
                }
            }
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
        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());
                }
            }
        }
Пример #5
0
        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;
            }
        }