コード例 #1
0
 public void localizar()
 {
     try
     {
         objDAL          = new LicencaDAL();
         this.lic_codigo = objDAL.localizar(this.lic_codigo);
         objDAL          = null;
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
 public void inserir()
 {
     try
     {
         objDAL = new LicencaDAL();
         objDAL.inserir(this.lic_chave, this.lic_data.ToString());
         objDAL = null;
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
 public DataTable localizar(String descricao, String atributo)
 {
     try
     {
         DataTable tab;
         objDAL = new LicencaDAL();
         tab    = objDAL.localizar(descricao, atributo);
         objDAL = null;
         return(tab);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #4
0
 public void localizarLeave(String descricao, String atributo)
 {
     try
     {
         DataTable tab;
         objDAL = new LicencaDAL();
         tab    = objDAL.localizarLeave(descricao, atributo);
         if (tab.Rows.Count > 0)
         {
             this.lic_codigo = int.Parse(tab.Rows[0]["lic_codigo"].ToString());
             this.lic_chave  = tab.Rows[0]["lic_chave"].ToString();
             this.lic_data   = DateTime.Parse(tab.Rows[0]["lic_data"].ToString());
         }
         objDAL = null;
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #5
0
        private void ValidarLicenca()
        {
            LicencaDAL licenca    = new LicencaDAL();
            DataTable  licenca_dt = licenca.localizar("", "");

            lblDtValidade.Text = "Valido Até " + licenca_dt.Rows[0]["lic_data"].ToString().Replace("00:00:00", "");
            String[] xdata = licenca_dt.Rows[0]["lic_data"].ToString().Replace("00:00:00", "").Split('/');

            DateTime data_licenca = new DateTime(Int32.Parse(xdata[2]), Int32.Parse(xdata[1]), Int32.Parse(xdata[0]));
            DateTime data_atual   = DateTime.Now;

            data_licenca = data_licenca.AddDays(-5);
            int result = DateTime.Compare(data_licenca, data_atual);

            if (result < 0)
            {
                MessageBox.Show("Sua licença esta expirando !");
                lblDtValidade.ForeColor = System.Drawing.Color.FromArgb(192, 57, 43);
            }
            else
            {
                lblDtValidade.ForeColor = System.Drawing.Color.White;
            }
        }
コード例 #6
0
        public Boolean verifica_licenca()
        {
            LicencaDAL licenca = new LicencaDAL();

            DataTable licenca_dt = licenca.localizarLicenca("", "lic_data");

            if (licenca_dt.Rows.Count > 0)
            {
                String data_licenca = licenca_dt.Rows[0]["lic_data"].ToString();

                String[] xdata_licenca = data_licenca.Split('/');
                DateTime nova_data     = new DateTime(Int32.Parse(xdata_licenca[2].Replace("00:00:00", "")), Int32.Parse(xdata_licenca[1]), Int32.Parse(xdata_licenca[0]));

                DateTime data_hoje = DateTime.Now.Date;

                int result = DateTime.Compare(nova_data, data_hoje);

                // Data 1 é anterior a Data 2
                if (result < 0)
                {
                    try
                    {
                        EmpresaDAL empresa = new EmpresaDAL();
                        DataTable  dt      = empresa.localizarEmTudo("");
                        String     xx      = dt.Rows[0]["emp_cnpj"].ToString();

                        Trend_SAT.ClienteClient client = new Trend_SAT.ClienteClient();
                        //trend


                        client.Open();
                        String x = "";

                        bd_pg sql = new bd_pg();
                        sql.AbrirConexao();
                        IDataReader dr = sql.RetornaDados("select * from trendsat_clientes where replace(replace(replace(cnpj,'.',''),'-',''),'/','') = '" + xx.ToString().Replace(".", "").Replace(",", "").Replace("/", "").Replace("-", "") + "'");

                        Int32 xlicenca = dr.GetOrdinal("licenca");

                        while (dr.Read())
                        {
                            x = dr.GetDateTime(xlicenca).ToShortDateString();
                        }

                        sql.FechaConexao();


                        client.Close();

                        if (x.Length > 0)
                        {
                            licenca.limpar_licencas();
                            String[] data = x.Split('/');
                            nova_data = new DateTime(Int32.Parse(data[2]), Int32.Parse(data[1]), Int32.Parse(data[0]));
                            licenca.inserir("", nova_data.ToShortDateString());

                            data_hoje = DateTime.Now.Date;
                            result    = DateTime.Compare(nova_data, data_hoje);

                            if (result < 0)
                            {
                                MessageBox.Show("Sua licença expirou, contate o desenvolvedor do sistema.");
                                return(false);
                            }
                            return(true);
                        }
                        else
                        {
                            MessageBox.Show("Nenhuma licença encontrada para este software, entre em contato com o desenvolvedor.");
                            return(false);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Sua licença Expirou, contate o desenvolvedor ou certifique-se de não ter pendência financeira e estar conectado a internet.");
                        return(false);
                    }
                }
                // Data 1 é igual a Data 2
                else if (result == 0)
                {
                    try
                    {
                        EmpresaDAL empresa = new EmpresaDAL();
                        DataTable  dt      = empresa.localizarEmTudo("");
                        String     xx      = dt.Rows[0]["emp_cnpj"].ToString();

                        Trend_SAT.ClienteClient client = new Trend_SAT.ClienteClient();
                        //trend


                        client.Open();
                        String x = client.DoWork(xx).ToString();

                        client.Close();

                        if (x.Length > 0)
                        {
                            licenca.limpar_licencas();
                            String[] data = x.Split('/');
                            nova_data = new DateTime(Int32.Parse(data[2]), Int32.Parse(data[1]), Int32.Parse(data[0]));
                            licenca.inserir("", nova_data.ToShortDateString());

                            data_hoje = DateTime.Now.Date;
                            result    = DateTime.Compare(nova_data, data_hoje);
                        }
                        else
                        {
                        }
                    }
                    catch
                    {
                    }

                    return(true);
                }
                // Data 1 é maior a Data 2
                else if (result > 0)
                {
                    try
                    {
                        EmpresaDAL empresa = new EmpresaDAL();
                        DataTable  dt      = empresa.localizarEmTudo("");
                        String     xx      = dt.Rows[0]["emp_cnpj"].ToString();

                        Trend_SAT.ClienteClient client = new Trend_SAT.ClienteClient();
                        //trend


                        client.Open();
                        String x = client.DoWork(xx).ToString();

                        client.Close();

                        if (x.Length > 0)
                        {
                            licenca.limpar_licencas();
                            String[] data = x.Split('/');
                            nova_data = new DateTime(Int32.Parse(data[2]), Int32.Parse(data[1]), Int32.Parse(data[0]));
                            licenca.inserir("", nova_data.ToShortDateString());

                            data_hoje = DateTime.Now.Date;
                            result    = DateTime.Compare(nova_data, data_hoje);
                        }
                        else
                        {
                        }
                    }
                    catch
                    {
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                EmpresaDAL empresa = new EmpresaDAL();
                DataTable  dt      = empresa.localizarEmTudo("");
                String     xx      = dt.Rows[0]["emp_cnpj"].ToString();

                //Verifica a licença na internet =============================================
                try
                {
                    Trend_SAT.ClienteClient client = new Trend_SAT.ClienteClient();
                    client.Open();
                    String x = client.DoWork(xx).ToString();

                    client.Close();

                    if (x.Length > 0)
                    {
                        licenca.limpar_licencas();
                        String[] data      = x.Split('/');
                        DateTime nova_data = new DateTime(Int32.Parse(data[2]), Int32.Parse(data[1]), Int32.Parse(data[0]));
                        licenca.inserir("", nova_data.ToShortDateString());

                        DateTime data_hoje = DateTime.Now.Date;
                        int      result    = DateTime.Compare(nova_data, data_hoje);

                        if (result < 0)
                        {
                            MessageBox.Show("Sua licença expirou, contate o desenvolvedor do sistema.");
                            return(false);
                        }
                        return(true);
                    }
                    else
                    {
                        MessageBox.Show("Nenhuma licença encontrada para este software, entre em contato com o desenvolvedor.");
                        return(false);
                    }
                }
                catch
                {
                    //DateTime data_hoje = DateTime.Now.Date;
                    MessageBox.Show("Você precisa estar conectado a internet para atualizar sua licença !");
                    return(false);
                }
            }
        }
コード例 #7
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                String  c_vinculacao = "codigo_vinculacao_fernando";
                String  s_licenca    = "";
                Double  v_imposto    = 0;
                Double  v_reducao    = 0;
                Boolean existe       = false;
                bd_pg   sql          = new bd_pg();
                //Trend_SAT_OO.data.bd_pg sql = new Trend_SAT_OO.data.bd_pg();

                EmpresaBLL empresa_bll = new EmpresaBLL();

                DataTable x     = empresa_bll.localizarEmTudo("");
                String    xcnpj = x.Rows[0].ItemArray[9].ToString().Replace(".", "").Replace("/", "").Replace("-", "").Replace(",", "").Trim();
                //.Rows[1].ToString().Replace(".", "").Replace("/", "").Replace("-", "").Replace(",", "").Trim();
                //txt_cnpj.Text.ToString();

                sql.AbrirConexao();
                IDataReader dr = sql.RetornaDados("select * from trendsat_clientes where replace(replace(replace(cnpj,'.',''),'-',''),'/','') = '" + xcnpj + "'");

                Int32 codigo_vinculacao = dr.GetOrdinal("codigo_vinculacao");
                Int32 licenca           = dr.GetOrdinal("licenca");
                Int32 imposto           = dr.GetOrdinal("imposto");
                Int32 reducao           = dr.GetOrdinal("reducao_tributaria");

                while (dr.Read())
                {
                    existe       = true;
                    c_vinculacao = dr.GetString(codigo_vinculacao);
                    s_licenca    = dr.GetDateTime(licenca).ToShortDateString();
                    v_imposto    = dr.GetDouble(imposto);
                    v_reducao    = dr.GetDouble(reducao);
                }

                sql.FechaConexao();


                if (existe)
                {
                    sql = new bd_pg("DATABASE=erp_trend;Pooling=False;SERVER=177.125.27.78;PORT=5433;UID=sistema;Password=q2aw3@se4;");
                    sql.AbrirConexao();
                    IDataReader dr2 = sql.RetornaDados("select * from erp_clientes where replace(replace(replace(cnpj,'.',''),'-',''),'/','') = '" + xcnpj + "' ");

                    Int32 razao      = dr2.GetOrdinal("nome");
                    Int32 fantasia   = dr2.GetOrdinal("fantasia");
                    Int32 cnpj       = dr2.GetOrdinal("cnpj");
                    Int32 ie         = dr2.GetOrdinal("inscricao_estadual");
                    Int32 im         = dr2.GetOrdinal("inscricao_municipal");
                    Int32 logradouro = dr2.GetOrdinal("logradouro");
                    Int32 numero     = dr2.GetOrdinal("numero");

                    Int32 estado    = dr2.GetOrdinal("uf");
                    Int32 municipio = dr2.GetOrdinal("municipio");

                    if (dr2.Read())
                    {
                        empresa_bll.emp_razaoSocial  = "Teste";
                        empresa_bll.emp_nomeFantasia = dr2.GetString(fantasia);
                        empresa_bll.emp_cnpj         = dr2.GetString(cnpj);

                        empresa_bll.emp_inscricaoEstadual  = dr2.GetString(ie);
                        empresa_bll.emp_inscricaoMunicipal = dr2.GetString(im);
                        empresa_bll.emp_logradouro         = dr2.GetString(logradouro);
                        empresa_bll.emp_numero             = dr2.GetString(numero);

                        empresa_bll.emp_estado = dr2.GetInt32(estado);
                        empresa_bll.emp_cidade = dr2.GetInt32(municipio);
                    }

                    sql.FechaConexao();

                    EmpresaDAL cmd_empresa = new EmpresaDAL();
                    cmd_empresa.excluir(1);
                    cmd_empresa.inserir(1, empresa_bll.emp_razaoSocial, empresa_bll.emp_nomeFantasia, empresa_bll.emp_logradouro, empresa_bll.emp_numero, "", "", empresa_bll.emp_estado, empresa_bll.emp_cidade, "", "", empresa_bll.emp_cnpj, "", "", 0, 0, 0);
                    cmd_empresa.atualiza_informacoes_fiscais(s_licenca, v_imposto, v_reducao);
                    // cmd_empresa.inserir(0, empresa_bll.emp_razaoSocial, "", "",
                    //     "", "", "", 0, 0, "",
                    //     "", "", "", "", 0, 0, 0);

                    // Atualizando Licenã de uso

                    LicencaDAL cmd_licenca = new LicencaDAL();
                    cmd_licenca.limpar_licencas();
                    cmd_licenca.inserir("1", s_licenca);

                    //Configurar ACBR

                    try
                    {
                        Acbr ac = new Acbr();
                        ac.configura_acbr(empresa_bll.emp_cnpj, empresa_bll.emp_inscricaoEstadual, empresa_bll.emp_inscricaoMunicipal, c_vinculacao);
                    }
                    catch
                    {
                        MessageBox.Show("Não foi possível configurar o ACBR, você deve fazer esta etapa depois !");
                    }

                    MessageBox.Show("Vinculação realizada com sucesso !");
                }
                else
                {
                    MessageBox.Show("CPF/CNPJ Invalido ou incorreto !");
                }
            }
            catch
            {
                MessageBox.Show("Falha ao configurar, verifique a sua conexão com a internet !");
            }
        }