예제 #1
0
        private void btnAddDevice_Click(object sender, EventArgs e)
        {
            string idHandHeld = "";
            string marca = "";
            string modelo = "";
            if (txtIDDevice.Text.Trim() != "")
            {
                idHandHeld = txtIDDevice.Text;
                marca = cbdbrand.SelectedValue.ToString();
                modelo = cbdmodel.Text;
                device newDevice = new device(idHandHeld, marca, modelo, 0);

                mainApp.DataManager.addDevice(newDevice);
                updateListaDevices();
                txtIDDevice.Text = "";
            }
            else
            {
                MessageBox.Show("Debe ingresarle un nombre al dispositivo");
            }
        }
예제 #2
0
        private Dictionary<string, device> LoadDevices()
        {
            Dictionary<string, device> listaDevices = new Dictionary<string, device>();
            string idDevice = "";
            string marca = "";
            string modelo = "";
            int identificador = 0;

            SqlConnection cnn = new SqlConnection(conexion);
            SqlCommand cmd = new SqlCommand("ListarDispositivos", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cnn.Open();
            SqlDataReader lector = cmd.ExecuteReader();
            try
            {

                while (lector.Read())
                {
                    idDevice = lector["hhid"].ToString();
                    marca = lector["idMarca"].ToString();
                    modelo = lector["idModelo"].ToString();
                    identificador = Convert.ToInt32(lector["id"].ToString());
                    device d = new device(idDevice, marca, modelo, identificador);

                    listaDevices.Add(idDevice, d);

                }
            }
            catch (Exception)
            {

            }
            finally
            {
                cnn.Close();
            }

            return listaDevices;
        }
예제 #3
0
        public void addDevice(string id_Device, device v_device)
        {
            // Agrega el acceso a la BD
            SqlConnection cnn = new SqlConnection(conexion);
            SqlCommand cmd = new SqlCommand("AgregarDispositivo", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@idHandHeld", v_device.ID);
            cmd.Parameters.AddWithValue("@marca", v_device.MARCA);
            cmd.Parameters.AddWithValue("@modelo", v_device.MODELO);

            try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo agregar el acceso,consulte con el administrador. Error: " + ex.Message);
            }
            finally
            {
                cnn.Close();
            }
        }
        public void addDevice(string id_Device, device v_device)
        {
            if (listaDevices.ContainsKey(id_Device))
            {
                listaDevices.Remove(id_Device);
                listaDevices.Add(id_Device, v_device);
            }
            else
            {
                listaDevices.Add(id_Device, v_device);
            }

            SaveDevices();
        }
        private void LoadDevices()
        {
            if (File.Exists(dataSource + @"\\devices.xml"))
            {

                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(dataSource + @"\\devices.xml");

                listaDevices.Clear();

                foreach (XmlElement elem in xDoc.SelectNodes("/Devices/Device"))
                {
                    string id = elem.Attributes["id"].Value;

                    device newDevice = new device();
                    newDevice.id = id;

                    if (!listaDevices.ContainsKey(id))
                    {
                        listaDevices.Add(id, newDevice);
                    }
                }
            }
        }