Beispiel #1
0
        public int EditMaquina(Machines m)
        {
            int res = 0;

            if (m != null)
            {
                //SE CREA UN DATATABLE COMUN Y SE ASIGNA
                //EL RESULTADO DE UNA CONSULTA LINQ
                //CON EL ID DE LA FILA
                DataTable dt = mta.GetData().
                               Where(x => x.Id == m.id).CopyToDataTable <maquinasRow>();

                //SE CREA UN DATATABLE TIPO DE LA TABLA
                maquinasDataTable mdt = new maquinasDataTable();
                //SE COMBINA LOS DATATABLES PARA FACILITAR EL MANEJO
                mdt.Merge(dt);

                //SE CREA UN DATAROW DEL TIPO DE LA TABLA
                EwoDatabaseDataSet.maquinasRow maqRow =
                    mdt.FindById(m.id);

                //SE ASIGNAN LOS VALORES MODIFICADOS
                maqRow.nombre    = m.nombre;
                maqRow.foto_path = m.foto;

                //SE EJECUTA LA ACTUALIZACIÓN
                res = mta.Update(maqRow);
            }

            return(res);
        }
Beispiel #2
0
        public List <Machines> ConsultarMaquinas(int id_planta)
        {
            List <Machines>   list = new List <Machines>();
            maquinasDataTable mdt  = new maquinasDataTable();

            mdt = mta.GetDataByIdPlanta(id_planta);

            for (int i = 0; i < mdt.Rows.Count; i++)
            {
                list.Add(new Machines()
                {
                    id     = int.Parse(mdt.Rows[i][0].ToString()),
                    nombre = mdt.Rows[i][1].ToString(),
                    foto   = mdt.Rows[i][2].ToString()
                });
            }

            return(list);
        }