public static List <Producto> GetProductoListForSearch(string whereSql) { if (string.IsNullOrEmpty(whereSql)) { whereSql = "1 = 1"; } List <Producto> theList = new List <Producto>(); Producto theUser = null; ProductoTableAdapter theAdapter = new ProductoTableAdapter(); try { ProductoDS.ProductoDataTable table = theAdapter.GetProductoForSearch(whereSql); if (table != null && table.Rows.Count > 0) { foreach (ProductoDS.ProductoRow row in table.Rows) { theUser = FillProdutowithImagenRecord(row); theList.Add(theUser); } } } catch (Exception q) { log.Error("el error ocurrio mientras obtenia la lista de los productos de la base de datos", q); return(null); } return(theList); }
public static Producto GetProductoById(int Idprocuto) { ProductoTableAdapter localAdapter = new ProductoTableAdapter(); if (Idprocuto <= 0) { return(null); } Producto theUser = null; try { ProductoDS.ProductoDataTable table = localAdapter.GetProductoById(Idprocuto); if (table != null && table.Rows.Count > 0) { ProductoDS.ProductoRow row = table[0]; theUser = FillProdutowithImagenRecord(row); } } catch (Exception q) { log.Error("Un error ocurrio mientras obtenia el modulo de la base de dato", q); return(null); } return(theUser); }
public static List <Producto> GetListaProducto() { List <Producto> theList = new List <Producto>(); Producto theData = null; try { ProductoDSTableAdapters.ProductoTableAdapter localAdapter = new ProductoDSTableAdapters.ProductoTableAdapter(); ProductoDS.ProductoDataTable table = localAdapter.GetListaProductos(); if (table != null && table.Rows.Count > 0) { foreach (var row in table) { theData = FillReccord(row); theList.Add(theData); } } } catch (Exception q) { throw new ArgumentException(q.Message, q); } return(theList); }
public static List <Producto> GetProductos() { ProductoDSTableAdapters.ProductoTableAdapter adapter = new ProductoDSTableAdapters.ProductoTableAdapter(); ProductoDS.ProductoDataTable table = adapter.GetProductos(); List <Producto> list = new List <Producto>(); foreach (var row in table) { Producto obj = GetProductoFromRow(row); list.Add(obj); } return(list); }
public static Producto GetProductoById(int productoId) { if (productoId <= 0) { throw new ArgumentException("El productoId no puede ser menor o igual que cero"); } ProductoDSTableAdapters.ProductoTableAdapter adapter = new ProductoDSTableAdapters.ProductoTableAdapter(); ProductoDS.ProductoDataTable table = adapter.GetProductoById(productoId); if (table == null || table.Rows.Count != 1) { throw new Exception("La table obtenida no tiene el numero correcto de filas"); } Producto obj = GetProductoFromRow(table[0]); return(obj); }
//------------------------------------------paginacion----------------------------------------------------- public static int SearchProductoPaginacion(ref List <Producto> articulos, string where, int pageSize, int firstRow, string ordenar) { try { int?totalRows = 0; ProductoTableAdapter localAdapter = new ProductoTableAdapter(); ProductoDS.ProductoDataTable theTable = localAdapter.GetSearchForProducto(where, pageSize, firstRow, ref totalRows, ordenar); if (theTable != null && theTable.Rows.Count > 0) { foreach (ProductoDS.ProductoRow row in theTable.Rows) { articulos.Add(FillProdutowithImagenRecord(row)); } } return((int)totalRows); } catch (Exception ex) { throw ex; } }
public static Producto GetProductoById(int ProductoId) { Producto theData = null; try { ProductoDSTableAdapters.ProductoTableAdapter localAdapter = new ProductoDSTableAdapters.ProductoTableAdapter(); ProductoDS.ProductoDataTable table = localAdapter.GetProductoById(ProductoId); if (table != null && table.Rows.Count > 0) { ProductoDS.ProductoRow row = table[0]; theData = FillReccord(row); } } catch (Exception q) { throw new ArgumentException(q.Message, q); } return(theData); }