Example #1
0
        protected ClsPLPOCollection ConsultarPLPODAL(string psCriterio)
        {
            //Declaración de variables
            DataSet ds = new DataSet();
            //Definición del adaptador
            SqlDataAdapter da = new SqlDataAdapter();
            //Definición de la coleccion
            ClsPLPOCollection pLPOCollection = new ClsPLPOCollection();
            ClsPLPO           pLPO;

            try
            {
                da.SelectCommand             = new SqlCommand(Procedimientos.sp_ConsPLPO, this.Conexion);
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                da.SelectCommand.Parameters.Add("@Criterio", SqlDbType.VarChar).Value = psCriterio;
                //Se llena el DataSet
                da.Fill(ds);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    int renglones = ds.Tables[0].Rows.Count;
                    int columnas  = ds.Tables[0].Columns.Count;
                    for (int contador = 0; contador < ds.Tables[0].Rows.Count; contador++) //Cada renglòn
                    {
                        pLPO       = new ClsPLPO();
                        pLPO.Plnty = ds.Tables[0].Rows[contador]["PLNTY"].ToString().Trim();
                        pLPO.Plnnr = ds.Tables[0].Rows[contador]["PLNNR"].ToString().Trim();
                        try
                        {
                            pLPO.Plnkn = int.Parse(ds.Tables[0].Rows[contador]["PLNKN"].ToString().Trim());
                        }
                        catch
                        {
                            pLPO.Plnkn = 0;
                        }
                        pLPO.Loekz = ds.Tables[0].Rows[contador]["LOEKZ"].ToString().Trim();
                        pLPO.Vornr = ds.Tables[0].Rows[contador]["VORNR"].ToString().Trim();
                        pLPO.Phflg = ds.Tables[0].Rows[contador]["PHFLG"].ToString().Trim();
                        pLPOCollection.Add(pLPO);
                    }
                }

                return(pLPOCollection);
            }
            catch (Exception ex)
            {
                //Regenerar la excepción pero ahora con un mensaje personalizado para el usuario
                throw new Exception(Errores.ConsultarRegistro + Errores.MensajeOriginal + ex.Message.ToString());
            }
            finally
            {
                //Cerrar la conexión
                this.Conexion.Close();
            }
        }
Example #2
0
        public ClsPLPOCollection ConsultarPLPOBAL(string psCriterio)
        {
            ClsPLPOCollection pLPOCollection = new ClsPLPOCollection();

            try
            {
                pLPOCollection = base.ConsultarPLPODAL(psCriterio);
                return(pLPOCollection);
            }
            catch
            {
                throw;
            }
        }