Example #1
0
        public bool Insertar(BE_TES_LETRAS e_Letras, List <BE_TES_LETRASDET> l_LetrasDetalle, List <BE_TES_LETRASDOC> l_LetraDocumentos)
        {
            bool             b_Result   = false;
            DatosMySql       xMiFuncion = new DatosMySql();
            MySqlTransaction trans      = null;
            int n_row = 0;

            trans = mysConec.BeginTransaction();
            xMiFuncion.ReAbrirConeccion(mysConec);
            try
            {
                if (xMiFuncion.StoreEjecutar("tes_letras_insertar", e_Letras, mysConec, 4) == true)
                {
                    int n_idgenerado = Convert.ToInt32(xMiFuncion.intIdGenerado);

                    // GRABAMOS EL DETALLE DE LAS LETRAS
                    for (n_row = 0; n_row <= l_LetrasDetalle.Count - 1; n_row++)
                    {
                        BE_TES_LETRASDET e_letdet = new BE_TES_LETRASDET();
                        l_LetrasDetalle[n_row].n_idlet = n_idgenerado;
                        e_letdet = l_LetrasDetalle[n_row];
                        if (xMiFuncion.StoreEjecutar("tes_letrasdet_insertar", e_letdet, mysConec, 1) == false)
                        {
                            // SI SUCEDE UN ERROR DEVOLVEMOS FALSO
                            b_OcurrioError = xMiFuncion.booOcurrioError;
                            c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                            n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                            trans.Rollback();
                            return(b_Result);
                        }

                        int n_fil = 0;
                        for (n_fil = 0; n_fil <= l_diario.Count - 1; n_fil++)
                        {
                            if (l_diario[n_fil].c_orinumdoc == l_LetrasDetalle[n_row].c_numlet)
                            {
                                l_diario[n_fil].n_oriid = Convert.ToInt32(xMiFuncion.intIdGenerado);
                            }
                        }
                    }

                    // GRABAMOS LOS DOCUMENTOS RELACIONADOS A LAS LETRAS
                    for (n_row = 0; n_row <= l_LetraDocumentos.Count - 1; n_row++)
                    {
                        BE_TES_LETRASDOC e_letdoc = new BE_TES_LETRASDOC();

                        l_LetraDocumentos[n_row].n_idlet = n_idgenerado;
                        e_letdoc = l_LetraDocumentos[n_row];
                        if (xMiFuncion.StoreEjecutar("tes_letrasdoc_insertar", e_letdoc, mysConec, null) == false)
                        {
                            // SI SUCEDE UN ERROR DEVOLVEMOS FALSO
                            b_OcurrioError = xMiFuncion.booOcurrioError;
                            c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                            n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                            trans.Rollback();
                            return(b_Result);
                        }
                    }

                    // GRABAMOS EL DIARIO
                    for (n_row = 0; n_row <= l_diario.Count - 1; n_row++)
                    {
                        l_diario[n_row].n_oriid = Convert.ToInt32(n_idgenerado);
                        if (xMiFuncion.StoreEjecutar("con_diario_insertar", l_diario[n_row], mysConec, 0) == false)
                        {
                            b_OcurrioError = xMiFuncion.booOcurrioError;
                            c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                            n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                            trans.Rollback();
                            return(b_Result);
                        }
                    }
                }
                else
                {
                    b_OcurrioError = xMiFuncion.booOcurrioError;
                    c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                    n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                    trans.Rollback();
                    return(b_Result);
                }

                b_Result = true;
                trans.Commit();
                return(b_Result);
            }
            catch (Exception exc)
            {
                // SI SUCEDE UN ERROR DEVOLVEMOS FALSO
                b_OcurrioError = xMiFuncion.booOcurrioError;
                c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                trans.Rollback();
                return(b_Result);
            }
        }
Example #2
0
        public bool Actualizar(BE_TES_LETRAS e_Letras, List <BE_TES_LETRASDET> l_LetrasDetalle, List <BE_TES_LETRASDOC> l_LetraDocumentos)
        {
            bool             b_Result   = false;
            int              n_row      = 0;
            DatosMySql       xMiFuncion = new DatosMySql();
            MySqlTransaction trans      = null;

            trans = mysConec.BeginTransaction();
            xMiFuncion.ReAbrirConeccion(mysConec);
            try
            {
                string[,] arrParametros = new string[1, 3] {
                    { "n_idlet", "System.INT64", e_Letras.n_id.ToString() }
                };

                // ELIMINAMOS LOS LETRAS GENERADAS
                if (xMiFuncion.StoreEjecutar("tes_letrasdet_delete", arrParametros, mysConec) == false)
                {
                    b_OcurrioError = xMiFuncion.booOcurrioError;
                    c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                    n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                    trans.Rollback();
                    return(b_Result);
                }

                // ELIMINAMOS LOS DOCUMENTO CARGADOS
                if (xMiFuncion.StoreEjecutar("tes_letrasdoc_delete", arrParametros, mysConec) == false)
                {
                    b_OcurrioError = xMiFuncion.booOcurrioError;
                    c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                    n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                    trans.Rollback();
                    return(b_Result);
                }

                if (xMiFuncion.StoreEjecutar("tes_letras_actualizar", e_Letras, mysConec, null) == true)
                {
                    int n_id = Convert.ToInt32(e_Letras.n_id);
                    // GRABAMOS EL DETALLE DE LAS LETRAS
                    for (n_row = 0; n_row <= l_LetrasDetalle.Count - 1; n_row++)
                    {
                        BE_TES_LETRASDET e_letdet = new BE_TES_LETRASDET();
                        l_LetrasDetalle[n_row].n_idlet = n_id;
                        e_letdet = l_LetrasDetalle[n_row];
                        if (xMiFuncion.StoreEjecutar("tes_letrasdet_insertar", e_letdet, mysConec, 1) == false)
                        {
                            // SI SUCEDE UN ERROR DEVOLVEMOS FALSO
                            b_OcurrioError = xMiFuncion.booOcurrioError;
                            c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                            n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                            trans.Rollback();
                            return(b_Result);
                        }
                    }

                    // GRABAMOS LOS DOCUMENTOS RELACIONADOS A LAS LETRAS
                    for (n_row = 0; n_row <= l_LetraDocumentos.Count - 1; n_row++)
                    {
                        BE_TES_LETRASDOC e_letdoc = new BE_TES_LETRASDOC();

                        l_LetraDocumentos[n_row].n_idlet = n_id;
                        e_letdoc = l_LetraDocumentos[n_row];
                        if (xMiFuncion.StoreEjecutar("tes_letrasdoc_insertar", e_letdoc, mysConec, null) == false)
                        {
                            // SI SUCEDE UN ERROR DEVOLVEMOS FALSO
                            b_OcurrioError = xMiFuncion.booOcurrioError;
                            c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                            n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                            trans.Rollback();
                            return(b_Result);
                        }
                    }
                    b_Result = true;
                }
                else
                {
                    b_OcurrioError = xMiFuncion.booOcurrioError;
                    c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                    n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                }

                b_Result = true;
                trans.Commit();
                return(b_Result);
            }
            catch (Exception exc)
            {
                // SI SUCEDE UN ERROR DEVOLVEMOS FALSO
                b_OcurrioError = xMiFuncion.booOcurrioError;
                c_ErrorMensaje = xMiFuncion.StrErrorMensaje;
                n_ErrorNumber  = xMiFuncion.IntErrorNumber;
                trans.Rollback();
                return(b_Result);
            }
        }
Example #3
0
        public void TraerRegistro(int n_IdRegistro)
        {
            DataTable     dtResult = new DataTable();
            CD_tes_letras miFun    = new CD_tes_letras();

            miFun.mysConec = mysConec;
            int n_row = 0;

            if (miFun.TraerRegistro(n_IdRegistro) == true)
            {
                dtListaDoc = miFun.dtLista4;
                dtResult   = miFun.dtLista1;

                e_Letras.n_idemp     = Convert.ToInt32(dtResult.Rows[0]["n_idemp"]);
                e_Letras.n_ano       = Convert.ToInt32(dtResult.Rows[0]["n_ano"]);
                e_Letras.n_mes       = Convert.ToInt32(dtResult.Rows[0]["n_mes"]);
                e_Letras.n_idlib     = Convert.ToInt32(dtResult.Rows[0]["n_idlib"]);
                e_Letras.n_id        = Convert.ToInt32(dtResult.Rows[0]["n_id"]);
                e_Letras.c_numreg    = dtResult.Rows[0]["c_numreg"].ToString();
                e_Letras.n_tiplet    = Convert.ToInt32(dtResult.Rows[0]["n_tiplet"]);
                e_Letras.d_fchreg    = Convert.ToDateTime(dtResult.Rows[0]["d_fchreg"]);
                e_Letras.d_fchini    = Convert.ToDateTime(dtResult.Rows[0]["d_fchini"]);
                e_Letras.n_idclipro  = Convert.ToInt32(dtResult.Rows[0]["n_idclipro"]);
                e_Letras.n_idmon     = Convert.ToInt32(dtResult.Rows[0]["n_idmon"]);
                e_Letras.n_numlet    = Convert.ToInt32(dtResult.Rows[0]["n_numlet"]);
                e_Letras.n_impcap    = Convert.ToDouble(dtResult.Rows[0]["n_impcap"]);
                e_Letras.n_idtipint  = Convert.ToInt32(dtResult.Rows[0]["n_idtipint"]);
                e_Letras.n_portas    = Convert.ToDouble(dtResult.Rows[0]["n_portas"]);
                e_Letras.c_glosa     = dtResult.Rows[0]["c_glosa"].ToString();
                e_Letras.n_numdiaint = Convert.ToInt32(dtResult.Rows[0]["n_numdiaint"]);
                e_Letras.n_numdiapla = Convert.ToInt32(dtResult.Rows[0]["n_numdiapla"]);
                e_Letras.n_tc        = Convert.ToDouble(dtResult.Rows[0]["n_tc"]);
                e_Letras.c_girnumdoc = dtResult.Rows[0]["c_girnumdoc"].ToString();
                e_Letras.c_girnom    = dtResult.Rows[0]["c_girnom"].ToString();
                e_Letras.c_girtel    = dtResult.Rows[0]["c_girtel"].ToString();
                e_Letras.c_girdir    = dtResult.Rows[0]["c_girdir"].ToString();
                e_Letras.n_imppor    = Convert.ToDouble(dtResult.Rows[0]["n_imppor"]);
                e_Letras.n_idban     = Convert.ToInt32(dtResult.Rows[0]["n_idban"]);
                e_Letras.n_idcueban  = Convert.ToInt32(dtResult.Rows[0]["n_idcueban"]);

                dtResult = miFun.dtLista2;

                for (n_row = 0; n_row <= dtResult.Rows.Count - 1; n_row++)
                {
                    BE_TES_LETRASDET e_det = new BE_TES_LETRASDET();

                    e_det.n_idlet = Convert.ToInt32(dtResult.Rows[n_row]["n_idlet"]);
                    //e_det.n_id = Convert.ToInt32(dtResult.Rows[n_row]["n_id"]);
                    e_det.c_numser = dtResult.Rows[n_row]["c_numser"].ToString();
                    e_det.c_numlet = dtResult.Rows[n_row]["c_numlet"].ToString();
                    e_det.d_fchemi = Convert.ToDateTime(dtResult.Rows[n_row]["d_fchemi"]);
                    e_det.d_fchven = Convert.ToDateTime(dtResult.Rows[n_row]["d_fchven"]);
                    e_det.n_impcap = Convert.ToDouble(dtResult.Rows[n_row]["n_impcap"]);
                    e_det.n_imppor = Convert.ToDouble(dtResult.Rows[n_row]["n_imppor"]);
                    e_det.n_impint = Convert.ToDouble(dtResult.Rows[n_row]["n_impint"]);
                    e_det.n_implet = Convert.ToDouble(dtResult.Rows[n_row]["n_implet"]);
                    e_det.n_diapla = Convert.ToInt32(dtResult.Rows[n_row]["n_diapla"]);
                    e_det.n_impsal = Convert.ToDouble(dtResult.Rows[n_row]["n_impsal"]);
                    e_det.c_imptex = dtResult.Rows[n_row]["c_imptex"].ToString();

                    l_LetDet.Add(e_det);
                }


                dtResult = miFun.dtLista3;

                for (n_row = 0; n_row <= dtResult.Rows.Count - 1; n_row++)
                {
                    BE_TES_LETRASDOC e_doc = new BE_TES_LETRASDOC();

                    e_doc.n_idlet  = Convert.ToInt32(dtResult.Rows[n_row]["n_idlet"]);
                    e_doc.n_iddoc  = Convert.ToInt32(dtResult.Rows[n_row]["n_iddoc"]);
                    e_doc.n_impfin = Convert.ToDouble(dtResult.Rows[n_row]["n_impfin"]);

                    l_LetDoc.Add(e_doc);
                }
            }
            else
            {
                b_OcurrioError = miFun.b_OcurrioError;
                c_ErrorMensaje = miFun.c_ErrorMensaje;
                n_ErrorNumber  = miFun.n_ErrorNumber;
            }

            return;
        }