Example #1
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            //Definitivo
            try
            {
                foreach (DataGridViewRow row in dgvEnvioCargo.Rows)
                {
                    CobranzaDetalleBE CobranzaDetalleBE = new CobranzaDetalleBE()
                    {
                        OPCION      = 6,
                        USUARIO     = General.General.GetUsuario,
                        sdFechaOp   = General.General.gFechaOp,
                        IdCobranza  = row.Cells["IdCobranza"].Value.ToString(),
                        IdDocumento = row.Cells["IdDocumento"].Value.ToString(),
                        cNumDoc     = row.Cells["cNumDoc"].Value.ToString(),
                    };

                    CobranzaDetalleBL CobranzaDetalleBL = new CobranzaDetalleBL();
                    CobranzaDetalleBL.ProcesarCobranzaDetalle(CobranzaDetalleBE);
                }
                MessageBox.Show("Se Proceso Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnBuscar_Click(new object(), new EventArgs());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet           ds = new DataSet();
                CobranzaDetalleBL CobranzaDetalleBL = new CobranzaDetalleBL();
                CobranzaDetalleBE CobranzaDetalleBE = new CobranzaDetalleBE()
                {
                    OPCION        = 7,
                    USUARIO       = General.General.GetUsuario,
                    sdFechaOp     = General.General.gFechaOp,
                    sdVencimiento = dtFechaFiltro.Value
                };

                ds = CobranzaDetalleBL.ProcesarCobranzaDetalle(CobranzaDetalleBE);
                dgvCobranzaDetalle.DataSource = ds.Tables[0];
                lblRegistros.Text             = ds.Tables[0].Rows.Count.ToString() + " registro(s)";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                if (rdbFecha.Checked && dtFechaFilter.Text.Equals(string.Empty))
                {
                    MessageBox.Show("Debe ingresar una fecha", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    dtFechaFilter.Focus();
                    return;
                }

                if (rdbPagadora.Checked && txtIdPagadora.Text.Equals(string.Empty))
                {
                    MessageBox.Show("Seleccione una pagadora", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    btnBuscarPagadora.Focus();
                    return;
                }

                DataSet           ds = new DataSet();
                CobranzaDetalleBE CobranzaDetalleBE = new CobranzaDetalleBE()
                {
                    OPCION        = 9,
                    USUARIO       = General.General.GetUsuario,
                    sdVencimiento = rdbFecha.Checked ? dtFechaFilter.Value : DateTime.MinValue,
                    IdPagadora    = rdbPagadora.Checked ? txtIdPagadora.Text.Trim(): string.Empty
                };

                CobranzaDetalleBL CobranzaDetalleBL = new CobranzaDetalleBL();
                ds = CobranzaDetalleBL.ProcesarCobranzaDetalle(CobranzaDetalleBE);
                dgvDatos.DataSource = ds.Tables[0];
                lblRegistros.Text   = ds.Tables[0].Rows.Count.ToString() + " registro(s)";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void frmTituloValorProtestarVisor_Load(object sender, EventArgs e)
        {
            try
            {
                DataSet           ds = new DataSet();
                CobranzaDetalleBL CobranzaDetalleBL = new CobranzaDetalleBL();
                CobranzaDetalleBE CobranzaDetalleBE = new CobranzaDetalleBE()
                {
                    OPCION        = 7,
                    USUARIO       = General.General.GetUsuario,
                    sdFechaOp     = General.General.gFechaOp,
                    sdVencimiento = _dtFechaFiltro
                };

                ds = CobranzaDetalleBL.ProcesarCobranzaDetalle(CobranzaDetalleBE);
                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds.Tables[0]));
                reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                // Obtener la variable general de validación
                TableBaseBE oEntityTable = new TableBaseBE();
                oEntityTable.OPCION   = 1;
                oEntityTable.USUARIO  = General.General.GetUsuario;
                oEntityTable.Table_Id = "01175"; //Porcentaje Validacion Cobranzas
                DataSet ds = new TableBaseBL().ProcesarTableBase(oEntityTable);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    PrjLimiteVal = decimal.Parse(ds.Tables[0].Rows[0]["Table_Value"].ToString());
                }

                TotalizarDepositos();
                TotalizarImporteDoc();
                Decimal Total          = string.IsNullOrEmpty(lblSaltoXAplicar.Text) ? 0 : Convert.ToDecimal(lblSaltoXAplicar.Text);
                Decimal AcImporteTotal = string.IsNullOrEmpty(txtTotalImp.Text) ? 0 : Convert.ToDecimal(txtTotalImp.Text);

                //if (AcImporteTotal != Total)
                //{
                //    MessageBox.Show("La distribución del depósito debe ser igual que el importe del depósito", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                //    return;
                //}

                //Validacion, el monto a cancelar no debe ser menor igual del 90%
                Decimal AcnvImporte   = 0;
                Decimal AcMontoCobrar = 0;
                Decimal nMontoCobrar  = 0;
                Decimal nDifCobrada   = 0;

                bool IsError = false;
                foreach (DataGridViewRow row in dgvDocumentos.Rows)
                {
                    AcnvImporte   = AcnvImporte + (Decimal)row.Cells["nvImporte"].Value;
                    AcMontoCobrar = AcMontoCobrar + (Decimal)row.Cells["nvMontoCobrar"].Value;

                    nMontoCobrar = (Decimal)row.Cells["nvMontoCobrar"].Value;
                    nDifCobrada  = (Decimal)row.Cells["DifCobrada"].Value;
                    nDifCobrada  = Math.Abs(nDifCobrada);

                    //if (PrjLimiteVal > 0)
                    //{
                    //if (((AcnvImporte / AcMontoCobrar) * 100) < PrjLimiteVal)
                    //{
                    //    IsError = true;
                    //    break;
                    //}

                    // Modif 20190708
                    if (((nDifCobrada / nMontoCobrar) * 100) > PrjLimiteVal)
                    {
                        IsError = true;
                        break;
                    }
                    //}
                }

                if (IsError)
                {
                    MessageBox.Show("El importe a cancelar excede el " + PrjLimiteVal.ToString() + "% de lo permitido, por favor verifique.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    //MessageBox.Show("El importe a cancelar es mayor al 10% de lo permitido, por favor verifique.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }


                if (dtRegistro.Value == DateTime.MinValue)
                {
                    MessageBox.Show("Se debe ingresar una fecha", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                //Comentado por Rq. 20181012 para los previos se puede crear cobranzas con fecha futura pero al confirmar validar que la fecha sea igual al del día
                //if (dtRegistro.Value > DateTime.Now)
                //{
                //    MessageBox.Show("La fecha de cancelación no puede ser mayor a la fecha actual", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                //    return;
                //}

                CobranzaBE CobranzaBE = new CobranzaBE()
                {
                    USUARIO           = General.General.GetCodigoUsuario,
                    OPCION            = 2,
                    IdCobranza        = txtIdCobranza.Text,
                    dtValuta          = dtRegistro.Value,
                    dtRegistro        = General.General.gFechaOp,                                                                //dtRegistro.Value,
                    IdTipoCobranza_tt = "00056",                                                                                 //Cobranza por Socio
                    IdMoneda_tt       = cboIdMoneda_tt.SelectedValue.ToString(),
                    nTotal            = String.IsNullOrEmpty(txtTotalImp.Text.Trim()) ? 0 : Convert.ToDecimal(txtTotalImp.Text), //lblSaltoXAplicar
                    DatosAdicionales  = txtDatosAdicionales.Text,
                };

                DataSet dsCobranza = new DataSet();
                dsCobranza = CobranzaBL.ProcesarCobranza(CobranzaBE);

                if (dsCobranza.Tables[0].Rows.Count > 0)
                {
                    this.txtIdCobranza.Text = dsCobranza.Tables[0].Rows[0]["IdCobranza"].ToString();
                    CobranzaDetalleBE oCobranzaDetBE = new CobranzaDetalleBE()
                    {
                        USUARIO    = General.General.GetCodigoUsuario,
                        OPCION     = 3,
                        IdCobranza = dsCobranza.Tables[0].Rows[0]["IdCobranza"].ToString(),
                        sdFechaOp  = General.General.gFechaOp
                    };
                    CobranzaDetalleBL.ProcesarCobranzaDetalle(oCobranzaDetBE);

                    /* Documentos */
                    foreach (var item in LstCobranzaDetalle)
                    {
                        item.USUARIO    = General.General.GetCodigoUsuario;
                        item.OPCION     = 2;
                        item.IdSocio    = txtIdSocio.Text;
                        item.IdCobranza = dsCobranza.Tables[0].Rows[0]["IdCobranza"].ToString();
                        item.nvImporte  = item.nvImporte;
                        item.sdFechaOp  = General.General.gFechaOp;
                        item.IdLote     = item.IdLote;
                        item.cItem      = item.cItem;
                        CobranzaDetalleBL.ProcesarCobranzaDetalle(item);
                    }

                    /* Depositos */
                    CobranzaPagoBE CobranzaPagoBE = new CobranzaPagoBE()
                    {
                        USUARIO    = General.General.GetCodigoUsuario,
                        OPCION     = 3,
                        IdCobranza = dsCobranza.Tables[0].Rows[0]["IdCobranza"].ToString(),
                    };
                    new CobranzaPagoBL().ProcesarCobranzaPago(CobranzaPagoBE);

                    foreach (CobranzaPagoBE oEntity in LstCobranzaPago)
                    {
                        oEntity.USUARIO    = General.General.GetCodigoUsuario;
                        oEntity.OPCION     = 2;
                        oEntity.IdCobranza = dsCobranza.Tables[0].Rows[0]["IdCobranza"].ToString();
                        new CobranzaPagoBL().ProcesarCobranzaPago(oEntity);
                    }
                }

                this.btnImprimir.PerformClick();
                MessageBox.Show("Se Proceso Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }