Beispiel #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);
            }
        }
Beispiel #2
0
        public DataSet ProcesarCobranzaDetalle(CobranzaDetalleBE BE)
        {
            DataSet dsResult;

            try
            {
                cmd = db.GetStoredProcCommand("CobranzaDetalle_Mnt");
                db.AddInParameter(cmd, "OPCION", DbType.Int32, BE.OPCION);
                db.AddInParameter(cmd, "USUARIO", DbType.String, BE.USUARIO);
                db.AddInParameter(cmd, "IdCobranza", DbType.String, BE.IdCobranza);
                db.AddInParameter(cmd, "IdDocumento", DbType.String, BE.IdDocumento);
                db.AddInParameter(cmd, "cNumDoc", DbType.String, BE.cNumDoc);
                db.AddInParameter(cmd, "IdLote", DbType.String, BE.IdLote);
                db.AddInParameter(cmd, "cItem", DbType.String, BE.cItem);
                db.AddInParameter(cmd, "nVNominal", DbType.Decimal, BE.nvNominal);
                db.AddInParameter(cmd, "nvMontoCobrar", DbType.Decimal, BE.nvMontoCobrar);
                db.AddInParameter(cmd, "nSaldo", DbType.Decimal, BE.nSaldo);
                db.AddInParameter(cmd, "IdPagadora", DbType.String, BE.IdPagadora);
                db.AddInParameter(cmd, "IdSocio", DbType.String, BE.IdSocio);
                db.AddInParameter(cmd, "nCapital", DbType.Decimal, BE.nCapital);
                db.AddInParameter(cmd, "nIntereses", DbType.Decimal, BE.nIntereses);
                db.AddInParameter(cmd, "nGarantia", DbType.Decimal, BE.nGarantia);
                db.AddInParameter(cmd, "nDias", DbType.Int32, BE.nDias);
                db.AddInParameter(cmd, "cNumOpe", DbType.String, BE.cNumOpe);
                db.AddInParameter(cmd, "nvImporte", DbType.String, BE.nvImporte);
                if (BE.sdFechaOp != DateTime.MinValue)
                {
                    db.AddInParameter(cmd, "gFechaOp", DbType.DateTime, BE.sdFechaOp);
                }
                db.AddInParameter(cmd, "gSesionID", DbType.String, BE.gSesionID);
                db.AddInParameter(cmd, "gPlazaID", DbType.String, BE.gPlazaID);
                db.AddInParameter(cmd, "valorMonedaID", DbType.Int16, BE.valorMonedaID);
                db.AddInParameter(cmd, "socioBancoID", DbType.String, BE.socioBancoID);
                db.AddInParameter(cmd, "ctasBancariaID", DbType.String, BE.ctasBancariaID);
                db.AddInParameter(cmd, "DifCobrada", DbType.Decimal, BE.DifCobrada);
                db.AddInParameter(cmd, "DiasMora", DbType.Int32, BE.DiasMora);
                db.AddInParameter(cmd, "Interes", DbType.Decimal, BE.Interes);
                db.AddInParameter(cmd, "Garantia", DbType.Decimal, BE.Garantia);
                if (BE.sdVencimiento != DateTime.MinValue)
                {
                    db.AddInParameter(cmd, "sdVencimiento", DbType.DateTime, BE.sdVencimiento);
                }
                dsResult = db.ExecuteDataSet(cmd);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(dsResult);
        }
        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 bool GrabarCobranza()
        {
            bool bResult = false;

            try
            {
                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(false);
                }

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

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

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

                if (dsCobranza.Tables[0].Rows.Count > 0)
                {
                    CobranzaDetalleBE oCobranzaDetBE = new CobranzaDetalleBE()
                    {
                        USUARIO    = General.General.GetCodigoUsuario,
                        OPCION     = 3,
                        IdCobranza = dsCobranza.Tables[0].Rows[0]["IdCobranza"].ToString(),
                        sdFechaOp  = dtRegistro.Value,  //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  = dtRegistro.Value; //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);
                    }
                    bResult = true;
                }
            }
            catch (Exception ex)
            {
                bResult = false;
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(bResult);
        }
        private void CargarDatos()
        {
            try
            {
                DataSet    dsCobranza = new DataSet();
                CobranzaBE CobranzaBE = new CobranzaBE()
                {
                    OPCION     = 4,
                    USUARIO    = General.General.GetCodigoUsuario,
                    IdCobranza = txtIdCobranza.Text,
                };

                dsCobranza = CobranzaBL.ProcesarCobranza(CobranzaBE);

                if (dsCobranza.Tables[0].Rows.Count > 0)
                {
                    txtIdSocio.Text     = dsCobranza.Tables[0].Rows[0]["IdSocio"].ToString();
                    txtDescripcion.Text = dsCobranza.Tables[0].Rows[0]["IdSocio_Dsc"].ToString();
                    //dtRegistro.Value = Convert.ToDateTime(dsCobranza.Tables[0].Rows[0]["dtRegistro"].ToString());
                    dtRegistro.Value             = Convert.ToDateTime(dsCobranza.Tables[0].Rows[0]["dtValuta"].ToString());
                    cboIdMoneda_tt.SelectedValue = dsCobranza.Tables[0].Rows[0]["IdMoneda_tt"].ToString();
                    cboIdMoneda_tt_SelectedIndexChanged(new object(), new EventArgs());
                    txtnTotal.Text           = Convert.ToDecimal(dsCobranza.Tables[0].Rows[0]["nTotal"]).ToString("N2");
                    lblSaltoXAplicar.Text    = Convert.ToDecimal(dsCobranza.Tables[0].Rows[0]["nTotal"]).ToString("N2");
                    txtDatosAdicionales.Text = dsCobranza.Tables[0].Rows[0]["DatosAdicionales"].ToString();
                    lblDiferencia.Text       = (Convert.ToDecimal(dsCobranza.Tables[0].Rows[0]["nTotal"]) - Convert.ToDecimal(dsCobranza.Tables[0].Rows[0]["nTotal"])).ToString("N2");

                    if (dsCobranza.Tables[0].Rows[0]["Status"].ToString() == "C")
                    {
                        btnDepositosXAplicar.Enabled = false;
                        btnQuitarDepositos.Enabled   = false;
                        btnAgregarDet.Enabled        = false;
                        btnQuitarDet.Enabled         = false;
                        btnAceptar.Enabled           = false;
                    }

                    DataSet           dsDetaLote         = new DataSet();
                    CobranzaDetalleBE oCobranzaDetalleBE = new CobranzaDetalleBE()
                    {
                        OPCION     = 1,
                        USUARIO    = General.General.GetCodigoUsuario,
                        sdFechaOp  = General.General.gFechaOp,
                        gSesionID  = General.General.gSesionID,
                        gPlazaID   = General.General.gPlazaID,
                        IdCobranza = txtIdCobranza.Text,
                    };
                    dsDetaLote = CobranzaDetalleBL.ProcesarCobranzaDetalle(oCobranzaDetalleBE);
                    if (dsDetaLote.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < dsDetaLote.Tables[0].Rows.Count; i++)
                        {
                            CobranzaDetalleBE oCobranzadetBE = new CobranzaDetalleBE()
                            {
                                IdLote            = dsDetaLote.Tables[0].Rows[i]["IdLote"].ToString(),
                                IdDocumento       = dsDetaLote.Tables[0].Rows[i]["IdDocumento"].ToString(),
                                cItem             = dsDetaLote.Tables[0].Rows[i]["cItem"].ToString(),
                                IdSocio           = dsDetaLote.Tables[0].Rows[i]["IdSocio"].ToString(),
                                IdSocio_Dsc       = dsDetaLote.Tables[0].Rows[i]["IdSocio_Dsc"].ToString(),
                                vDocumento        = dsDetaLote.Tables[0].Rows[i]["vDocumento"].ToString(),
                                cNumDoc           = dsDetaLote.Tables[0].Rows[i]["cNumDoc"].ToString(),
                                nvNominal         = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nvNominal"].ToString()),
                                IdPagadora        = dsDetaLote.Tables[0].Rows[i]["IdPagadora"].ToString(),
                                IdPagadora_Dsc    = dsDetaLote.Tables[0].Rows[i]["IdPagadora_Dsc"].ToString(),
                                nvImporte         = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nvImporte"].ToString()),
                                nvNegociable      = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nvNegociable"].ToString()),
                                nvMontoCobrar     = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nvMontoCobrar"].ToString()),
                                sdRecepcion       = DateTime.Parse(dsDetaLote.Tables[0].Rows[i]["sdRecepcion"].ToString()),
                                sdVencimiento     = DateTime.Parse(dsDetaLote.Tables[0].Rows[i]["sdVencimiento"].ToString()),
                                nTazaActiva       = decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nTazaActiva"].ToString()),
                                nPorFondoGarantia = decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nPorFondoGarantia"].ToString()),
                                nDias             = Convert.ToInt32((DateTime.Parse(dsDetaLote.Tables[0].Rows[i]["sdVencimiento"].ToString()) - DateTime.Parse(dsDetaLote.Tables[0].Rows[i]["sdRecepcion"].ToString())).TotalDays),
                                DifCobrada        = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["DifCobrada"].ToString()),
                                DiasMora          = int.Parse(dsDetaLote.Tables[0].Rows[i]["DiasMora"].ToString()),
                                Interes           = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["Interes"].ToString()),
                                Garantia          = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["Garantia"].ToString()),
                            };
                            LstCobranzaDetalle.Add(oCobranzadetBE);
                        }
                        dgvDocumentos.DataSource = LstCobranzaDetalle;
                        TotalizarImporteDoc();
                    }

                    DataSet        dsCobranzaPago  = new DataSet();
                    CobranzaPagoBE oCobranzaPagoBE = new CobranzaPagoBE()
                    {
                        OPCION     = 1,
                        USUARIO    = General.General.GetCodigoUsuario,
                        IdCobranza = txtIdCobranza.Text,
                    };
                    dsCobranzaPago = new CobranzaPagoBL().ProcesarCobranzaPago(oCobranzaPagoBE);

                    foreach (DataRow row in dsCobranzaPago.Tables[0].Rows)
                    {
                        CobranzaPagoBE oEntity = new CobranzaPagoBE()
                        {
                            IdCobranza         = row["IdCobranza"].ToString(),
                            socioBancoID       = row["socioBancoID"].ToString(),
                            ctasBancariaID     = row["ctasBancariaID"].ToString(),
                            ctasBanNumCta      = row["ctasBanNumCta"].ToString(),
                            jImporte           = string.IsNullOrEmpty(row["jImporte"].ToString()) ? 0 : decimal.Parse(row["jImporte"].ToString()),
                            jSaldo             = string.IsNullOrEmpty(row["jSaldo"].ToString()) ? 0 : decimal.Parse(row["jSaldo"].ToString()),
                            nTotal             = string.IsNullOrEmpty(row["nTotal"].ToString()) ? 0 : decimal.Parse(row["nTotal"].ToString()),
                            IdOperacion_tt     = row["IdOperacion_tt"].ToString(),
                            IdOperacion_tt_Dsc = row["IdOperacion_tt_Dsc"].ToString(),
                            IdTipoAbono_tt     = row["IdTipoAbono_tt"].ToString(),
                            IdTipoAbono_tt_Dsc = row["IdTipoAbono_tt_Dsc"].ToString(),
                        };
                        LstCobranzaPago.Add(oEntity);
                        dgvDepositos.DataSource = LstCobranzaPago;
                    }

                    TotalizarDepositos();
                    TotalizarImporteDoc();
                }
                else
                {
                    MessageBox.Show("Este .... no Existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnAgregarDet_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(cboIdMoneda_tt.SelectedValue.ToString().Trim()))
                {
                    MessageBox.Show("Debe seleccionar una modena.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    cboIdMoneda_tt.Focus();
                    return;
                }

                frmCobranzaPagadoraDocumentos ofrmCobranzaPagadoraDocumentos = new frmCobranzaPagadoraDocumentos();
                ofrmCobranzaPagadoraDocumentos.Tipo          = "S";
                ofrmCobranzaPagadoraDocumentos.IdEntidad     = txtIdSocio.Text;
                ofrmCobranzaPagadoraDocumentos.NombreEntidad = txtDescripcion.Text;
                ofrmCobranzaPagadoraDocumentos.IdMoneda_tt   = cboIdMoneda_tt.SelectedValue.ToString();
                ofrmCobranzaPagadoraDocumentos.ShowDialog();

                DataSet dsDetaLote = new DataSet();
                foreach (var item in ofrmCobranzaPagadoraDocumentos.LstEntidadTmpLote)
                {
                    DetaLoteBE DetaLoteBE = new DetaLoteBE()
                    {
                        OPCION      = 5,
                        USUARIO     = General.General.GetCodigoUsuario,
                        IdSocio     = txtIdSocio.Text.Trim(),
                        IdPagadora  = "",
                        IdDocumento = item.CodDocumento,
                        cNumDoc     = item.NumDocumento,
                        IdMoneda_tt = cboIdMoneda_tt.SelectedValue.ToString(),
                        IdLote      = item.IdLote,
                        cItem       = item.cItem,
                    };
                    dsDetaLote = DetaLoteBL.ProcesarDetaLote(DetaLoteBE);

                    if (dsDetaLote.Tables[0].Rows.Count > 0)
                    {
                        CobranzaDetalleBE oCobranzaDetalleBE = new CobranzaDetalleBE()
                        {
                            IdLote            = dsDetaLote.Tables[0].Rows[0]["IdLote"].ToString(),
                            cItem             = dsDetaLote.Tables[0].Rows[0]["Item"].ToString(),
                            IdDocumento       = dsDetaLote.Tables[0].Rows[0]["IdDocumento"].ToString(),
                            IdPagadora        = dsDetaLote.Tables[0].Rows[0]["IdPagadora"].ToString(),
                            IdPagadora_Dsc    = dsDetaLote.Tables[0].Rows[0]["IdPagadora_Dsc"].ToString(),
                            vDocumento        = dsDetaLote.Tables[0].Rows[0]["vDocumento"].ToString(),
                            cNumDoc           = dsDetaLote.Tables[0].Rows[0]["cNumDoc"].ToString(),
                            sdRecepcion       = DateTime.Parse(dsDetaLote.Tables[0].Rows[0]["sdRecepcion"].ToString()),
                            nvNominal         = Decimal.Parse(dsDetaLote.Tables[0].Rows[0]["nvNominal"].ToString()),
                            nvNegociable      = Decimal.Parse(dsDetaLote.Tables[0].Rows[0]["nvNegociable"].ToString()),
                            nvMontoCobrar     = Decimal.Parse(dsDetaLote.Tables[0].Rows[0]["nvMontoCobrar"].ToString()),
                            nvImporte         = Decimal.Parse(dsDetaLote.Tables[0].Rows[0]["nvMontoCobrar"].ToString()),
                            sdVencimiento     = DateTime.Parse(dsDetaLote.Tables[0].Rows[0]["sdVencimiento"].ToString()),
                            nTazaActiva       = decimal.Parse(dsDetaLote.Tables[0].Rows[0]["nTazaActiva"].ToString()),
                            nPorFondoGarantia = decimal.Parse(dsDetaLote.Tables[0].Rows[0]["nPorFondoGarantia"].ToString()),
                            nDias             = Convert.ToInt32((DateTime.Parse(dsDetaLote.Tables[0].Rows[0]["sdVencimiento"].ToString()) - DateTime.Parse(dsDetaLote.Tables[0].Rows[0]["sdRecepcion"].ToString())).TotalDays),
                            DifCobrada        = 0,
                            DiasMora          = 0,
                            Interes           = 0,
                            Garantia          = decimal.Parse(dsDetaLote.Tables[0].Rows[0]["nFondoGarantia"].ToString()) * -1,
                        };

                        // Validar
                        bool IsVal = true;
                        foreach (var oCobranzaDet in LstCobranzaDetalle)
                        {
                            if (oCobranzaDet.IdPagadora == oCobranzaDetalleBE.IdPagadora && oCobranzaDet.IdDocumento == oCobranzaDetalleBE.IdDocumento && oCobranzaDet.cNumDoc == oCobranzaDetalleBE.cNumDoc)
                            {
                                IsVal = false;
                                MessageBox.Show("El documento " + oCobranzaDet.cNumDoc.Trim() + " ya existe, seleccione otro", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                break;
                            }
                        }
                        if (IsVal)
                        {
                            LstCobranzaDetalle.Add(oCobranzaDetalleBE);
                        }
                    }
                }
                dgvDocumentos.DataSource = LstCobranzaDetalle;

                Decimal AcnvImporte = 0;
                int     Index       = 0;
                foreach (DataGridViewRow row in dgvDocumentos.Rows)
                {
                    dgvDocumentos_CellEndEdit(new object(), new DataGridViewCellEventArgs(14, Index));
                    AcnvImporte += (Decimal)row.Cells["nvImporte"].Value;
                    Index       += 1;
                }
                txtTotalImp.Text = AcnvImporte.ToString("N2");
            }
            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);
            }
        }
Beispiel #10
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = 0;
            DataSet      ds           = new DataSet();

            try
            {
                if (dgvCobranza.RowCount > 0)
                {
                    if (dgvCobranza.CurrentRow.Cells["Status"].Value.ToString() != "A")
                    {
                        MessageBox.Show("Esta cobranza ya esta confirmada", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    General.General.ValidarTipoCambio();
                    dialogResult = MessageBox.Show("Seguro de confirmar la cobranza Nro. " + dgvCobranza.CurrentRow.Cells["IdCobranza"].Value.ToString().Trim(), "Confirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dialogResult == DialogResult.Yes)
                    {
                        //Confirma el detalle
                        string   IdCobranza  = dgvCobranza.CurrentRow.Cells["IdCobranza"].Value.ToString().Trim();
                        string   IdMoneda_tt = dgvCobranza.CurrentRow.Cells["IdMoneda_tt"].Value.ToString().Trim();
                        DateTime dtRegistro  = Convert.ToDateTime(dgvCobranza.CurrentRow.Cells["Fecha"].Value.ToString().Trim());
                        int      iMonedaID   = IdMoneda_tt == "00036" ? 1 : 2;

                        BindingList <CobranzaDetalleBE> LstCobranzaDetalle = new BindingList <CobranzaDetalleBE>();
                        DataSet           dsDetaLote         = new DataSet();
                        CobranzaDetalleBE oCobranzaDetalleBE = new CobranzaDetalleBE()
                        {
                            USUARIO    = General.General.GetCodigoUsuario,
                            OPCION     = 1,
                            IdCobranza = IdCobranza,
                            sdFechaOp  = General.General.gFechaOp
                        };
                        dsDetaLote = new CobranzaDetalleBL().ProcesarCobranzaDetalle(oCobranzaDetalleBE);
                        if (dsDetaLote.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < dsDetaLote.Tables[0].Rows.Count; i++)
                            {
                                CobranzaDetalleBE oCobranzadetBE = new CobranzaDetalleBE()
                                {
                                    IdLote       = dsDetaLote.Tables[0].Rows[i]["IdLote"].ToString(),
                                    cItem        = dsDetaLote.Tables[0].Rows[i]["cItem"].ToString(),
                                    IdDocumento  = dsDetaLote.Tables[0].Rows[i]["IdDocumento"].ToString(),
                                    IdSocio      = dsDetaLote.Tables[0].Rows[i]["IdSocio"].ToString(),
                                    IdSocio_Dsc  = dsDetaLote.Tables[0].Rows[i]["IdSocio_Dsc"].ToString(),
                                    vDocumento   = dsDetaLote.Tables[0].Rows[i]["vDocumento"].ToString(),
                                    cNumDoc      = dsDetaLote.Tables[0].Rows[i]["cNumDoc"].ToString(),
                                    nvNominal    = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nvNominal"].ToString()),
                                    nvNegociable = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nvNegociable"].ToString()),
                                    nvImporte    = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["nvImporte"].ToString()),
                                    DifCobrada   = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["DifCobrada"].ToString()),
                                    Interes      = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["Interes"].ToString()),
                                    Garantia     = Decimal.Parse(dsDetaLote.Tables[0].Rows[i]["Garantia"].ToString()),
                                };
                                LstCobranzaDetalle.Add(oCobranzadetBE);
                            }
                        }

                        CobranzaBE oCobranza = new CobranzaBE()
                        {
                            USUARIO    = General.General.GetCodigoUsuario,
                            OPCION     = 6,
                            IdCobranza = IdCobranza,
                            dtRegistro = General.General.gFechaOp,
                            dtValuta   = General.General.gFechaOp,
                            iMonedaID  = iMonedaID,
                            gPlazaID   = General.General.gPlazaID,
                            gSesionID  = General.General.gSesionID,
                            gFechaOp   = General.General.gFechaOp
                        };
                        bool bResult = CobranzaBL.ProcesarCobranza(oCobranza, LstCobranzaDetalle);
                        if (bResult)
                        {
                            //oCobranza = new CobranzaBE()
                            //{
                            //    USUARIO = General.General.GetCodigoUsuario,
                            //    OPCION = 12,
                            //    IdCobranza = IdCobranza,
                            //    dtRegistro = General.General.gFechaOp,
                            //    dtValuta = General.General.gFechaOp,
                            //    gPlazaID = General.General.gPlazaID,
                            //    gSesionID = General.General.gSesionID,
                            //    gFechaOp = General.General.gFechaOp
                            //};
                            //CobranzaBL.ProcesarCobranza(oCobranza);

                            MessageBox.Show("Se Proceso Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            //Impresion
                            DataSet dsCobranza = new DataSet();
                            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConexionStrDBEfideFactoring"].ConnectionString))
                            {
                                SqlCommand cmd1 = new SqlCommand("Rpt_CobranzaP_Cab", con);
                                cmd1.CommandType = CommandType.StoredProcedure;
                                cmd1.Parameters.AddWithValue("@IdCobranza", IdCobranza);
                                SqlDataAdapter daCab = new SqlDataAdapter(cmd1);
                                daCab.Fill(dsCobranza, "Rpt_CobranzaP_Cab");

                                SqlCommand cmd2 = new SqlCommand("Rpt_CobranzaP_Det", con);
                                cmd2.CommandType = CommandType.StoredProcedure;
                                cmd2.Parameters.AddWithValue("@IdCobranza", IdCobranza);
                                SqlDataAdapter daDet = new SqlDataAdapter(cmd2);
                                daDet.Fill(dsCobranza, "Rpt_CobranzaP_Det");

                                SqlCommand cmd3 = new SqlCommand("Rpt_CobranzaPago", con);
                                cmd3.CommandType = CommandType.StoredProcedure;
                                cmd3.Parameters.AddWithValue("@IdCobranza", IdCobranza);
                                SqlDataAdapter daDet2 = new SqlDataAdapter(cmd3);
                                daDet2.Fill(dsCobranza, "Rpt_CobranzaPago");

                                con.Close();
                            }

                            Crystal.crRptCobranzaPagadora    ocrLoteLiquidacion       = new Crystal.crRptCobranzaPagadora();
                            Reportes.frmVisorLoteLiquidacion ofrmVisorLoteLiquidacion = new Reportes.frmVisorLoteLiquidacion();
                            ofrmVisorLoteLiquidacion.crvVisorLoteLiq.ReportSource = ocrLoteLiquidacion;
                            ocrLoteLiquidacion.SetDataSource(dsCobranza);
                            ocrLoteLiquidacion.SetParameterValue("FechaCancelacion", dtRegistro);
                            ocrLoteLiquidacion.SetParameterValue("Usuario", General.General.GetUsuario);
                            ofrmVisorLoteLiquidacion.WindowState = FormWindowState.Maximized;
                            ofrmVisorLoteLiquidacion.ShowDialog();
                        }

                        //foreach (var item in LstCobranzaDetalle)
                        //{
                        //    item.USUARIO = General.General.GetCodigoUsuario;
                        //    item.OPCION = 5;
                        //    item.IdPagadora = item.IdPagadora;
                        //    item.IdSocio = item.IdSocio;
                        //    item.IdCobranza = IdCobranza;
                        //    item.nvImporte = item.nvImporte;
                        //    item.sdFechaOp = General.General.gFechaOp;
                        //    item.gSesionID = General.General.gSesionID;
                        //    item.gPlazaID = General.General.gPlazaID;
                        //    item.valorMonedaID = iMonedaID;
                        //    item.IdLote = item.IdLote;
                        //    item.cItem = item.cItem;
                        //    new CobranzaDetalleBL().ProcesarCobranzaDetalle(item);
                        //}
                        btnBuscar.PerformClick();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public DataSet ProcesarCobranzaDetalle(CobranzaDetalleBE BE)
 {
     return(CobranzaDetalleDA.ProcesarCobranzaDetalle(BE));
 }