Exemple #1
0
        /// <summary>
        /// Método responsável por retornar o ID do item especificado.
        /// </summary>
        /// <param name="comando">Comando que será consultado no banco de dados.</param>
        public static string ConsultaSimples(string comando)
        {
            string resultado = null;

            try
            {
                AbreConexao();

                MySqlCommand cmd = new MySqlCommand(comando, conexao);
                resultado = cmd.ExecuteScalar().ToString();
            }
            catch (NullReferenceException)
            {
                FechaConexao();
                return(null);
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(04);
                FechaConexao();
                return(null);
            }
            finally
            {
                FechaConexao();
            }

            return(resultado);
        }
Exemple #2
0
        public static void AtualizarCliente()
        {
            try
            {
                string comando = "Update tbl_contato set nome = '" + Nome + "', " +
                                 "razaosocial = '" + RazaoSocial + "', telefone = '" + Telefone + "', " +
                                 "contato = '" + Contato + "', setor = '" + Setor + "', " +
                                 "cpf = '" + CPF + "', rg = '" + RG + "', cnpj = '" + CNPJ + "', " +
                                 "inscricaoestadual = '" + InscricaoEstadual + "', inscricaomunicipal = '" + InscricaoMunicipal + "', " +
                                 "site = '" + Site + "', email = '" + Email + "', endereco = '" + Endereco + "', " +
                                 "bairro = '" + Bairro + "', cidade = '" + Cidade + "', estado = '" + Estado + "', " +
                                 "cep = '" + CEP + "', complemento = '" + Complemento + "', " +
                                 "pontoreferencia = '" + PontoReferencia + "', obs = '" + Obs + "'" +
                                 "where id = '" + ID + "';";
                Sistema.ExecutaComando(comando);

                comando = "Update tbl_contato_contrato set contrato = " + Contrato + " where contato = " + ID + ";";
                Sistema.ExecutaComando(comando);
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(38);
                return;
            }
            finally
            {
                Log.AlterarCliente();

                ListaMensagens.RetornaMensagem(11, MessageBoxIcon.Information);
            }
        }
Exemple #3
0
        /// <summary>
        /// Verifica o Login
        /// </summary>
        /// <param name="user">Usuário</param>
        /// <param name="pw">Senha</param>
        /// <returns></returns>
        public static bool VerificaLogin(string user, string pw)
        {
            try
            {
                AbreConexao();

                string       comando = "select id from tbl_usuarios where user = '******' and pw = '" + pw + "';";
                MySqlCommand cmd     = new MySqlCommand(comando, conexao);
                if (!string.IsNullOrEmpty(cmd.ExecuteScalar().ToString()))
                {
                    FechaConexao();
                    return(true);
                }
                else
                {
                    FechaConexao();
                    return(false);
                }
            }
            catch (NullReferenceException)
            {
                ListaErro.RetornaErro(47);
                FechaConexao();
                return(false);
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(04);
                FechaConexao();
                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// Método responsável por preencher as combobox nas telas.
        /// </summary>
        /// <param name="comando">Comando que será consultado no banco de dados.</param>
        public static List <string> PreencheCMB(string comando)
        {
            List <string> resultado = new List <string>();

            try
            {
                AbreConexao();

                MySqlCommand    cmd = new MySqlCommand(comando, conexao);
                MySqlDataReader dR;

                dR = cmd.ExecuteReader();

                while (dR.Read())
                {
                    resultado.Add(dR.GetString("Nome"));
                }
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(03);
                FechaConexao();
                return(resultado);
            }
            finally
            {
                FechaConexao();
            }

            return(resultado);
        }
Exemple #5
0
        /// <summary>
        /// Abre a conexão com o Banco de dados.
        /// </summary>
        private static void AbreConexao()
        {
            if (enderecoServidor == "")
            {
                XElement xml;

                try
                {
                    xml = XElement.Load(arquivoXML);
                }
                catch (Exception)
                {
                    Configuracoes_Banco config = new Configuracoes_Banco(true);
                    config.ShowDialog();
                    return;
                }

                try
                {
                    foreach (XElement x in xml.Elements())
                    {
                        enderecoServidor = x.Attribute("servidor").Value;
                        nomeBanco        = x.Attribute("banco").Value;
                        nomeUsuario      = x.Attribute("uid").Value;
                        senhaUsuario     = x.Attribute("pwd").Value;
                    }
                }
                catch (Exception)
                {
                    ListaErro.RetornaErro(60);
                    return;
                }
            }

            try
            {
                string connString = string.Format("Server={0}; Database={1}; Userid={2}; Password={3};",
                                                  enderecoServidor, nomeBanco, nomeUsuario, senhaUsuario);

                conexao = new MySqlConnection(connString);
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(01);
                return;
            }

            try
            {
                if (conexao.State == ConnectionState.Closed)
                {
                    conexao.Open();
                }
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(59);
                return;
            }
        }
Exemple #6
0
        /// <summary>
        /// Método responsável por retornar a tarefa solicitada.
        /// </summary>
        /// <param name="comando">Comando que será consultado no banco de dados.</param>
        public static List <string> ConsultaFornecedor(string comando)
        {
            List <string> resultado = new List <string>();

            try
            {
                AbreConexao();

                MySqlCommand    cmd = new MySqlCommand(comando, conexao);
                MySqlDataReader dR;

                dR = cmd.ExecuteReader();

                while (dR.Read())
                {
                    for (int i = 0; i < 25; i++)
                    {
                        if (dR.IsDBNull(i))
                        {
                            resultado.Add("");
                        }
                        else
                        {
                            if (dR.GetString(i) == null)
                            {
                                resultado.Add("");
                            }
                            else
                            {
                            }
                            resultado.Add(dR.GetString(i).ToString());
                        }
                    }
                }

                dR.Close();
            }


            catch (MySqlException)
            {
                ListaErro.RetornaErro(55);
                FechaConexao();
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("AQUI");
            }
            finally
            {
                FechaConexao();
            }

            return(resultado);
        }
Exemple #7
0
        /// <summary>
        /// Método responsável por verificar o CNPJ na receita federal e importar os dados do CNPJ informado
        /// </summary>
        /// <param name="_CNPJ"></param>
        /// <returns>CNPJ da empresa/MEI</returns>
        public static bool PesquisarCNPJ(string _CNPJ)
        {
            bool resultado = false;

            if (Funcoes.ValidaCNPJ(_CNPJ))
            {
                string url = "https://www.receitaws.com.br/v1/cnpj/" + _CNPJ;

                try
                {
                    string fileContents;

                    WebRequest  request  = WebRequest.Create(url);
                    WebResponse response = request.GetResponse();
                    Stream      data     = response.GetResponseStream();

                    string html = String.Empty;
                    using (StreamReader sr = new StreamReader(data))
                    {
                        fileContents = sr.ReadToEnd();
                    }

                    JsonTextReader reader     = new JsonTextReader(new StringReader(fileContents));
                    RootObject     rootobject = JsonConvert.DeserializeObject <RootObject>(fileContents);

                    for (int i = 0; i < 1; i++)
                    {
                        Nome              = rootobject.Nome;
                        Apelido           = rootobject.Fantasia;
                        DataNascimento    = rootobject.Abertura;
                        CEP               = rootobject.CEP.Replace(".", "").Replace("-", "");
                        Endereco          = rootobject.Logradouro;
                        Numero            = rootobject.Numero.Replace("(", "").Replace(")", "").Replace(" ", "");
                        Complemento       = rootobject.Complemento;
                        Bairro            = rootobject.Bairro;
                        Cidade            = rootobject.Municipio;
                        Estado            = rootobject.UF;
                        TelefoneComercial = rootobject.Telefone;
                        Email             = rootobject.Email;
                    }
                }
                catch (Exception)
                {
                    ListaErro.RetornaErro(53);
                }
                finally
                {
                    resultado = true;
                }
            }

            return(resultado);
        }
Exemple #8
0
 /// <summary>
 /// Método responsável por apagar o fornecedor
 /// </summary>
 public static void ApagarFornecedor(int _id)
 {
     try
     {
         string comando = "delete from tbl_fornecedor where ID = '" + _id + "';";
         Sistema.ExecutaComando(comando);
     }
     catch (Exception)
     {
         ListaErro.RetornaErro(57);
         throw;
     }
 }
Exemple #9
0
        /// <summary>
        /// Destrava todas as tarefas do banco de dados
        /// </summary>
        public static bool DestravaTodasTarefas()
        {
            try
            {
                Sistema.ExecutaComando("Update tbl_tarefas set travar = 'N';");
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(19);
                return(false);
            }

            return(true);
        }
Exemple #10
0
        public static void PreCarregaCliente(string nome)
        {
            try
            {
                LimparVariaveis();

                string comando = "Select ID from tbl_contato" + " where nome = '" + nome + "';";
                ID = int.Parse(Sistema.ConsultaSimples(comando));
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(20);
                return;
            }
        }
Exemple #11
0
        /// <summary>
        /// Atualiza a tarefa
        /// </summary>
        /// <returns>Se verdadeiro, a operação foi um sucesso</returns>
        public static bool AtualizarTarefa()
        {
            string comando = null;
            int    idEmpresa = 0, idFuncionario = 0;

            try
            {
                comando   = "Select ID from tbl_contato where nome = '" + empresa + "';";
                idEmpresa = int.Parse(Sistema.ConsultaSimples(comando));

                comando       = "Select ID from tbl_funcionarios where nome = '" + atribuicao + "';";
                idFuncionario = int.Parse(Sistema.ConsultaSimples(comando));
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(17);
                return(false);
            }

            try
            {
                comando = "update tbl_tarefas " +
                          "SET empresa = " + idEmpresa + ", funcionario = " + idFuncionario + ", " +
                          "status = " + status + ", assunto = '" + assunto + "', " +
                          "datainicial = '" + dataInicial + "', datafinal = '" + dataFinal + "', " +
                          "prioridade = " + prioridade + ", texto = '" + texto + "' " +
                          "Where id = " + ID + ";";

                Sistema.ExecutaComando(comando);
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(17);
                return(false);
            }

            //Atualiza variáveis
            _assunto     = Assunto;
            _atribuicao  = Atribuicao;
            _dataFinal   = DataFinal;
            _dataInicial = DataInicial;
            _empresa     = Empresa;
            _prioridade  = Prioridade;
            _status      = Status;
            _texto       = Texto;

            return(true);
        }
Exemple #12
0
        public static List <string> ConsultaAnexosTarefa(int id, string comando)
        {
            List <string> resultado = new List <string>();

            try
            {
                AbreConexao();

                MySqlCommand    cmd = new MySqlCommand(comando, conexao);
                MySqlDataReader dR;

                dR = cmd.ExecuteReader();

                int qtdAnexos = int.Parse(ConsultaSimples("Select count(id) from tbl_tarefa_anexos " +
                                                          "where tarefa = " + id + ";"));

                while (dR.Read())
                {
                    for (int i = 0; i < qtdAnexos; i++)
                    {
                        if (dR.GetString(i) == null)
                        {
                            resultado.Add("");
                        }
                        else
                        {
                            resultado.Add(dR.GetString(i));
                        }
                    }
                }
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(05);
                FechaConexao();
            }
            finally
            {
                FechaConexao();
            }

            return(resultado);
        }
Exemple #13
0
 /// <summary>
 /// Método que executa um comando no MYSQL
 /// </summary>
 /// <param name="comando">Comando que será executado no banco de dados.</param>
 public static void ExecutaComando(string comando)
 {
     try
     {
         AbreConexao();
         MySqlCommand cmd = new MySqlCommand(comando, conexao);
         cmd.ExecuteNonQuery();
     }
     catch (MySqlException)
     {
         ListaErro.RetornaErro(11);
         FechaConexao();
         return;
     }
     finally
     {
         FechaConexao();
     }
 }
Exemple #14
0
        /// <summary>
        /// Método responsável por atualizar o fornecedor
        /// </summary>
        public static void AtualizarFornecedor()
        {
            string comando = null, _dataNascimento = null;

            try
            {
                if (!string.IsNullOrEmpty(DataNascimento))
                {
                    if (DataNascimento.Length > 8)
                    {
                        _dataNascimento = DataNascimento.Substring(6, 4) + "-" + DataNascimento.Substring(3, 2) + "-" + DataNascimento.Substring(0, 2);
                    }
                    else
                    {
                        _dataNascimento = DataNascimento.Substring(4, 4) + "-" + DataNascimento.Substring(2, 2) + "-" + DataNascimento.Substring(0, 2);
                    }

                    comando = string.Format("update tbl_fornecedor set Tipo = '{0}', DataNascimento = '{1}', Documento = '{2}', Nome = '{3}', Apelido = '{4}', CEP = '{5}'," +
                                            " Endereco = '{6}', Numero = '{7}', Complemento = '{8}', Bairro = '{9}', Cidade = '{10}', Estado = '{11}', Pais = '{12}', Telefone = '{13}', " +
                                            "Contato = '{14}', TelefoneComercial = '{15}', ContatoComercial = '{16}', Celular = '{17}', ContatoCelular = '{18}', Email = '{19}', Site = '{20}'," +
                                            "InscricaoEstadual = '{21}', InscricaoEstadual = '{22}', Observacoes = '{23}' where ID = '{24}';"
                                            , Tipo, _dataNascimento, Documento, Nome, Apelido, CEP, Endereco, Numero, Complemento, Bairro, Cidade, Estado, Pais, Telefone, Contato, TelefoneComercial,
                                            ContatoComercial, Celular, ContatoCelular, Email, Site, InscricaoEstadual, InscricaoEstadual, Obs, ID);
                }
                else
                {
                    comando = string.Format("update tbl_fornecedor set Tipo = '{0}', Documento = '{1}', Nome = '{2}', Apelido = '{3}', CEP = '{4}'," +
                                            " Endereco = '{5}', Numero = '{6}', Complemento = '{7}', Bairro = '{8}', Cidade = '{9}', Estado = '{10}', Pais = '{11}', Telefone = '{12}', " +
                                            "Contato = '{13}', TelefoneComercial = '{14}', ContatoComercial = '{15}', Celular = '{16}', ContatoCelular = '{17}', Email = '{18}', Site = '{19}'," +
                                            "InscricaoEstadual = '{20}', InscricaoEstadual = '{21}', Observacoes = '{22}' where ID = '{23}';"
                                            , Tipo, Documento, Nome, Apelido, CEP, Endereco, Numero, Complemento, Bairro, Cidade, Estado, Pais, Telefone, Contato, TelefoneComercial,
                                            ContatoComercial, Celular, ContatoCelular, Email, Site, InscricaoEstadual, InscricaoEstadual, Obs, ID);
                }


                Sistema.ExecutaComando(comando);
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(51);
                throw;
            }
        }
Exemple #15
0
        /// <summary>
        /// Método responsável por destravar todos os Fornecedores do banco de dados.
        /// Utilizar apenas se ocorrer algum desligamento inesperado de algum usuário.
        /// </summary>
        /// <returns>Se verdadeiro, a operação foi um sucesso.</returns>
        public static bool DestravaTodosFornecedores()
        {
            bool   resultado = false;
            string comando   = null;

            try
            {
                comando = "Update tbl_fornecedor set travar = 'N';";
                Sistema.ExecutaComando(comando);
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(19);
            }
            finally
            {
                resultado = true;
            }

            return(resultado);
        }
Exemple #16
0
        /// <summary>
        /// Método responsável por retornar a tarefa solicitada.
        /// </summary>
        /// <param name="comando">Comando que será consultado no banco de dados.</param>
        public static List <string> ConsultaTarefas(string comando)
        {
            List <string> resultado = new List <string>();

            try
            {
                AbreConexao();

                MySqlCommand    cmd = new MySqlCommand(comando, conexao);
                MySqlDataReader dR;

                dR = cmd.ExecuteReader();

                while (dR.Read())
                {
                    for (int i = 0; i < 9; i++)
                    {
                        if (dR.GetString(i) == null)
                        {
                            resultado.Add("");
                        }
                        else
                        {
                            resultado.Add(dR.GetString(i));
                        }
                    }
                }
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(05);
                FechaConexao();
            }
            finally
            {
                FechaConexao();
            }

            return(resultado);
        }
Exemple #17
0
        /// <summary>
        /// Método responsável por retornar o id AutoIncrement do MYSQL da tabela selecionada
        /// </summary>
        /// <param name="tipo">1:Clientes/Fornecedores, 2:Ordem de serviço</param>
        /// <returns></returns>
        public static string ConsultaAutoIncrement(int tipo)
        {
            string resultado = null;

            string comando = "SELECT `AUTO_INCREMENT` " +
                             "FROM INFORMATION_SCHEMA.TABLES " +
                             "WHERE TABLE_SCHEMA = 'gerenciatarefa' ";

            switch (tipo)
            {
            case 1:
                comando += "AND TABLE_NAME = 'tbl_contato';";
                break;

            case 2:
                break;
            }

            try
            {
                AbreConexao();
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(07);
                FechaConexao();
            }
            finally
            {
                MySqlCommand cmd = new MySqlCommand(comando, conexao);

                resultado = cmd.ExecuteScalar().ToString();

                FechaConexao();
            }

            return(resultado);
        }
Exemple #18
0
        /// <summary>
        /// Preenche um DataSet e retorna um DataTable com o resultado.
        /// </summary>
        /// <param name="comando">Comando que será consultado no banco de dados.</param>
        public static DataTable PreencheDGV(string comando)
        {
            DataSet resultado = new DataSet();

            try
            {
                AbreConexao();

                MySqlDataAdapter dA = new MySqlDataAdapter(comando, conexao);
                dA.Fill(resultado);
            }
            catch (MySqlException)
            {
                ListaErro.RetornaErro(02);
                FechaConexao();
            }
            finally
            {
                FechaConexao();
            }

            return(resultado.Tables[0]);
        }
Exemple #19
0
        /// <summary>
        /// Método que copia todos os arquivos do diretório.
        /// </summary>
        /// <param name="sourceDirName">De qual pasta será copiado</param>
        /// <param name="destDirName">Para qual pasta será copiado</param>
        /// <param name="copySubDirs">Copiar subpastas?</param>
        private static void CopiaDiretorio(string sourceDirName, string destDirName, bool copySubDirs)
        {
            // Get the subdirectories for the specified directory.
            DirectoryInfo dir = new DirectoryInfo(sourceDirName);

            if (!dir.Exists)
            {
                ListaErro.RetornaErro(30);
                return;
            }

            DirectoryInfo[] dirs = dir.GetDirectories();
            // If the destination directory doesn't exist, create it.
            if (!Directory.Exists(destDirName))
            {
                Directory.CreateDirectory(destDirName);
            }

            // Get the files in the directory and copy them to the new location.
            FileInfo[] files = dir.GetFiles();
            foreach (FileInfo file in files)
            {
                string temppath = Path.Combine(destDirName, file.Name);
                file.CopyTo(temppath, false);
            }

            // If copying subdirectories, copy them and their contents to new location.
            if (copySubDirs)
            {
                foreach (DirectoryInfo subdir in dirs)
                {
                    string temppath = Path.Combine(destDirName, subdir.Name);
                    CopiaDiretorio(subdir.FullName, temppath, copySubDirs);
                }
            }
        }
Exemple #20
0
        public static bool AnexarArquivo(string caminhoArquivo)
        {
            bool resultado = false;

            try
            {
                string formato             = Path.GetExtension(caminhoArquivo).ToUpper();
                string nomeArquivo         = Path.GetFileNameWithoutExtension(caminhoArquivo);
                string nomeArquivoCompleto = nomeArquivo + formato;
                string enderecoServidor    = Encoding.UTF8.GetString(Convert.FromBase64String(Sistema.EnderecoServidor));
                string caminhoPasta        = "\\\\" + enderecoServidor + "\\GerenciadorTarefas\\Anexos\\" + id.ToString();
                string destino             = caminhoPasta + "\\" + nomeArquivoCompleto;

                if (!Directory.Exists(caminhoPasta))
                {
                    Directory.CreateDirectory(caminhoPasta);
                }

                FileInfo arquivo = new FileInfo(destino);

                if (!arquivo.Exists)
                {
                    try
                    {
                        File.Copy(caminhoArquivo, destino);
                        resultado = true;
                    }
                    catch (Exception)
                    {
                        ListaErro.RetornaErro(65);
                        return(resultado);
                    }
                    finally
                    {
                        if (resultado)
                        {
                            string comando = "Select id from tbl_tarefa_anexos " +
                                             "where tarefa = '" + id.ToString() + "' and nome = '" + nomeArquivoCompleto + "';";

                            if (string.IsNullOrEmpty(Sistema.ConsultaSimples(comando)))
                            {
                                Sistema.ExecutaComando("insert into tbl_tarefa_anexos values(0," + id.ToString() + "," +
                                                       "'" + nomeArquivoCompleto + "');");
                            }
                            else
                            {
                                ListaMensagens.RetornaMensagem(35, MessageBoxIcon.Information);
                                resultado = false;
                            }
                        }
                    }
                }
                else
                {
                    ListaMensagens.RetornaMensagem(34, MessageBoxIcon.Information);
                }
            }
            catch (Exception)
            {
            }

            return(resultado);
        }
Exemple #21
0
        /// <summary>
        /// Cadastra a tarefa
        /// </summary>
        public static void CadastrarTarefa()
        {
            string comando = null;
            int    idEmpresa = 0, idFuncionario = 0;

            try
            {
                comando   = "Select ID from tbl_contato where nome = '" + empresa + "';";
                idEmpresa = int.Parse(Sistema.ConsultaSimples(comando));

                comando       = "Select ID from tbl_funcionarios where nome = '" + atribuicao + "';";
                idFuncionario = int.Parse(Sistema.ConsultaSimples(comando));
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(16);
                return;
            }
            finally
            {
                //Atualiza variáveis
                string _dataCadastro = Sistema.Hoje.Substring(6, 4) + "-" + Sistema.Hoje.Substring(3, 2) + "-" + Sistema.Hoje.Substring(0, 2);

                _assunto     = Assunto;
                _atribuicao  = Atribuicao;
                _dataFinal   = DataFinal.Substring(6, 4) + "-" + DataFinal.Substring(3, 2) + "-" + DataFinal.Substring(0, 2);
                _dataInicial = DataInicial.Substring(6, 4) + "-" + DataInicial.Substring(3, 2) + "-" + DataInicial.Substring(0, 2);
                _empresa     = Empresa;
                _prioridade  = Prioridade;
                _status      = Status;
                _texto       = Texto;

                if (travar)
                {
                    //Cadastra a tarefa
                    comando = "insert into tbl_tarefas values (0," + idEmpresa + "," + idFuncionario
                              + "," + status + ",'" + assunto + "','" + _dataCadastro + "','" + _dataInicial + "', '" + _dataFinal
                              + "'," + prioridade + ",'" + texto + "','S');";
                    Sistema.ExecutaComando(comando);

                    _dataFinal   = DataFinal;
                    _dataInicial = DataInicial;

                    //ID da tarefa
                    comando = "Select ID from tbl_tarefas where empresa = '" + idEmpresa
                              + "' AND funcionario = '" + idFuncionario
                              + "' AND assunto = '" + assunto + "';";

                    id = int.Parse(Sistema.ConsultaSimples(comando));

                    //Data de Cadastro da tarefa
                    comando = "Select DataCadastro from tbl_tarefas"
                              + " where id = '" + id.ToString() + "';";

                    string resultado = Sistema.ConsultaSimples(comando);

                    dataCadastro = resultado.Substring(6, 4) + "-" + resultado.Substring(3, 2) + "-" + resultado.Substring(0, 2);

                    novaTarefa = false;
                }
                else
                {
                    comando = "insert into tbl_tarefas values (0," + idEmpresa + "," + idFuncionario
                              + "," + status + ",'" + assunto + "','" + dataCadastro + "','" + dataInicial + "', '" + dataFinal
                              + "'," + prioridade + ",'" + texto + "','N');";
                    Sistema.ExecutaComando(comando);
                }
            }
        }
Exemple #22
0
        /// <summary>
        /// Carrega os dados da tarefa escolhida
        /// </summary>
        public static void CarregarTarefa()
        {
            try
            {
                int idEmpresa = 0, idFuncionario = 0;

                string comando = "Select ID from tbl_contato"
                                 + " where nome = '" + empresa + "';";
                idEmpresa = int.Parse(Sistema.ConsultaSimples(comando));

                comando = "Select ID from tbl_funcionarios"
                          + " where nome = '" + atribuicao + "';";
                idFuncionario = int.Parse(Sistema.ConsultaSimples(comando));

                comando = "Select ID from tbl_tarefas"
                          + " where empresa = '" + idEmpresa + "' AND funcionario = '" + idFuncionario +
                          "' AND assunto = '" + assunto + "';";

                id = int.Parse(Sistema.ConsultaSimples(comando));
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(15);
                return;
            }
            finally
            {
                novaTarefa = false;

                List <string> lista = Sistema.ConsultaTarefas("select tbl_contato.nome AS 'empresa', " +
                                                              "tbl_funcionarios.nome as 'funcionario', tbl_tarefas.`status`, tbl_tarefas.assunto, " +
                                                              "tbl_tarefas.dataCadastro, tbl_tarefas.datainicial, tbl_tarefas.datafinal, " +
                                                              "tbl_tarefas.prioridade, tbl_tarefas.texto from tbl_tarefas " +
                                                              "Join tbl_contato on tbl_contato.ID = tbl_tarefas.Empresa " +
                                                              "Join tbl_funcionarios on tbl_funcionarios.id = tbl_tarefas.Funcionario " +
                                                              "Where tbl_tarefas.id = " + ID + ";");


                Empresa      = lista[0];
                Atribuicao   = lista[1];
                Status       = int.Parse(lista[2]) - 1;
                Assunto      = lista[3];
                dataCadastro = lista[4].Substring(0, 10);
                DataInicial  = lista[5].Substring(0, 10);
                if (lista[6] == "" || lista[6] == null)
                {
                    DataFinal = lista[5].Substring(0, 10);
                }
                else
                {
                    DataFinal = lista[6].Substring(0, 10);
                }

                Prioridade = int.Parse(lista[7]);
                Texto      = lista[8];
                titulo     = lista[0] + " - " + lista[3];
                Anexos     = Sistema.ConsultaAnexosTarefa(ID, "select nome from tbl_tarefa_anexos " +
                                                          "Where id = " + ID + ";");

                _empresa     = lista[0];
                _atribuicao  = lista[1];
                _status      = int.Parse(lista[2]) - 1;
                _assunto     = lista[3];
                _dataInicial = lista[5].Substring(0, 10);
                if (lista[6] == "" || lista[6] == null)
                {
                    _dataFinal = lista[5].Substring(0, 10);
                }
                else
                {
                    _dataFinal = lista[6].Substring(0, 10);
                }
                _prioridade = int.Parse(lista[7]);
                _texto      = lista[8];
                _anexos     = Anexos;
            }
        }
Exemple #23
0
        /// <summary>
        /// Método responsável por cadastrar o fornecedor
        /// </summary>
        public static void CadastrarFornecedor()
        {
            string comando = null, _dataCadastro = "", _dataNascimento = "";

            try
            {
                _dataCadastro = DataCadastro.Substring(6, 4) + "-" + DataCadastro.Substring(3, 2) + "-" + DataCadastro.Substring(0, 2);

                if (!string.IsNullOrEmpty(DataNascimento))
                {
                    if (DataNascimento.Length > 8)
                    {
                        _dataNascimento = DataNascimento.Substring(6, 4) + "-" + DataNascimento.Substring(3, 2) + "-" + DataNascimento.Substring(0, 2);
                    }
                    else
                    {
                        _dataNascimento = DataNascimento.Substring(4, 4) + "-" + DataNascimento.Substring(2, 2) + "-" + DataNascimento.Substring(0, 2);
                    }
                }

                comando = "insert into tbl_fornecedor values (0," + Tipo + ", '" + _dataCadastro + "',if('" + _dataNascimento + "' = '',NULL,'" + _dataNascimento + "'),'" + Documento + "','" + Nome + "','" + Apelido + "','" + CEP + "','"
                          + Endereco + "','" + Numero + "','" + Complemento + "','" + Bairro + "','" + Cidade + "','" + Estado + "','" + Pais + "','" + Telefone + "','" + Contato + "','"
                          + TelefoneComercial + "','" + ContatoComercial + "','" + Celular + "','" + ContatoCelular + "','" + Email + "','" + Site + "','" + InscricaoEstadual + "','" + InscricaoEstadual + "','"
                          + Obs + "','S'); ";
                Sistema.ExecutaComando(comando);
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(51);
                throw;
            }

            try
            {
                comando = "Select ID from tbl_fornecedor where Tipo = '" + Tipo + "'" +
                          " AND Nome = '" + Nome + "'" +
                          " AND datacadastro = '" + _dataCadastro + "';";

                ID = int.Parse(Sistema.ConsultaSimples(comando));
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(51);
                throw;
            }

            if (ID != 0)
            {
                //Backup
                _id                = ID;
                _tipo              = Tipo;
                _dataCadastro      = DataCadastro;
                _dataNascimento    = DataNascimento;
                _documento         = Documento;
                _nome              = Nome;
                _apelido           = Apelido;
                _cep               = CEP;
                _endereco          = Endereco;
                _numero            = Numero;
                _complemento       = Complemento;
                _bairro            = Bairro;
                _cidade            = Cidade;
                _estado            = Estado;
                _pais              = Pais;
                _telefone          = Telefone;
                _contato           = Contato;
                _telefoneComercial = TelefoneComercial;
                _contatoComercial  = ContatoComercial;
                _celular           = Celular;
                _contatoCelular    = ContatoCelular;
                _email             = Email;
                _site              = Site;
                _inscricaoEstadual = InscricaoEstadual;
                _inscricaoEstadual = InscricaoEstadual;
                _obs               = Obs;
            }
        }
Exemple #24
0
        public static bool CadastrarCliente()
        {
            bool resultado = false;

            try
            {
                string comando = string.Format("insert into tbl_contato values " +
                                               "(0,'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}');",
                                               DataCadastro, Nome, RazaoSocial, Telefone, Contato, Setor, CPF, RG, CNPJ, InscricaoEstadual, InscricaoMunicipal, Site, Email, Endereco + ", " + Numero, Bairro,
                                               Cidade, Estado, CEP, Complemento, PontoReferencia, Obs);
                Sistema.ExecutaComando(comando);

                comando = string.Format("Select id from tbl_contato where nome = '{0}';", Nome);
                ID      = Int32.Parse(Sistema.ConsultaSimples(comando));

                comando = string.Format("insert into tbl_contato_contrato values ({0},{1});", ID, Contrato);
                Sistema.ExecutaComando(comando);
            }
            catch (Exception)
            {
                ListaErro.RetornaErro(39);
                resultado = false;
            }
            finally
            {
                _nome              = Nome;
                _razaoSocial       = RazaoSocial;
                _telefoneComercial = Telefone;
                _contato           = Contato;
                _setor             = Setor;
                _dataCadastro      = DataCadastro;
                _email             = Email;
                _site              = Site;
                _obs  = Obs;
                _cpf  = CPF;
                _rg   = RG;
                _cnpj = CNPJ;
                _inscricaoMunicipal = InscricaoMunicipal;
                _inscricaoEstadual  = InscricaoEstadual;
                _cep = CEP;
                if (Endereco.Contains(","))
                {
                    _endereco = Endereco.Substring(0, Endereco.LastIndexOf(','));
                    _numero   = Endereco.Substring(Endereco.LastIndexOf(',') + 2, (Endereco.Length - (Endereco.LastIndexOf(',') + 2)));
                }
                else
                {
                    _endereco = Endereco;
                }
                _bairro          = Bairro;
                _cidade          = Cidade;
                _estado          = Estado;
                _complemento     = Complemento;
                _pontoReferencia = PontoReferencia;

                _contrato = Convert.ToInt32(Sistema.ConsultaSimples("select contrato from tbl_contato_contrato where contato = " + ID + ";")) - 1;

                Log.CadastrarCliente();
                resultado = true;
            }

            return(resultado);
        }