Ejemplo n.º 1
0
        private void LvDispositivos_DoubleClick(object sender, EventArgs e)
        {
            LimpaTela();
            String nomeDispositivo = "";

            foreach (ListViewItem item in lvDispositivos.SelectedItems)
            {
                nomeDispositivo = item.Text;
            }
            ConexaoHardwareDAO dao = new ConexaoHardwareDAO();
            var consulta           = dao.GetConexaoPorDispositivo(nomeDispositivo);

            foreach (var _conexaoHardware in consulta)
            {
                conexaoHardwareModel.id = _conexaoHardware.id;

                dispositivoTbx.Text = _conexaoHardware.Dispositivo;
                ipTbx.Text          = _conexaoHardware.IP;
                gatewayTbx.Text     = _conexaoHardware.Gateway;
                mascaraTbx.Text     = _conexaoHardware.MascaraDeRede;
                DDNSTbx.Text        = _conexaoHardware.DDNS;
                statusCbx.Checked   = _conexaoHardware.Ativo;

                gvPortas.Rows.Clear();
                foreach (var item in _conexaoHardware.Portas)
                {
                    DataGridViewRow gvPortasLinha = (DataGridViewRow)gvPortas.Rows[0].Clone();
                    gvPortasLinha.Cells[0].Value = item.Funcao;
                    gvPortasLinha.Cells[1].Value = item.Porta;
                    gvPortasLinha.Cells[2].Value = item.Descricao;
                    gvPortas.Rows.Add(gvPortasLinha);
                }
            }
        }
Ejemplo n.º 2
0
        private void Salva_Click(object sender, EventArgs e)
        {
            if (dispositivoTbx.Text != "" || ipTbx.Text != null || mascaraTbx.Text != null)
            {
                ConexaoHardwareDAO dao = new ConexaoHardwareDAO();
                PortaModel         portaModel;

                if (conexaoHardwareModel.id == null)
                {
                    conexaoHardwareModel = new ConexaoHardwareModel();
                }
                conexaoHardwareModel.Dispositivo   = dispositivoTbx.Text;
                conexaoHardwareModel.IP            = ipTbx.Text;
                conexaoHardwareModel.Gateway       = gatewayTbx.Text;
                conexaoHardwareModel.MascaraDeRede = mascaraTbx.Text;
                conexaoHardwareModel.DDNS          = DDNSTbx.Text;
                conexaoHardwareModel.Ativo         = statusCbx.Checked;

                List <PortaModel> listPortas = new List <PortaModel>();

                if (gvPortas.Rows != null)
                {
                    foreach (DataGridViewRow row in gvPortas.Rows)
                    {
                        if (row.Cells["Porta"].Value != null)
                        {
                            portaModel           = new PortaModel();
                            portaModel.Funcao    = Convert.ToString(row.Cells["Funcao"].Value);
                            portaModel.Porta     = Convert.ToString(row.Cells["Porta"].Value);
                            portaModel.Descricao = Convert.ToString(row.Cells["Descricao"].Value);
                            listPortas.Add(portaModel);
                        }
                    }
                    if (listPortas != null)
                    {
                        conexaoHardwareModel.Portas = listPortas;
                    }
                }
                dao.CriarConexao(conexaoHardwareModel);
                LimpaTela();
                ms.sucessoSalvar();
            }
            else
            {
                ms.camposNaoPreenchidos();
            }
            getDispositivos();
        }
Ejemplo n.º 3
0
        private void getDispositivos()
        {
            ConexaoHardwareDAO dao = new ConexaoHardwareDAO();

            lvDispositivos.Items.Clear();
            var consulta = dao.GetTodasConexoes();

            foreach (var _conexaoHardware in consulta)
            {
                string[]     arr = new string[2];
                ListViewItem itm;
                arr[0] = _conexaoHardware.Dispositivo;
                arr[1] = Convert.ToString(_conexaoHardware.Ativo);
                itm    = new ListViewItem(arr);
                lvDispositivos.Items.Add(itm);
            }
        }
        private void setHardware()
        {
            hardwareModel = new ConexaoHardwareModel();
            ConexaoHardwareDAO dao = new ConexaoHardwareDAO();
            var consulta           = dao.GetConexaoPorDispositivo(hardwareDisponivelcbx.Text);

            if (consulta != null)
            {
                foreach (var _conexaoHardware in consulta)
                {
                    hardwareModel.id = _conexaoHardware.id;

                    hardwareModel.Dispositivo   = _conexaoHardware.Dispositivo;
                    hardwareModel.IP            = _conexaoHardware.IP;
                    hardwareModel.Gateway       = _conexaoHardware.Gateway;
                    hardwareModel.MascaraDeRede = _conexaoHardware.MascaraDeRede;
                    hardwareModel.DDNS          = _conexaoHardware.DDNS;
                    hardwareModel.Ativo         = _conexaoHardware.Ativo;
                    if (_conexaoHardware.Portas != null)
                    {
                        List <PortaModel> portaList = new List <PortaModel>();
                        foreach (var item in _conexaoHardware.Portas)
                        {
                            PortaModel portaHardware = new PortaModel();
                            portaHardware.Funcao    = item.Funcao;
                            portaHardware.Porta     = item.Porta;
                            portaHardware.Descricao = item.Descricao;
                            portaList.Add(portaHardware);
                        }
                        hardwareModel.Portas = portaList;
                    }
                }
                statusConexaoLb.Text      = "Hardware Selecionado.";
                statusConexaoLb.ForeColor = System.Drawing.Color.Green;
                //pnlAcoes.Enabled = true;
                pnlLog.Enabled = true;
            }
            else
            {
                statusConexaoLb.ForeColor = System.Drawing.Color.Red;
                statusConexaoLb.Text      = "Não há dispositivo selecionado!";
                pnlAcoes.Enabled          = false;
                pnlLog.Enabled            = false;
            }
        }
        public PainelOperacoes()
        {
            InitializeComponent();
            label = aGauge1.GaugeLabels.FindByName("GaugeLabel1");
            alert = aGauge1.GaugeRanges.FindByName("AlertRange");
            aGauge1.ValueInRangeChanged += AGauge1_ValueInRangeChanged;
            ConexaoHardwareDAO hardwareDAO = new ConexaoHardwareDAO();

            hardwareCollection = hardwareDAO.GetTodasConexoes();
            foreach (var _hardwareModelList in hardwareCollection)
            {
                hardwareDisponivelcbx.Items.Add(_hardwareModelList.Dispositivo);
            }
            ReceitaDAO receitaDAO = new ReceitaDAO();

            receitasCollection = receitaDAO.GetTodasReceitas();
            foreach (var _receitasModelList in receitasCollection)
            {
                receitaCb.Items.Add(_receitasModelList.Nome);
            }
            pnlAcoes.Enabled = false;
            pnlLog.Enabled   = false;
        }