Example #1
0
        //AO CARREGAR O FORM, VERIFICA CONFIGS(VERSAO), MENSAGENS E DEPOIS CHAMA O METODO STATUS INICIAL
        public FrmPrincipal()
        {
            InitializeComponent();

            var s = new SistemasController();

            var configs = s.VerificaConfiguracoes();

            /*
             * if (configs == null)//Se não conseguir ler as configurações do banco, fecha o sistema
             * {
             *  Environment.Exit(0);
             *
             * }
             * else if (configs.Versao == "")//Se o campo versão estiver em branco, fecha o sistema
             * {
             *  Environment.Exit(0);
             * }
             * else if (configs.Versao != _versao)
             * {
             *  MessageBox.Show("ATENÇÃO !!!\nEsta versão está desatualizada, por favor, baixe a nova versão" +
             *      "\nno link: " + configs.linkNovaVersao + "", "Atenção !", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  Environment.Exit(0);
             * }
             * if (configs.Menssagem.Length > 0)//Se tiver alguma mensagem, exibe na inicialização
             * {
             *  MessageBox.Show(configs.Menssagem);
             * }
             */
            StatusInicial();
        }
Example #2
0
        //BUSCAR REGISTRO
        private void btnBuscarRegistro_Click(object sender, EventArgs e)
        {
            try
            {
                SistemasController sController = new SistemasController();

                Sistemas s = sController.BuscaCodigo(Convert.ToInt32(textRegistro.Text), Convert.ToInt32(textSistema.Text));
                if (s == null)
                {
                    textRegistro.Text = "";
                }

                textDescricao.Text = "";

                textRegistro.Text     = Convert.ToString(s.Codigo);
                textAssunto.Text      = s.Assunto;
                textDescricao.Text    = s.Descricao;
                textDataGravacao.Text = Convert.ToString(s.DataUltimaGravacao);

                textAssunto.Enabled   = true;
                textDescricao.Enabled = false;//Desabilitado e habilitado no final, pois o texto estava vindo todo selecionado

                btnNovo.Enabled           = true;
                btnGravar.Enabled         = true;
                btnCancelar.Enabled       = true;
                btnBuscarRegistro.Enabled = false;
                btnBuscarAssunto.Enabled  = false;

                textRegistro.Enabled  = false;
                textDescricao.Enabled = true;
            }
            catch (Exception)
            {
            }
        }
Example #3
0
        //BOTÃO GRAVAR
        private void btnGravar_Click(object sender, EventArgs e)
        {
            Sistemas m      = new Sistemas();
            int      tabela = Convert.ToInt32(textSistema.Text);

            m.Codigo             = Convert.ToInt32(textRegistro.Text);
            m.Assunto            = textAssunto.Text;
            m.Descricao          = textDescricao.Text;
            m.DataUltimaGravacao = System.DateTime.Now;

            m.QuemGravou = Environment.UserName;

            SistemasController mController = new SistemasController();

            if (mController.Gravar(m, tabela) == 1)//Se o retorno 1 então foi inserido novo registro
            {
                MessageBox.Show("Gravação concluida !\nRegistro: " + mController.UltimoRegistro(tabela));
                StatusInicial();
            }
            else if (mController.Gravar(m, tabela) == 2)//Se o retorno 2 então foi atualizado
            {
                MessageBox.Show("Gravação concluida !");
                StatusInicial();
            }
        }
Example #4
0
        //BUSCAR ASSUNTO
        private void btnBuscarAssunto_Click(object sender, EventArgs e)
        {
            SistemasController sController = new SistemasController();

            var lista = new List <Sistemas>();

            lista = sController.BuscarAssunto(textAssunto.Text, Convert.ToInt32(textSistema.Text));


            if (lista.Count == 0)
            {
                textDescricao.Enabled = true;
                textDescricao.Enabled = true;
                MessageBox.Show("Não encontrado !");
            }
            else if (lista.Count == 1)
            {
                textRegistro.Text     = Convert.ToString(lista[0].Codigo);
                textAssunto.Text      = lista[0].Assunto;
                textDescricao.Text    = lista[0].Descricao;
                textDataGravacao.Text = Convert.ToString(lista[0].DataUltimaGravacao);

                textRegistro.Enabled  = false;
                textDescricao.Enabled = false;//Desabilitado e habilitado no final, pois o texto estava vindo todo selecionado

                btnGravar.Enabled         = true;
                btnBuscarRegistro.Enabled = false;
                btnBuscarAssunto.Enabled  = false;

                textDescricao.Enabled = true;
            }
            else
            {
                var sb = new System.Text.StringBuilder();
                for (int i = 0; i < lista.Count; i++)
                {
                    sb.AppendLine("REGISTRO: " + Convert.ToString(lista[i].Codigo));
                    sb.AppendLine("ASSUNTO: " + lista[i].Assunto);
                    sb.AppendLine("-------------------------------------------------------" +
                                  "--------------------------------------------------------------------" +
                                  "------------------------------------------------------------");
                }
                textDescricao.Text    = sb.ToString();
                textDescricao.Enabled = true;
            }
        }