コード例 #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;
            }
        }
コード例 #2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Zenfox_Software_OO.data.bd_postgres bd       = new Zenfox_Software_OO.data.bd_postgres();
            Zenfox_Software_OO.data.bd          local_db = new Zenfox_Software_OO.data.bd();

            StringBuilder sb = new StringBuilder();

            // Sincronizando produto ==============================================================
            bd.AbrirConexao();
            IDataReader dr = bd.RetornaDados("select * from produto where empresa = " + this.id + "");

            Int32 nome  = dr.GetOrdinal("nome");
            Int32 ean   = dr.GetOrdinal("ean");
            Int32 valor = dr.GetOrdinal("venda");
            Int32 ncm   = dr.GetOrdinal("ncm");
            Int32 cfop  = dr.GetOrdinal("cfop");

            while (dr.Read())
            {
                String xnome = "";
                String xean  = "";
                String xncm  = "";

                if (!dr.IsDBNull(nome))
                {
                    xnome = dr.GetString(nome);
                }

                if (!dr.IsDBNull(ean))
                {
                    xean = dr.GetString(ean);
                }

                if (!dr.IsDBNull(ncm))
                {
                    xncm = dr.GetString(ncm);
                }

                sb.AppendLine("INSERT INTO produtos(nome, ean, valor, ncm, cfop) VALUES('" + xnome + "','" + xean + "'," + dr.GetDouble(valor) + ", '" + xncm + "'," + dr.GetInt32(cfop) + ");");
            }
            bd.FechaConexao();

            local_db.abrir_conexao();
            local_db.Execute_Command(sb.ToString());
            local_db.fecha_conexao();

            backgroundWorker1.ReportProgress(1);
        }
コード例 #3
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         Zenfox_Software_OO.data.bd_postgres bd = new Zenfox_Software_OO.data.bd_postgres();
         bd.testa("SERVER=" + txt_ip.Text + ";PORT=" + txt_porta.Text);
         bd.AbrirConexao();
         bd.FechaConexao();
         MessageBox.Show("Conexão realizada com sucesso !");
         this.Close();
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.Message);
     }
 }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (System.IO.File.Exists("bd.txt"))
            {
                System.IO.File.Delete("bd.txt");
            }

            System.IO.File.WriteAllText("bd.txt", "SERVER=" + txt_ip.Text + ";PORT=" + txt_porta.Text);

            try
            {
                Zenfox_Software_OO.data.bd_postgres sql = new Zenfox_Software_OO.data.bd_postgres();
                sql.localdb();
                sql.AbrirConexao();
                sql.FechaConexao();
                MessageBox.Show("Conexão realizada com sucesso !");
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            //SERVER="++";PORT=5433
        }
コード例 #5
0
        private void Configura_Database_Load(object sender, EventArgs e)
        {
            Boolean x = false;

            Zenfox_Software_OO.data.bd_postgres sql = new Zenfox_Software_OO.data.bd_postgres();

            // Porta 5432
            if (System.IO.File.Exists("bd.txt"))
            {
                System.IO.File.Delete("bd.txt");
            }
            System.IO.File.WriteAllText("bd.txt", "SERVER=localhost;PORT=5432");
            sql.localdb();
            try
            {
                sql.AbrirConexao();
                sql.FechaConexao();
                x = true;
                this.Close();
            }
            catch
            {
            }

            // Porta 5433
            if (!x)
            {
                if (System.IO.File.Exists("bd.txt"))
                {
                    System.IO.File.Delete("bd.txt");
                }
                System.IO.File.WriteAllText("bd.txt", "SERVER=localhost;PORT=5433");
                sql.localdb();
                try
                {
                    sql.AbrirConexao();
                    sql.FechaConexao();
                    x = true;
                    this.Close();
                }
                catch
                {
                }
            }

            // Porta 5434
            if (!x)
            {
                if (System.IO.File.Exists("bd.txt"))
                {
                    System.IO.File.Delete("bd.txt");
                }
                System.IO.File.WriteAllText("bd.txt", "SERVER=localhost;PORT=5434");
                sql.localdb();
                try
                {
                    sql.AbrirConexao();
                    sql.FechaConexao();
                    x = true;
                    this.Close();
                }
                catch
                {
                }
            }
        }
コード例 #6
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");
                //}
            }
        }