Exemple #1
0
        public bool Actualizar(BE_VTA_PEDIDOCLI entPedido, List <BE_VTA_PEDIDOCLIDET> lstDetalle)
        {
            CD_vta_pedidocli miFun = new CD_vta_pedidocli();
            bool             booOk = false;

            miFun.mysConec = mysConec;
            booOk          = miFun.Actualizar(entPedido, lstDetalle);

            booOcurrioError = miFun.booOcurrioError;
            StrErrorMensaje = miFun.StrErrorMensaje;
            IntErrorNumber  = miFun.IntErrorNumber;

            return(booOk);
        }
Exemple #2
0
        public bool Actualizar(BE_VTA_PEDIDOCLI entCabecera, List <BE_VTA_PEDIDOCLIDET> lstDetalle)
        {
            bool             booOk      = false;
            int              intFila    = 0;
            DatosMySql       xMiFuncion = new DatosMySql();
            MySqlTransaction trans;

            DatosMySql FunMysql = new DatosMySql();

            mysConec = FunMysql.ReAbrirConeccion(mysConec);

            trans = mysConec.BeginTransaction();
            try
            {
                if (xMiFuncion.StoreEjecutar("vta_pedidocli_actualizar", entCabecera, mysConec, null) == true)
                {
                    string[,] arrParametros = new string[1, 3] {
                        { "n_idped", "System.INT64", entCabecera.n_id.ToString() }
                    };
                    // BORRAMOS EL DETALLE
                    if (xMiFuncion.StoreEjecutar("vta_pedidoclidet_delete", arrParametros, mysConec) == true)
                    {
                        // SI LOS ITEMS SE ELIMINARON CON EXITO INSERTAMOS LOS NUEVOS ITEMS
                        for (intFila = 0; intFila <= lstDetalle.Count - 1; intFila++)
                        {
                            lstDetalle[intFila].n_idped = Convert.ToInt32(entCabecera.n_id);
                            if (xMiFuncion.StoreEjecutar("vta_pedidoclidet_insertar", lstDetalle[intFila], mysConec, null) == true)
                            {
                                booOk = true;
                            }
                            else
                            {
                                // CONTROLAR EL ERROR
                                booOcurrioError = xMiFuncion.booOcurrioError;
                                StrErrorMensaje = xMiFuncion.StrErrorMensaje;
                                IntErrorNumber  = xMiFuncion.IntErrorNumber;
                                trans.Rollback();
                                booOk = false;
                                return(booOk);
                            }
                        }
                    }
                    else
                    {
                        // CONTROLAR EL ERROR
                        booOcurrioError = xMiFuncion.booOcurrioError;
                        StrErrorMensaje = xMiFuncion.StrErrorMensaje;
                        IntErrorNumber  = xMiFuncion.IntErrorNumber;
                        trans.Rollback();
                        booOk = false;
                        return(booOk);
                    }
                }
                else
                {
                    booOcurrioError = xMiFuncion.booOcurrioError;
                    StrErrorMensaje = xMiFuncion.StrErrorMensaje;
                    IntErrorNumber  = xMiFuncion.IntErrorNumber;
                    trans.Rollback();
                    booOk = false;
                    return(booOk);
                }
                trans.Commit();
                return(booOk);
            }
            catch (Exception exc)
            {
                // SI SUCEDE UN ERROR DEVOLVEMOS FALSO
                booOcurrioError = xMiFuncion.booOcurrioError;
                StrErrorMensaje = xMiFuncion.StrErrorMensaje;
                IntErrorNumber  = xMiFuncion.IntErrorNumber;
                trans.Rollback();
                return(booOk);
            }
        }
Exemple #3
0
        public bool Insertar(BE_VTA_PEDIDOCLI entCabecera, List <BE_VTA_PEDIDOCLIDET> lstDetalle)
        {
            bool             booOk      = false;
            int              intFila    = 0;
            DatosMySql       xMiFuncion = new DatosMySql();
            MySqlTransaction trans;

            DatosMySql FunMysql = new DatosMySql();

            mysConec = FunMysql.ReAbrirConeccion(mysConec);

            trans = mysConec.BeginTransaction();

            try
            {
                if (xMiFuncion.StoreEjecutar("vta_pedidocli_insertar", entCabecera, mysConec, 1) == true)
                {
                    for (intFila = 0; intFila <= lstDetalle.Count - 1; intFila++)
                    {
                        entCabecera.n_id            = Convert.ToInt32(xMiFuncion.intIdGenerado);
                        lstDetalle[intFila].n_idped = Convert.ToInt32(xMiFuncion.intIdGenerado);
                        if (xMiFuncion.StoreEjecutar("vta_pedidoclidet_insertar", lstDetalle[intFila], mysConec, null) == true)
                        {
                            booOk = true;
                        }
                        else
                        {
                            // CONTROLAR EL ERROR
                            booOcurrioError = xMiFuncion.booOcurrioError;
                            StrErrorMensaje = xMiFuncion.StrErrorMensaje;
                            IntErrorNumber  = xMiFuncion.IntErrorNumber;
                            trans.Rollback();
                            booOk = false;
                            return(booOk);
                        }
                    }
                }
                else
                {
                    booOcurrioError = xMiFuncion.booOcurrioError;
                    StrErrorMensaje = xMiFuncion.StrErrorMensaje;
                    IntErrorNumber  = xMiFuncion.IntErrorNumber;
                    trans.Rollback();
                    booOk = false;
                    return(booOk);
                }

                if (booOk == true)
                {
                    trans.Commit();
                }
                else
                {
                    trans.Rollback();
                }

                return(booOk);
            }
            catch (Exception exc)
            {
                // SI SUCEDE UN ERROR DEVOLVEMOS FALSO
                booOcurrioError = xMiFuncion.booOcurrioError;
                StrErrorMensaje = xMiFuncion.StrErrorMensaje;
                IntErrorNumber  = xMiFuncion.IntErrorNumber;
                //trans.Rollback();
                return(booOk);
            }
        }
Exemple #4
0
        public bool TraerRegistro(int n_IdRegistro)
        {
            bool             booresult = false;
            DataTable        dtCab     = new DataTable();
            DataTable        dtDet     = new DataTable();
            BE_VTA_PEDIDOCLI entreque  = new BE_VTA_PEDIDOCLI();

            CD_vta_pedidocli miFun = new CD_vta_pedidocli();

            miFun.mysConec = mysConec;
            lstPedDet.Clear();
            if (miFun.TraerRegistro(n_IdRegistro) == true)
            {
                dtCab = miFun.dtCabecera;
                dtDet = miFun.dtDetalle;

                entPedCab.n_idemp       = Convert.ToInt32(dtCab.Rows[0]["n_idemp"]);
                entPedCab.n_id          = Convert.ToInt32(dtCab.Rows[0]["n_id"]);
                entPedCab.n_anotra      = Convert.ToInt32(dtCab.Rows[0]["n_anotra"]);
                entPedCab.n_mestra      = Convert.ToInt32(dtCab.Rows[0]["n_mestra"]);
                entPedCab.n_idcli       = Convert.ToInt32(dtCab.Rows[0]["n_idcli"]);
                entPedCab.n_idpunven    = Convert.ToInt32(dtCab.Rows[0]["n_idpunven"]);
                entPedCab.n_idtipodoc   = Convert.ToInt32(dtCab.Rows[0]["n_idtipodoc"]);
                entPedCab.c_numser      = Convert.ToString(dtCab.Rows[0]["c_numser"]);
                entPedCab.c_numdoc      = Convert.ToString(dtCab.Rows[0]["c_numdoc"]);
                entPedCab.d_fchreg      = Convert.ToDateTime(dtCab.Rows[0]["d_fchreg"]);
                entPedCab.d_fchped      = Convert.ToDateTime(dtCab.Rows[0]["d_fchped"]);
                entPedCab.d_fchent      = Convert.ToDateTime(dtCab.Rows[0]["d_fchent"]);
                entPedCab.n_idconpag    = Convert.ToInt32(dtCab.Rows[0]["n_idconpag"]);
                entPedCab.n_idven       = Convert.ToInt32(dtCab.Rows[0]["n_idven"]);
                entPedCab.c_obs         = Convert.ToString(dtCab.Rows[0]["c_obs"]);
                entPedCab.n_pedidtipdoc = Convert.ToInt32(dtCab.Rows[0]["n_pedidtipdoc"]);
                entPedCab.c_pednumser   = Convert.ToString(dtCab.Rows[0]["c_pednumser"]);
                entPedCab.c_pednumdoc   = Convert.ToString(dtCab.Rows[0]["c_pednumdoc"]);
                entPedCab.n_impbru      = Convert.ToDouble(dtCab.Rows[0]["n_impbru"]);
                entPedCab.n_impigv      = Convert.ToDouble(dtCab.Rows[0]["n_impigv"]);
                entPedCab.n_imptot      = Convert.ToDouble(dtCab.Rows[0]["n_imptot"]);
                entPedCab.n_numite      = Convert.ToDouble(dtCab.Rows[0]["n_numite"]);
                entPedCab.n_mulent      = Convert.ToInt32(dtCab.Rows[0]["n_mulent"]);
                entPedCab.n_idestent    = Convert.ToInt32(dtCab.Rows[0]["n_idestent"]);
                entPedCab.n_idest       = Convert.ToInt32(dtCab.Rows[0]["n_idest"]);
                entPedCab.n_idmon       = Convert.ToInt32(xFun.NulosN(dtCab.Rows[0]["n_idmon"]));
                int n_row = 0;

                for (n_row = 0; n_row <= dtDet.Rows.Count - 1; n_row++)
                {
                    BE_VTA_PEDIDOCLIDET detped = new BE_VTA_PEDIDOCLIDET();

                    detped.n_idped     = Convert.ToInt32(dtDet.Rows[n_row]["n_idped"]);
                    detped.n_idite     = Convert.ToInt32(dtDet.Rows[n_row]["n_idite"]);
                    detped.n_idunimed  = Convert.ToInt32(dtDet.Rows[n_row]["n_idunimed"]);
                    detped.n_can       = Convert.ToDouble(dtDet.Rows[n_row]["n_can"]);
                    detped.n_impbru    = Convert.ToDouble(dtDet.Rows[n_row]["n_impbru"]);
                    detped.n_impigv    = Convert.ToDouble(dtDet.Rows[n_row]["n_impigv"]);
                    detped.n_imptot    = Convert.ToDouble(dtDet.Rows[n_row]["n_imptot"]);
                    detped.d_fchent    = Convert.ToDateTime(dtDet.Rows[n_row]["d_fchent"]);
                    detped.n_entregado = Convert.ToInt32(dtDet.Rows[n_row]["n_entregado"]);

                    lstPedDet.Add(detped);
                }
                booresult = true;
            }
            return(booresult);
        }