Exemplo n.º 1
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtnImportOriginal.Text.Trim()))
                {
                    MessageBox.Show("Ingrese un importe", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (dtVencimiento.Value == DateTime.MinValue)
                {
                    MessageBox.Show("Ingrese una fecha", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                DetaLoteBE oEntity = new DetaLoteBE();
                oEntity.USUARIO       = General.General.GetUsuario;
                oEntity.OPCION        = 14;
                oEntity.IdLote        = _IdLote;
                oEntity.cItem         = _cItem;
                oEntity.sdVencimiento = dtVencimiento.Value;
                oEntity.nvNegociable  = Convert.ToDecimal(txtnImportOriginal.Text);
                new DetaLoteBL().ProcesarDetaLote(oEntity);
                MessageBox.Show("Se Proceso Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void frmMntLiquidacionLinea_Load(object sender, EventArgs e)
        {
            txtIdLote.Text = _IdLote;
            txtMoneda.Text = _Table_IdMonedaDsc;

            // Datos del Lote
            DataSet    dsDetaLote  = new DataSet();
            DetaLoteBE oDetaLoteBE = new DetaLoteBE()
            {
                OPCION  = 6,
                USUARIO = General.General.GetUsuario,
                IdLote  = _IdLote
            };

            dsDetaLote = DetaLoteBL.ProcesarDetaLote(oDetaLoteBE);

            if (dsDetaLote.Tables[0].Rows.Count > 0)
            {
                txtnvNominal.Text        = string.IsNullOrEmpty(dsDetaLote.Tables[0].Rows[0]["nvNominal"].ToString()) ? "0.00" : Convert.ToDecimal(dsDetaLote.Tables[0].Rows[0]["nvNominal"]).ToString("N2");
                txtnNotaCredito.Text     = string.IsNullOrEmpty(dsDetaLote.Tables[0].Rows[0]["nNotaCredito"].ToString()) ? "0.00" : Convert.ToDecimal(dsDetaLote.Tables[0].Rows[0]["nNotaCredito"]).ToString("N2");
                txtnvRetencion.Text      = string.IsNullOrEmpty(dsDetaLote.Tables[0].Rows[0]["nvRetencion"].ToString()) ? "0.00" : Convert.ToDecimal(dsDetaLote.Tables[0].Rows[0]["nvRetencion"]).ToString("N2");
                txtDescuento.Text        = string.IsNullOrEmpty(dsDetaLote.Tables[0].Rows[0]["Descuento"].ToString()) ? "0.00" : Convert.ToDecimal(dsDetaLote.Tables[0].Rows[0]["Descuento"]).ToString("N2");
                txtnvFondoGarantia.Text  = string.IsNullOrEmpty(dsDetaLote.Tables[0].Rows[0]["nvFondoGarantia"].ToString()) ? "0.00" : Convert.ToDecimal(dsDetaLote.Tables[0].Rows[0]["nvFondoGarantia"]).ToString("N2");
                txtnValorNegociable.Text = string.IsNullOrEmpty(dsDetaLote.Tables[0].Rows[0]["nValorNegociable"].ToString()) ? "0.00" : Convert.ToDecimal(dsDetaLote.Tables[0].Rows[0]["nValorNegociable"]).ToString("N2");
                txtInteresDescuento.Text = string.IsNullOrEmpty(dsDetaLote.Tables[0].Rows[0]["nInteresAdelantado"].ToString()) ? "0.00" : Convert.ToDecimal(dsDetaLote.Tables[0].Rows[0]["nInteresAdelantado"]).ToString("N2");
                txtnvImporteNeto.Text    = string.IsNullOrEmpty(dsDetaLote.Tables[0].Rows[0]["nvImporteNeto"].ToString()) ? "0.00" : Convert.ToDecimal(dsDetaLote.Tables[0].Rows[0]["nvImporteNeto"]).ToString("N2");
            }

            CargarDatos();
        }
        private void CargarDatos()
        {
            try
            {
                DataSet    dsDetaLote = new DataSet();
                DetaLoteBE DetaLoteBE = new DetaLoteBE()
                {
                    OPCION       = 7,
                    USUARIO      = General.General.GetCodigoUsuario,
                    IdPagadora   = _Tipo.Equals("P") ? txtIdEntidad.Text : string.Empty,
                    IdSocio      = _Tipo.Equals("S") ? txtIdEntidad.Text : string.Empty,
                    IdMoneda_tt  = _IdMoneda_tt,
                    dtRenovacion = Convert.ToDateTime(txtdtRenovacion.Text),
                    Tipo         = _Tipo
                };
                dsDetaLote = DetaLoteBL.ProcesarDetaLote(DetaLoteBE);

                if (dsDetaLote.Tables[0].Rows.Count > 0)
                {
                    dgvDocumentos.DataSource = dsDetaLote.Tables[0];
                }

                string dtRenova = "";
                string dtNow    = General.General.gFechaOp.ToString().Substring(0, 10);

                foreach (DataGridViewRow row in dgvDocumentos.Rows)
                {
                    dtRenova = row.Cells["Column3"].Value.ToString().Substring(0, 10);
                    if (DateTime.Parse(dtRenova.ToString()) >= DateTime.Parse(dtNow.ToString()))
                    {
                    }
                    else // Vencido
                    {
                        row.DefaultCellStyle.ForeColor = Color.FromName(General.General.GetColorAnulado);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void frmCobranzaPagadoraDocumentos_Load(object sender, EventArgs e)
        {
            txtIdEntidad.Text     = IdEntidad.Trim();
            txtNombreEntidad.Text = NombreEntidad.Trim();

            try
            {
                DataSet    dsDetaLote = new DataSet();
                DetaLoteBE DetaLoteBE = new DetaLoteBE()
                {
                    OPCION      = 13,
                    USUARIO     = General.General.GetCodigoUsuario,
                    IdPagadora  = Tipo.Equals("P")? txtIdEntidad.Text : string.Empty,
                    IdSocio     = Tipo.Equals("S")? txtIdEntidad.Text : string.Empty,
                    IdMoneda_tt = IdMoneda_tt
                };

                dsDetaLote = DetaLoteBL.ProcesarDetaLote(DetaLoteBE);

                if (dsDetaLote.Tables[0].Rows.Count > 0)
                {
                    dgvDocumentos.DataSource = dsDetaLote.Tables[0];
                }

                if (Tipo.Equals("P"))
                {
                    this.dgvDocumentos.Columns["IdPagadora_Dsc"].Visible = false;
                }
                else
                {
                    this.dgvDocumentos.Columns["Socio"].Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        public DataSet ProcesarDetaLote(DetaLoteBE BE)
        {
            DataSet dsResult;

            try
            {
                cmd = db.GetStoredProcCommand("DetaLote_Mnt");
                db.AddInParameter(cmd, "OPCION", DbType.Int32, BE.OPCION);
                db.AddInParameter(cmd, "USUARIO", DbType.String, BE.USUARIO);
                db.AddInParameter(cmd, "IdLote", DbType.String, BE.IdLote);
                db.AddInParameter(cmd, "cItem", DbType.String, BE.cItem);
                db.AddInParameter(cmd, "IdPagadora", DbType.String, BE.IdPagadora);
                db.AddInParameter(cmd, "IdDocumento", DbType.String, BE.IdDocumento);
                db.AddInParameter(cmd, "IdSocio_Beneficiario", DbType.String, BE.IdSocio_Beneficiario);
                db.AddInParameter(cmd, "IdSocio_BeneficiarioRuc", DbType.String, BE.IdSocio_BeneficiarioRuc);
                db.AddInParameter(cmd, "cNumDoc", DbType.String, BE.cNumDoc);
                if (BE.sdRecepcion != DateTime.MinValue)
                {
                    db.AddInParameter(cmd, "sdRecepcion", DbType.DateTime, BE.sdRecepcion);
                }
                db.AddInParameter(cmd, "iPlazo", DbType.Int32, BE.iPlazo);
                if (BE.sdVencimiento != DateTime.MinValue)
                {
                    db.AddInParameter(cmd, "sdVencimiento", DbType.DateTime, BE.sdVencimiento);
                }
                db.AddInParameter(cmd, "nvNominal", DbType.Decimal, BE.nvNominal);
                db.AddInParameter(cmd, "cNotaCredito", DbType.String, BE.cNotaCredito);
                db.AddInParameter(cmd, "nNotaCredito", DbType.Decimal, BE.nNotaCredito);
                db.AddInParameter(cmd, "nPorRetencion", DbType.Decimal, BE.nPorRetencion);
                db.AddInParameter(cmd, "nvRetencion", DbType.Decimal, BE.nvRetencion);
                db.AddInParameter(cmd, "Descuento", DbType.Decimal, BE.Descuento);
                db.AddInParameter(cmd, "IdSocio", DbType.String, BE.IdSocio);
                db.AddInParameter(cmd, "nvNegociable", DbType.Decimal, BE.nvNegociable);
                db.AddInParameter(cmd, "nTazaActiva", DbType.Decimal, BE.nTazaActiva);
                db.AddInParameter(cmd, "nFondoGarantia", DbType.Decimal, BE.nFondoGarantia);
                db.AddInParameter(cmd, "nTasaSobregiro", DbType.Decimal, BE.nTasaSobregiro);
                db.AddInParameter(cmd, "IdMoneda_tt", DbType.String, BE.IdMoneda_tt);
                if (BE.dtRenovacion != DateTime.MinValue)
                {
                    db.AddInParameter(cmd, "dtRenovacion", DbType.DateTime, BE.dtRenovacion);
                }
                if (BE.FlgEnvioCorreo != string.Empty)
                {
                    db.AddInParameter(cmd, "FlgEnvioCorreo", DbType.String, BE.FlgEnvioCorreo);
                }
                if (BE.dtEnvioCorreo != DateTime.MinValue)
                {
                    db.AddInParameter(cmd, "dtEnvioCorreo", DbType.DateTime, BE.dtEnvioCorreo);
                }
                if (BE.FlgConfirmadoPagadora != string.Empty)
                {
                    db.AddInParameter(cmd, "FlgConfirmadoPagadora", DbType.String, BE.FlgConfirmadoPagadora);
                }
                if (BE.dtConfirmadoPagadora != DateTime.MinValue)
                {
                    db.AddInParameter(cmd, "dtConfirmadoPagadora", DbType.DateTime, BE.dtConfirmadoPagadora);
                }
                if (BE.IdImageDoc != string.Empty)
                {
                    db.AddInParameter(cmd, "IdImageDoc", DbType.String, BE.IdImageDoc);
                }
                db.AddInParameter(cmd, "bNoRequiereProtesto", DbType.Boolean, BE.bNoRequiereProtesto);
                db.AddInParameter(cmd, "Tipo", DbType.String, BE.Tipo);
                dsResult = db.ExecuteDataSet(cmd);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(dsResult);
        }
        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
            {
                if (LstEntityFE.Count == 0)
                {
                    MessageBox.Show("No hay documentos para enviar a operaciones, por favor verifique.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                int  Index      = 0;
                bool IsProcesar = true;
                List <DetaLoteBE> LstDetaLote = new List <DetaLoteBE>();
                foreach (FEXMLBE oEntityFE in LstEntityFE)
                {
                    ImportacionLoteBE oEntity = new ImportacionLoteBE()
                    {
                        RucPagadora = oEntityFE.RUC,
                        IdSocio     = txtIdSocio.Text.Trim(),
                        IdLinea     = IdLinea,
                        IdDocumento = oEntityFE.IdDocumento,
                        IdMoneda_tt = IdMoneda_tt,
                        cNumDoc     = oEntityFE.cNumDoc
                    };
                    DataSet ds = new DataSet();
                    ds = new ImportacionLoteBL().ProcesarImportacionLote(oEntity);
                    if (!ds.Tables[0].Rows[0]["Result"].Equals("OK"))
                    {
                        IsProcesar = false;
                        LstEntityFE[Index].Mensaje = ds.Tables[0].Rows[0]["MsgResult"].ToString();
                        Index++;
                        continue;
                    }
                    else
                    {
                        if (oEntityFE.nvNegociable == 0)
                        {
                            LstEntityFE[Index].Mensaje = "El importe de pago no puede ser 0.";
                            IsProcesar = false;
                            Index++;
                            continue;
                        }

                        if (oEntityFE.sdVencimiento == DateTime.MinValue)
                        {
                            LstEntityFE[Index].Mensaje = "Ingresar la fecha de vencimiento válida.";
                            IsProcesar = false;
                            Index++;
                            continue;
                        }

                        if (oEntityFE.sdVencimiento <= GeneralXML.FechaOperacion)
                        {
                            LstEntityFE[Index].Mensaje = "Fecha de vencimiento no puede ser menor a la fecha de recepción.";
                            IsProcesar = false;
                            Index++;
                            continue;
                        }

                        LstEntityFE[Index].Mensaje = "OK";

                        TimeSpan   ts             = Convert.ToDateTime(oEntityFE.sdVencimiento) - GeneralXML.FechaOperacion;
                        DetaLoteBE oEntityDetLote = new DetaLoteBE();
                        oEntityDetLote.USUARIO                 = GeneralXML.CodUsuario;
                        oEntityDetLote.OPCION                  = 2;
                        oEntityDetLote.IdLote                  = string.Empty;
                        oEntityDetLote.cItem                   = "";
                        oEntityDetLote.IdPagadora              = oEntityFE.IdPagadora;
                        oEntityDetLote.IdDocumento             = oEntityFE.IdDocumento;
                        oEntityDetLote.cNumDoc                 = oEntityFE.cNumDoc;
                        oEntityDetLote.sdRecepcion             = GeneralXML.FechaOperacion;
                        oEntityDetLote.iPlazo                  = ts.Days;
                        oEntityDetLote.sdVencimiento           = Convert.ToDateTime(oEntityFE.sdVencimiento);
                        oEntityDetLote.nvNominal               = Convert.ToDecimal(oEntityFE.nvNegociable);
                        oEntityDetLote.cNotaCredito            = string.Empty;
                        oEntityDetLote.nNotaCredito            = 0;
                        oEntityDetLote.nPorRetencion           = 0;
                        oEntityDetLote.nvRetencion             = 0;
                        oEntityDetLote.Descuento               = 0;
                        oEntityDetLote.dtRenovacion            = DateTime.MinValue;
                        oEntityDetLote.IdSocio_Beneficiario    = string.Empty;                      //_IdSocio_Beneficiario;
                        oEntityDetLote.IdSocio_BeneficiarioRuc = oEntityFE.IdSocio_BeneficiarioRuc; //_IdSocio_BeneficiarioRuc;
                        LstDetaLote.Add(oEntityDetLote);

                        Index++;
                    }
                }

                if (IsProcesar)
                {
                    LoteBE LoteBE = new LoteBE()
                    {
                        USUARIO           = GeneralXML.CodUsuario,
                        OPCION            = 2,
                        IdLote            = string.Empty,
                        IdSocio           = txtIdSocio.Text,
                        sdDesembolso      = GeneralXML.FechaOperacion,
                        IdLinea           = IdLinea,
                        IdMoneda_tt       = IdMoneda_tt,
                        nImporte          = LstDetaLote.Sum(f => f.nvNominal),
                        sdAprobacion      = DateTime.MinValue,
                        nDesembolso       = 0,
                        IdOperacion_tt    = "00080", // Email*******
                        IdFormaDesembolso = IdFormaDesembolso,
                        jComunCuentaID    = string.Empty,
                        jImporteAho       = LstDetaLote.Sum(f => f.nvNominal)
                    };
                    string Result = new LoteBL().ProcesarLote(LoteBE, LstDetaLote);

                    if (!string.IsNullOrEmpty(Result))
                    {
                        DetaLoteBE oEntity = new DetaLoteBE();
                        oEntity.OPCION  = 11;
                        oEntity.USUARIO = GeneralXML.CodUsuario;
                        oEntity.IdLote  = Result;
                        oEntity.IdSocio_Beneficiario = txtCarpetaXML.Text.ToString();
                        oEntity.iPlazo = OrigenLote;
                        DataSet ds = new DetaLoteBL().ProcesarDetaLote(oEntity);

                        if (OrigenLote == 0)
                        {
                            DetaLoteBE oEntityCorrelativo = new DetaLoteBE();
                            oEntityCorrelativo.OPCION  = 12;
                            oEntityCorrelativo.USUARIO = GeneralXML.CodUsuario;
                            DataSet dsCorr = new DetaLoteBL().ProcesarDetaLote(oEntityCorrelativo);

                            string Directorio = ConfigurationManager.AppSettings["RutaDirectorioFEXML"].ToString() + txtCarpetaXML.Text.ToString() + "\\RM-IA-" + DateTime.Now.ToString("ddMMyyyy") + "-" + dsCorr.Tables[0].Rows[0]["Correlativo"].ToString() + "-FTPLA$OVM";
                            ExportToExcel(ds.Tables[0], Directorio, "Hoja1");
                        }

                        MessageBox.Show("Se Proceso Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        IdLinea     = string.Empty;
                        IdMoneda_tt = string.Empty;
                        txtIdSocio.Clear();
                        txtIdSocio_Dsc.Clear();
                        txtIdLinea_Dsc.Clear();
                        txtIdMoneda_tt_Dsc.Clear();
                        txtFecha.Clear();
                        txtIdTipoLinea_tt_Dsc.Clear();
                        txtCarpetaXML.Clear();
                        LstDetaLote             = new List <DetaLoteBE>();
                        LstEntityFE             = new List <FEXMLBE>();
                        dgvFEDetalle.DataSource = LstEntityFE.ToList();
                    }
                    else
                    {
                        MessageBox.Show("Ocurrio un error al procesar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                dgvFEDetalle.DataSource = LstEntityFE.ToList();
                GridFormating();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                if (cboIdMoneda_tt.SelectedIndex == 0)
                {
                    MessageBox.Show("Se debe seleccionar una Moneda", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (rdbPagadora.Checked == true && string.IsNullOrEmpty(txtIdPagadora.Text))
                {
                    MessageBox.Show("Debe seleccionar una Pagadora", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (rdbSocio.Checked == true && string.IsNullOrEmpty(txtIdSocio.Text))
                {
                    MessageBox.Show("Debe seleccionar un Socio", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                string dtRenova = dtRenovacion.Value.ToString().Substring(0, 10);
                string dtNow    = General.General.gFechaOp.ToString().Substring(0, 10);

                //if (DateTime.Parse(dtRenova.ToString()) < DateTime.Parse(dtNow.ToString()))
                //{
                //    MessageBox.Show("La fecha de Renovación no puede ser menor que el día actual", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                //    return;
                //}


                frmRenovacionDocAdd Ofrm = new frmRenovacionDocAdd();
                Ofrm._IdEntidad       = Tipo.Equals("P") ? txtIdPagadora.Text : txtIdSocio.Text;
                Ofrm._IdEntidad_Dsc   = Tipo.Equals("P") ? txtIdPagadora_Dsc.Text : txtIdSocio_Dsc.Text;
                Ofrm._IdMoneda_tt     = cboIdMoneda_tt.SelectedValue.ToString();
                Ofrm._IdMoneda_tt_Dsc = cboIdMoneda_tt.Text;
                Ofrm._dtRenovacion    = dtRenovacion.Text;
                Ofrm._Tipo            = Tipo;
                Ofrm.ShowDialog();


                DataSet ds = new DataSet();

                foreach (var item in Ofrm.LstEntidadTmpLote)
                {
                    DetaLoteBE DetaLoteBE = new DetaLoteBE()
                    {
                        OPCION       = 8,
                        USUARIO      = General.General.GetCodigoUsuario,
                        IdLote       = item.IdLote,
                        cItem        = item.cItem,
                        dtRenovacion = dtRenovacion.Value,
                        Tipo         = Tipo
                    };
                    ds = DetaLoteBL.ProcesarDetaLote(DetaLoteBE);

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            RenovacionDetBE oRenovacionBE = new RenovacionDetBE()
                            {
                                IdLote             = ds.Tables[0].Rows[i]["IdLote"].ToString(),
                                cItem              = ds.Tables[0].Rows[i]["cItem"].ToString(),
                                IdDocumento        = ds.Tables[0].Rows[i]["IdDocumento"].ToString(),
                                cNumDoc            = ds.Tables[0].Rows[i]["cNumDoc"].ToString(),
                                IdEntidad          = ds.Tables[0].Rows[i]["IdEntidad"].ToString(),
                                IdEntidad_Dsc      = ds.Tables[0].Rows[i]["IdEntidad_Dsc"].ToString(),
                                sdVencimiento      = !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["sdVencimiento"].ToString()) ? DateTime.Parse(ds.Tables[0].Rows[i]["sdVencimiento"].ToString()) : DateTime.MinValue,
                                iVencimiento       = !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["DiasVenc"].ToString()) ? int.Parse(ds.Tables[0].Rows[i]["DiasVenc"].ToString()) : 0,
                                nvNominal          = !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["nvNominal"].ToString()) ? Decimal.Parse(ds.Tables[0].Rows[i]["nvNominal"].ToString()) : 0,
                                nvNegociable       = !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["nvNegociable"].ToString()) ? Decimal.Parse(ds.Tables[0].Rows[i]["nvNegociable"].ToString()) : 0,
                                TEAOrigen          = !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["TEAOrigen"].ToString()) ? Decimal.Parse(ds.Tables[0].Rows[i]["TEAOrigen"].ToString()) : 0,
                                nPorTEA            = 18,
                                nGastosAdm         = 30,
                                nGastosReno        = 30,
                                iPlazoVencimientoN = 30,
                                sdVencimientoN     = dtRenovacion.Value.AddDays(30),
                                nFondoGarantia     = !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["nFondoGarantia"].ToString()) ? Decimal.Parse(ds.Tables[0].Rows[i]["nFondoGarantia"].ToString()) : 0,
                            };
                            //LstRenovacionDet.Add(oRenovacionBE);

                            // Validar
                            bool IsVal = true;
                            foreach (var oRenovacionDet in LstRenovacionDet)
                            {
                                if (oRenovacionDet.IdEntidad == oRenovacionBE.IdEntidad && oRenovacionDet.IdDocumento == oRenovacionBE.IdDocumento && oRenovacionDet.cNumDoc == oRenovacionBE.cNumDoc)
                                {
                                    IsVal = false;
                                    MessageBox.Show("El documento " + oRenovacionBE.cNumDoc.Trim() + " ya existe, seleccione otro", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                            }
                            if (IsVal)
                            {
                                LstRenovacionDet.Add(oRenovacionBE);
                            }
                        }
                    }

                    dgvRenovacionDet.DataSource = LstRenovacionDet;
                    foreach (DataGridViewRow row in dgvRenovacionDet.Rows)
                    {
                        dtRenova = row.Cells["sdVencimiento"].Value.ToString().Substring(0, 10);
                        if (DateTime.Parse(dtRenova.ToString()) >= DateTime.Parse(dtNow.ToString()))
                        {
                        }
                        else     // Vencido
                        {
                            row.DefaultCellStyle.ForeColor = Color.FromName(General.General.GetColorAnulado);
                        }
                    }

                    Totalizar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
 public DataSet ProcesarDetaLote(DetaLoteBE BE)
 {
     return(DetaLoteDA.ProcesarDetaLote(BE));
 }