Example #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;

            try{
                Zenfox_Software_OO.data.bd_postgres bd = new Zenfox_Software_OO.data.bd_postgres();
                bd.localdb();

                Zenfox_Software_OO.Cadastros.Empresa cmd = new Zenfox_Software_OO.Cadastros.Empresa();
                if (cmd.verifica_primeiro_acesso())
                {
                    inicial inicial = new inicial();
                    inicial.ShowDialog();
                    timer1.Enabled = true;
                }
                else
                {
                    this.Visible = false;
                    Dashboard dashboard = new Dashboard(1);
                    dashboard.Show();
                    atualizacao.RunWorkerAsync();
                }
            }
            catch (Exception ee)
            {
                // MessageBox.Show(ee.Message);
                Configura_Database c_database = new Configura_Database();
                c_database.ShowDialog();
                timer1.Enabled = true;
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (usuario)
            {
                if (txt_cnpj.Text.ToString().Length > 2)
                {
                    if (txt_senha.Text.ToString().Length >= 6)
                    {
                        if (txt_senha.Text == txt_confirmacao_senha.Text)
                        {
                            Zenfox_Software_OO.Cadastros.Usuario cmd_user = new Zenfox_Software_OO.Cadastros.Usuario();

                            Zenfox_Software_OO.Cadastros.Entidade_Usuario ent_usuario = new Zenfox_Software_OO.Cadastros.Entidade_Usuario();
                            ent_usuario.nome    = txt_cnpj.Text;
                            ent_usuario.usuario = txt_cnpj.Text;
                            ent_usuario.senha   = txt_senha.Text;
                            ent_usuario.adm     = true;

                            cmd_user.insere_usuario(ent_usuario);
                            MessageBox.Show("Usuario administrador criado com sucesso !");

                            this.Visible = false;
                            Sincronizacao cmd_sinc = new Sincronizacao();
                            cmd_sinc.id = this.id;
                            cmd_sinc.ShowDialog();

                            Dashboard dash = new Dashboard(this.id);
                            dash.Show();
                        }
                        else
                        {
                            MessageBox.Show("Senha e confirmação de senha são diferentes !");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Sua senha deve conter pelo menos 6 digitos");
                    }
                }
                else
                {
                    MessageBox.Show("Você precisa informar um usuario válido !");
                }

                // UsuarioDAL cmd_usuario = new UsuarioDAL();
                // cmd_usuario.InserirUsuario(txt_cnpj.Text, txt_cnpj.Text, txt_senha.Text, "Ativo", 0, 0, "*****@*****.**");
                // MessageBox.Show("Cadastro Criado com sucesso !");
                // this.Close();
            }
            else
            {
                Boolean existe = false;
                Zenfox_Software_OO.data.bd_postgres sql_pg = new Zenfox_Software_OO.data.bd_postgres();
                //Trend_SAT_OO.data.bd_pg sql = new Trend_SAT_OO.data.bd_pg();
                //EmpresaBLL empresa_bll = new EmpresaBLL();

                sql_pg.AbrirConexao();
                IDataReader dr = sql_pg.RetornaDados("select * from empresa where cpf_cnpj = '" + txt_cnpj.Text.Replace(',', '.').Trim() + "' and senha = '" + txt_senha.Text + "'");

                id = dr.GetOrdinal("id");

                while (dr.Read())
                {
                    existe = true;
                    id     = dr.GetInt32(id);
                }

                sql_pg.FechaConexao();


                if (existe)
                {
                    Zenfox_Software_OO.Cadastros.Empresa cmd_empresa = new Zenfox_Software_OO.Cadastros.Empresa();
                    cmd_empresa.vincula_empresa(id);

                    label_titulo.Text    = "Primeiro Usuario";
                    label_descricao.Text = "Informe o usuario e senha para o usuario principal do sistema";
                    //
                    label_campo1.Text = "Nome Usuario";
                    label_campo2.Text = "Senha";
                    //
                    txt_cnpj.Text  = "";
                    txt_cnpj.Mask  = "";
                    txt_senha.Text = "";
                    //
                    txt_senha2.Visible            = true;
                    txt_senha.Visible             = true;
                    txt_confirmacao_senha.Visible = true;

                    usuario = true;
                }
                else
                {
                    MessageBox.Show("CPF/CNPJ Invalido ou incorreto !");
                }

                //trend_cliente.ClienteClient cmd = new trend_cliente.ClienteClient();
                //Int32 x = cmd.seleciona_cliente(txt_cnpj.Text,txt_senha.Text);
                //
                //if(x > 0){
                //    MessageBox.Show("Vinculado");
                //}else{
                //    MessageBox.Show("Não vinculado");
                //}
            }
        }