Example #1
0
        public Acft IncluirACFT(PictureBox imagem, Acft acft, Local local, float tamFonte)
        {
            imgCarta = imagem;

            acft.listaACFTs_parent = this;

            //acft.Id = proximoID++;

            if (local == null)
            {
                local   = new Local();
                local.X = acft.X;
                local.Y = acft.Y;
            }
            else
            {
                acft.X = local.X;
                acft.Y = local.Y;
            }

            local.donoGrupo = acft.donoGrupo;
            local.donoAcft  = acft;

            /////////////////////////////////////////////////////////

            acft.lblMatricula.Parent      = imagem;
            acft.lblMatricula.AutoSize    = true;
            acft.lblMatricula.BorderStyle = BorderStyle.FixedSingle;

            acft.lblMatricula.Font = new Font("Tahoma", tamFonte, FontStyle.Bold);

            acft.lblMatricula.Click += new EventHandler(this.lbl_Click);

            /////////////////////////////////////////////////////////

            acft.lblAltitude.Parent      = imagem;
            acft.lblAltitude.AutoSize    = true;
            acft.lblAltitude.BorderStyle = BorderStyle.None;

            acft.lblAltitude.Text = acft.Altitude.ToString();
            acft.AtualizarDadosAltitude();

            /////////////////////////////////////////////////////////

            if (!acft.locais.Contains(local))
            {
                acft.locais.Add(local);
            }
            acft.retas.Add(new Reta(local, local));
            acft.indiceRetaAtual = 0;

            ACFTs.Add(acft);

            this.lbl_Click(acft.lblMatricula, new EventArgs());

            return(acft);
        }
        public void ExcluirAcft(Acft acft, bool manterConexaoAberta = true)
        {
            string sql = "DELETE FROM Acft     " +
                         " WHERE Id = @Id      ";

            OleDbCommand command = new OleDbCommand(sql, conexao);

            command.Parameters.AddWithValue("@Id", acft.Id);

            ExecutarComando(command, manterConexaoAberta);
        }
Example #3
0
        private void lblCorPerimetro_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                lblCorPerimetro.ForeColor = colorDialog1.Color;

                Acft acft = new Acft();
                if (listaACFTs.indiceSelecionado != -1)
                {
                    acft = listaACFTs.ACFTs[listaACFTs.indiceSelecionado];
                }

                acft.CorPerimetro = lblCorPerimetro.ForeColor;
            }
        }
        public void ExcluirLocaisAcft(Acft acft, bool manterConexaoAberta = true)
        {
            if (acft == null)
            {
                return;
            }

            string sql = "DELETE FROM Locais        " +
                         " WHERE id_acft = @id_acft ";

            OleDbCommand command = new OleDbCommand(sql, conexao);

            command.Parameters.AddWithValue("@id_acft", acft.Id);

            ExecutarComando(command, manterConexaoAberta);
        }
        public List <Local> LerLocais(Grupo grupo, Acft acft)
        {
            DataTable    dt     = LerLocais_DataTable(grupo, acft);
            List <Local> locais = new List <Local>();

            locais = (
                from row in dt.AsEnumerable()
                select new Local()
            {
                donoGrupo = grupo,
                donoAcft = acft,
                Nome = row["Nome"].ToString(),
                Tipo = row["Tipo"].ToString(),
                Altitude = (int)row["Altitude"],
                X = (int)row["X"],
                Y = (int)row["Y"]
            }
                ).ToList();

            return(locais);
        }
        private DataTable LerLocais_DataTable(Grupo grupo, Acft acft)
        {
            string sql = "SELECT * FROM Locais " +
                         " WHERE 1=1";

            if (grupo != null)
            {
                sql += " AND Id_Grupo = " + grupo.Id;
            }

            if (acft != null)
            {
                sql += " AND Id_Acft = " + acft.Id;
            }
            else
            {
                sql += " AND Id_Acft IS NULL ";
            }

            sql += " ORDER BY Ordem";

            return(LerTabela(sql));
        }
Example #7
0
        //-------------------------------------------------------------------------------------------------------------------

        private void incluirACFT(Local local)
        {
            Acft acft = new Acft();

            acft.donoGrupo = grupo;

            acft.Matricula            = txtACFTMatricula.Text;
            acft.Tipo                 = txtACFTTipo.Text;
            acft.Velocidade           = double.Parse(txtACFTVelocidade.Text);
            acft.Altitude             = int.Parse(txtACFTAltitude.Text);
            acft.distanciaLateralMin  = tckBarDistanciaLateralMinima.Value;
            acft.distanciaVerticalMin = tckBarDistanciaVerticalMinima.Value;

            acft.Incremento = tckBarVelocidade.Value;

            acft.CorFonteMatricula = lblCorAcft.ForeColor;
            acft.CorLinhas         = lblCorLinhas.ForeColor;
            acft.CorPerimetro      = lblCorPerimetro.ForeColor;
            acft.CorFonteAltitude  = lblCorAltitude.ForeColor;

            listaACFTs.IncluirACFT(imgCarta, acft, local, tckBarTamFonte.Value);

            //imgCarta.SendToBack();
        }
 public void ExcluirAcft(Acft Acft)
 {
     dao.ExcluirAcft(Acft);
 }
 public void InserirAlterarAcft(Acft Acft)
 {
     dao.InserirAlterarAcft(Acft);
 }
        /*
         * private void label_KeyUp(object sender, KeyEventArgs e)
         * {
         *  if (e.KeyCode == Keys.Delete)
         *  {
         *      foreach (var local in locais)
         *      {
         *          if (local.lblNome == sender)
         *              locais.Remove(local);
         *      }
         *  }
         * }
         */

        private void label_DoubleClick(object sender, EventArgs e)
        {
            Local remover = null;
            Local l1      = null;
            Local l2      = null;

            int c = 0, i = 0;

            Acft dono = (locais.Where(o => o.lblNome == sender).ToList()[0]).donoAcft;

            //se for um local avulso
            if (dono == null)
            {
                foreach (var local in locais)
                {
                    if (local.lblNome == sender)
                    {
                        locais.Remove(local);
                        local.lblNome.Parent = null;
                        indiceSelecionado    = -1;
                        //imgCarta.Refresh();
                        return;
                    }
                }
            }


            //---------------------------------------------------------------
            //filtrando apenas os locais da acft selecionada
            List <Local> vlocais = locais.Where(o => o.donoAcft == dono).ToList();

            foreach (var local in vlocais)
            {
                if (local.lblNome == sender)
                {
                    remover = local;
                }
                else
                if (remover == null)
                {
                    i  = c;
                    l1 = local;
                }
                else
                {
                    l2 = local;
                    break;
                }
                c++;
            }

            if (l2 == null)
            {
                if (l1.donoAcft.retas.Count == 1)
                {
                    l1.donoAcft.retas[i].Fim = remover.donoAcft.retas[i].Ini;

                    dono.locais.Remove(remover);
                    locais.Remove(remover);
                    remover.lblNome.Parent = null;
                }
                else
                if (l1.donoAcft.indiceRetaAtual < l1.donoAcft.retas.Count() - 1)
                {
                    l1.donoAcft.retas[i].Fim = remover.donoAcft.retas[i].Fim;
                    l1.donoAcft.retas.Remove(l1.donoAcft.retas[i]);

                    dono.locais.Remove(remover);
                    locais.Remove(remover);
                    remover.lblNome.Parent = null;

                    if (i == l1.donoAcft.indiceRetaAtual)
                    {
                        l1.donoAcft.Trafegar(l1.donoAcft.retas[l1.donoAcft.indiceRetaAtual].Fim);
                    }
                }
            }
            else
            {
                if (l1 == null)
                {
                    return;
                }

                l1.donoAcft.retas[i].Fim = remover.donoAcft.retas[i + 1].Fim;
                l1.donoAcft.retas.Remove(l1.donoAcft.retas[i + 1]);

                if (i == l1.donoAcft.indiceRetaAtual)
                {
                    l1.donoAcft.Trafegar(l2);
                }
                else
                if (i < l1.donoAcft.indiceRetaAtual)
                {
                    --l1.donoAcft.indiceRetaAtual;
                }

                dono.locais.Remove(remover);
                locais.Remove(remover);
                remover.lblNome.Parent = null;
            }

            indiceSelecionado = -1;
            imgCarta.Refresh();
        }
        public void InserirAlterarAcft(Acft acft, bool manterConexaoAberta = true)
        {
            OleDbCommand command = null;
            string       sql     = "";

            if (acft.Id == 0)
            {
                sql += " INSERT INTO Acft                                                    ";
                sql += " (                                                                   ";
                sql += "   Id_Grupo, Id, Matricula, Tipo, Velocidade, Altitude,              ";
                sql += "   CorFonteMatricula, CorFonteAltitude, CorLinhas, CorPerimetro,     ";
                sql += "   MostrarMatricula, MostrarRumo, MostrarPerimetro                   ";
                sql += " )                                                                   ";
                sql += " VALUES                                                              ";
                sql += " (                                                                   ";
                sql += "   @Id_Grupo, @Id, @Matricula, @Tipo, @Velocidade, @Altitude,        ";
                sql += "   @CorFonteMatricula, @CorFonteAltitude, @CorLinhas, @CorPerimetro, ";
                sql += "   @MostrarMatricula, @MostrarRumo, @MostrarPerimetro                ";
                sql += " )                                                                   ";

                command = new OleDbCommand(sql, conexao);

                acft.Id = LerNovoId("Acft");

                command.Parameters.AddWithValue("@Id_Grupo", acft.donoGrupo.Id);
                command.Parameters.AddWithValue("@Id", acft.Id);
                command.Parameters.AddWithValue("@Matricula", acft.Matricula);
                command.Parameters.AddWithValue("@Tipo", acft.Tipo);
                command.Parameters.AddWithValue("@Velocidade", acft.Velocidade);
                command.Parameters.AddWithValue("@Altitude", acft.Altitude);

                command.Parameters.AddWithValue("@CorFonteMatricula", Cores.toARGB(acft.CorFonteMatricula));
                command.Parameters.AddWithValue("@CorFonteAltitude", Cores.toARGB(acft.CorFonteAltitude));
                command.Parameters.AddWithValue("@CorLinhas", Cores.toARGB(acft.CorLinhas));
                command.Parameters.AddWithValue("@CorPerimetro", Cores.toARGB(acft.CorPerimetro));

                command.Parameters.AddWithValue("@MostrarMatricula", acft.MostrarMatricula);
                command.Parameters.AddWithValue("@MostrarRumo", acft.MostrarRumo);
                command.Parameters.AddWithValue("@MostrarPerimetro", acft.MostrarPerimetro);
            }
            else
            {
                sql += "UPDATE Acft SET                               ";
                sql += "       Matricula         = @Matricula,         ";
                sql += "       Tipo              = @Tipo,              ";
                sql += "       Velocidade        = @Velocidade,        ";
                sql += "       Altitude          = @Altitude,          ";

                sql += "       CorFonteMatricula = @CorFonteMatricula, ";
                sql += "       CorFonteAltitude  = @CorFonteAltitude,  ";
                sql += "       CorLinhas         = @CorLinhas,         ";
                sql += "       CorPerimetro      = @CorPerimetro,      ";

                sql += "       MostrarMatricula  = @MostrarMatricula,  ";
                sql += "       MostrarRumo       = @MostrarRumo,       ";
                sql += "       MostrarPerimetro  = @MostrarPerimetro   ";

                sql += " WHERE Id = @Id ";

                command = new OleDbCommand(sql, conexao);

                command.Parameters.AddWithValue("@Matricula", acft.Matricula);
                command.Parameters.AddWithValue("@Tipo", acft.Tipo);
                command.Parameters.AddWithValue("@Velocidade", acft.Velocidade);
                command.Parameters.AddWithValue("@Altitude", acft.Altitude);

                command.Parameters.AddWithValue("@CorFonteMatricula", Cores.toARGB(acft.CorFonteMatricula));
                command.Parameters.AddWithValue("@CorFonteAltitude", Cores.toARGB(acft.CorFonteAltitude));
                command.Parameters.AddWithValue("@CorLinhas", Cores.toARGB(acft.CorLinhas));
                command.Parameters.AddWithValue("@CorPerimetro", Cores.toARGB(acft.CorPerimetro));

                command.Parameters.AddWithValue("@MostrarMatricula", acft.MostrarMatricula);
                command.Parameters.AddWithValue("@MostrarRumo", acft.MostrarRumo);
                command.Parameters.AddWithValue("@MostrarPerimetro", acft.MostrarPerimetro);
                //where
                command.Parameters.AddWithValue("@Id", acft.Id);
            }

            ExecutarComando(command, manterConexaoAberta);

            ExcluirLocaisAcft(acft);
            InserirLocais(acft.locais);
        }