public static List <AppOrder> getListaUser(int userId) { string sql = String.Format( $"select ao.\"idOrder\", ao.\"createDate\", pr.\"name\", au.\"fullname\", ad.\"address\"" + $" from \"AppOrder\" ao, \"Product\" pr, \"AppUser\" au, \"Address\" ad" + $" where ao.\"idProduct\"= pr.\"idProduct\" and ao.\"idAddress\" = ad.\"idAddress\"" + " and ad.\"idUser\"= au.\"idUser\"and au.\"idUser\"={0};", userId); DataTable dt = ConnectionBD.ExecuteQuery(sql); List <AppOrder> lista = new List <AppOrder>(); foreach (DataRow row in dt.Rows) { AppOrder o = new AppOrder(); o.idOrder = Convert.ToInt32(row[0].ToString()); o.createDate = DateTime.Parse(row[1].ToString()); o.idAddress = Convert.ToInt32(row[2].ToString()); o.idProduct = Convert.ToInt32(row[3].ToString()); lista.Add(o); } return(lista); }
public static List <AppOrder> getListaAppOrder(string iduser) { string sql = String.Format( "SELECT ao.idorder, ao.createdate, pr.name, au.fullname, ad.address " + "FROM APPORDER ao, ADRESS ad, PRODUCT pr, APPUSER au " + $"WHERE ao.idproduct =pr.idproduct " + $"AND ao.idadress =ad.idadress " + $"AND ad.iduser =au.iduser " + $"AND au.iduser ='******'; ", iduser); DataTable dt = ConexionDB.RealizarConsulta(sql); List <AppOrder> listaAppOrders = new List <AppOrder>(); foreach (DataRow fila in dt.Rows) { AppOrder qp = new AppOrder(); qp.idorder = fila[0].ToString(); qp.createdate = Convert.ToDateTime(fila[1].ToString()); qp.idproduct = fila[2].ToString(); qp.idadress = fila[3].ToString(); listaAppOrders.Add(qp); } return(listaAppOrders); }
public static void addOrder(AppOrder o) { string act = String.Format( "insert into \"AppOrder\"" + "(\"createDate\", \"idProduct\", \"idAddress\")" + "values ('{0}', {1}, {2});", o.createDate, o.idProduct, o.idAddress); ConnectionBD.ExecuteNonQuery(act); }
public static List <AppOrder> getLista() { string query = $"select ao.\"idOrder\", ao.\"createDate\", pr.\"name\", au.\"fullname\", ad.\"address\"" + $" from \"AppOrder\" ao, \"Product\" pr, \"AppUser\" au, \"Address\" ad" + $" where ao.\"idProduct\"= pr.\"idProduct\" and ao.\"idAddress\" = ad.\"idAddress\"" + $" and ad.\"idUser\"= au.\"idUser\""; DataTable dt = ConnectionBD.ExecuteQuery(query); List <AppOrder> lista = new List <AppOrder>(); foreach (DataRow row in dt.Rows) { AppOrder o = new AppOrder(); lista.Add(o); } return(lista); }
public static List <AppOrder> getLista() { string sql = "select * from apporder"; DataTable dt = ConexionDB.RealizarConsulta(sql); List <AppOrder> listOrders = new List <AppOrder>(); foreach (DataRow fila in dt.Rows) { AppOrder ap = new AppOrder(); ap.idorder = fila[0].ToString(); ap.createdate = Convert.ToDateTime(fila[1].ToString()); ap.idproduct = fila[2].ToString(); ap.idadress = fila[3].ToString(); listOrders.Add(ap); } return(listOrders); }