public int EditSistema(Sistemas s) { int res = 0; if (s != null) { //SE CREA UN DATATABLE COMUN Y SE ASIGNA //EL RESULTADO DE UNA CONSULTA LINQ //CON EL ID DE LA FILA DataTable dt = sta.GetData(). Where(x => x.Id == s.id).CopyToDataTable <sistemasRow>(); //SE CREA UN DATATABLE TIPO DE LA TABLA sistemasDataTable sdt = new sistemasDataTable(); //SE COMBINA LOS DATATABLES PARA FACILITAR EL MANEJO sdt.Merge(dt); //SE CREA UN DATAROW DEL TIPO DE LA TABLA EwoDatabaseDataSet.sistemasRow sisRow = sdt.FindById(s.id); //SE ASIGNAN LOS VALORES MODIFICADOS sisRow.Nombre = s.nombre; sisRow.image_path = s.image_path; sisRow.id_maquina = s.id_machine; //SE EJECUTA LA ACTUALIZACIÓN res = sta.Update(sisRow); } return(res); }
public List <Sistemas> ConsultarSistemas(int id_maquina) { List <Sistemas> list = new List <Sistemas>(); sistemasDataTable sdt = new sistemasDataTable(); sdt = sta.GetDataByIdMaquina(id_maquina); for (int i = 0; i < sdt.Rows.Count; i++) { list.Add(new Sistemas() { id = int.Parse(sdt.Rows[i][0].ToString()), nombre = sdt.Rows[i][1].ToString(), id_machine = int.Parse(sdt.Rows[i][2].ToString()), image_path = sdt.Rows[i][3].ToString() }); } Dispose(true); return(list); }