Example #1
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);
        }
Example #2
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;
            }
        }
Example #3
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);
        }
Example #4
0
        public static bool ApagarAnexos()
        {
            try
            {
                Sistema.ExecutaComando("delete from tbl_tarefa_anexos where tarefa = " + ID + ";");

                Directory.Delete(@"\\192.168.254.253\GerenciadorTarefas\Anexos\" + ID);
            }
            catch (Exception)
            {
                return(false);
            }

            tarefaApagada = true;
            return(true);
        }
Example #5
0
        /// <summary>
        /// Retorna a prioridade da tarefa solicitada
        /// </summary>
        public static string ConsultaPrioridade()
        {
            int    idEmpresa = 0, idFuncionario = 0, idTarefa = 0;
            string comando = null;

            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 + "';";
            idTarefa = int.Parse(Sistema.ConsultaSimples(comando));

            comando = "Select prioridade from tbl_tarefas where id = " + idTarefa + ";";
            return(Sistema.ConsultaSimples(comando));
        }
Example #6
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;
            }
        }
Example #7
0
        /// <summary>
        /// Apaga a tarefa
        /// </summary>
        /// <param name="tarefa">ID da tarefa que deseja apagar</param>
        public static bool ApagarTarefa()
        {
            try
            {
                string enderecoServidor = Encoding.UTF8.GetString(Convert.FromBase64String(Sistema.EnderecoServidor));

                Sistema.ExecutaComando("delete from tbl_tarefa_anexos where tarefa = " + ID + ";");
                Directory.Delete(@"\\" + enderecoServidor + @"\GerenciadorTarefas\Anexos\" + ID);

                Sistema.ExecutaComando("delete from tbl_tarefas where id = " + ID + ";");
            }
            catch (Exception)
            {
                tarefaApagada = false;
                return(false);
            }

            tarefaApagada = true;
            return(true);
        }
Example #8
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);
        }
Example #9
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;
            }
        }
Example #10
0
        /// <summary>
        /// Método responsável por carregar os dados do fornecedor selecionado
        /// </summary>
        /// <param name="_idFornecedor">ID do fornecedor</param>
        public static void AbrirFornecedor()
        {
            List <string> listaFornecedor = Sistema.ConsultaFornecedor("select Tipo, datacadastro, datanascimento, Documento, Nome, " +
                                                                       "Apelido, CEP, Endereco, Numero, Complemento, Bairro, Cidade, Estado, Pais, Telefone, Contato, Telefonecomercial, " +
                                                                       "Contatocomercial, Celular, ContatoCelular, Email, Site, inscricaoestadual, inscricaomunicipal, Observacoes " +
                                                                       "from tbl_fornecedor where ID = '" + ID + "';");

            try
            {
                Tipo         = int.Parse(listaFornecedor[0]);
                DataCadastro = listaFornecedor[1].Substring(0, 10);
                if (!string.IsNullOrEmpty(listaFornecedor[2]) && listaFornecedor[2] != "")
                {
                    DataNascimento = listaFornecedor[2].Substring(0, 10);
                }
                Documento          = listaFornecedor[3];
                Nome               = listaFornecedor[4];
                Apelido            = listaFornecedor[5];
                CEP                = listaFornecedor[6];
                Endereco           = listaFornecedor[7];
                Numero             = listaFornecedor[8];
                Complemento        = listaFornecedor[9];
                Bairro             = listaFornecedor[10];
                Cidade             = listaFornecedor[11];
                Estado             = listaFornecedor[12];
                Pais               = listaFornecedor[13];
                Telefone           = listaFornecedor[14];
                Contato            = listaFornecedor[15];
                TelefoneComercial  = listaFornecedor[16];
                ContatoComercial   = listaFornecedor[17];
                Celular            = listaFornecedor[18];
                ContatoCelular     = listaFornecedor[19];
                Email              = listaFornecedor[20];
                Site               = listaFornecedor[21];
                InscricaoEstadual  = listaFornecedor[22];
                InscricaoMunicipal = listaFornecedor[23];
                Obs                = listaFornecedor[24];

                //Backup
                _id           = ID;
                _tipo         = int.Parse(listaFornecedor[0]);
                _dataCadastro = listaFornecedor[1].Substring(0, 10);
                if (!string.IsNullOrEmpty(listaFornecedor[2]) && listaFornecedor[2] != "")
                {
                    _dataNascimento = listaFornecedor[2].Substring(0, 10);
                }

                _documento          = listaFornecedor[3];
                _nome               = listaFornecedor[4];
                _apelido            = listaFornecedor[5];
                _cep                = listaFornecedor[6];
                _endereco           = listaFornecedor[7];
                _numero             = listaFornecedor[8];
                _complemento        = listaFornecedor[9];
                _bairro             = listaFornecedor[10];
                _cidade             = listaFornecedor[11];
                _estado             = listaFornecedor[12];
                _pais               = listaFornecedor[13];
                _telefone           = listaFornecedor[14];
                _contato            = listaFornecedor[15];
                _telefoneComercial  = listaFornecedor[16];
                _contatoComercial   = listaFornecedor[17];
                _celular            = listaFornecedor[18];
                _contatoCelular     = listaFornecedor[19];
                _email              = listaFornecedor[20];
                _site               = listaFornecedor[21];
                _inscricaoEstadual  = listaFornecedor[22];
                _inscricaoMunicipal = listaFornecedor[23];
                _obs                = listaFornecedor[24];

                Log.AbrirFornecedor(ID);
            }
            catch (ArgumentOutOfRangeException x)
            {
                MessageBox.Show(x.ToString());
                throw;
            }
        }
Example #11
0
        public static List <string> DadosImpressao()
        {
            List <string> lista = new List <string>
            {
                "ID: " + ID
            };

            if (!string.IsNullOrEmpty(CNPJ))
            {
                // 1
                if (!string.IsNullOrEmpty(RazaoSocial))
                {
                    lista.Add("Razão Social: " + RazaoSocial);
                }
                else
                {
                    lista.Add("");
                }
                // 2
                lista.Add("Nome Fantasia: " + Nome);
                // 3
                if (CNPJ.Contains(".") && CNPJ.Contains("/") && CNPJ.Contains("-"))
                {
                    lista.Add("CNPJ: " + CNPJ);
                }
                else
                {
                    lista.Add("CNPJ: " + CNPJ.FormataCNPJ());
                }
            }
            else if (!string.IsNullOrEmpty(CPF))
            {
                // 1
                lista.Add("Nome: " + Nome);
                // 2
                lista.Add("RG: " + RG);
                // 3
                if (CPF.Contains(".") && CPF.Contains("-"))
                {
                    lista.Add("CPF: " + CPF);
                }
                else
                {
                    lista.Add("CPF: " + CPF.FormataCPF());
                }
            }
            else
            {
                // 1
                lista.Add("Nome: " + Nome);
                // 2
                lista.Add("");
                // 3
                lista.Add("");
            }
            //4
            string consulta = "Select nome from tbl_contrato where id = " + (Contrato + 1).ToString() + ";";

            lista.Add("Tipo de cliente: " + Sistema.ConsultaSimples(consulta));
            //5
            if (DataCadastro.Contains("/"))
            {
                lista.Add("Cadastrado em: " + DataCadastro);
            }
            else
            {
                lista.Add("Cadastrado em: " + DataCadastro.FormataData());
            }
            // 6
            string textoEndereco = "Endereço: ";

            if (!string.IsNullOrEmpty(Endereco))
            {
                textoEndereco += Endereco;
            }
            if (!string.IsNullOrEmpty(Numero))
            {
                textoEndereco += ", " + Numero;
            }
            if (!string.IsNullOrEmpty(Bairro))
            {
                textoEndereco += " - " + Bairro;
            }
            if (!string.IsNullOrEmpty(Cidade))
            {
                textoEndereco += " - " + Cidade;
            }
            if (!string.IsNullOrEmpty(Estado))
            {
                textoEndereco += " / " + Estado;
            }
            if (!string.IsNullOrEmpty(CEP))
            {
                if (CEP.Contains("-"))
                {
                    textoEndereco += " - " + CEP;
                }
                else
                {
                    textoEndereco += " - " + CEP.FormataCEP();
                }
            }
            if (!string.IsNullOrEmpty(PontoReferencia))
            {
                textoEndereco += ", " + PontoReferencia;
            }
            lista.Add(textoEndereco);

            // 7
            if (!string.IsNullOrEmpty(Telefone) && !string.IsNullOrEmpty(Contato))
            {
                if (Telefone.Length > 11)
                {
                    lista.Add(Telefone.FormataNumeroCelular() + " - " + Contato);
                }
                else
                {
                    lista.Add(Telefone.FormataNumeroTelefone() + " - " + Contato);
                }
            }
            else if (!string.IsNullOrEmpty(Telefone) && string.IsNullOrEmpty(Contato))
            {
                if (Telefone.Length > 11)
                {
                    lista.Add(Telefone.FormataNumeroCelular());
                }
                else
                {
                    lista.Add(Telefone.FormataNumeroTelefone());
                }
            }
            else if (string.IsNullOrEmpty(Telefone) && !string.IsNullOrEmpty(Contato))
            {
                lista.Add("Contato Principal:" + Contato);
            }
            else
            {
                lista.Add("");
            }

            // 8
            if (!string.IsNullOrEmpty(Setor))
            {
                lista.Add("Setor: " + Setor);
            }
            else
            {
                lista.Add("");
            }

            // 9
            if (!string.IsNullOrEmpty(Email))
            {
                lista.Add("E-mail Principal: " + Email);
            }
            else
            {
                lista.Add("");
            }

            // 10
            lista.Add("");
            // 11
            lista.Add("Site: " + Site);
            // 12
            lista.Add("Inscrição Estadual: " + InscricaoEstadual);

            return(lista);
        }
Example #12
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);
        }
Example #13
0
        /// <summary>
        /// Método responsável por atualizar a tabela da tela inicial
        /// </summary>
        ///
        public static bool AtualizaDGVClientes(int posicaoCmbFiltroClientes)
        {
            if (Sistema.TestaConexao())
            {
                string comando = "";

                switch (posicaoCmbFiltroClientes)
                {
                case 0:
                    comando = "select tbl_contato.Nome, tbl_contato.Contato, tbl_contato.Telefone, tbl_contato.email as 'E-mail', tbl_contato_contrato.contrato " +
                              "from tbl_contato " +
                              "join tbl_contato_contrato on tbl_contato_contrato.Contato = tbl_contato.id " +
                              "where tbl_contato_contrato.Contrato = 3;";
                    break;

                case 1:
                    comando = "select tbl_contato.Nome, tbl_contato.Contato, tbl_contato.Telefone, tbl_contato.email as 'E-mail', tbl_contato_contrato.contrato " +
                              "from tbl_contato " +
                              "join tbl_contato_contrato on tbl_contato_contrato.Contato = tbl_contato.id " +
                              "where tbl_contato_contrato.Contrato = 2 OR tbl_contato_contrato.Contrato = 3 OR tbl_contato_contrato.Contrato = 4;";
                    break;

                case 2:
                    comando = "select tbl_contato.Nome, tbl_contato.Contato, tbl_contato.Telefone, tbl_contato.email as 'E-mail', tbl_contato_contrato.contrato " +
                              "from tbl_contato " +
                              "join tbl_contato_contrato on tbl_contato_contrato.Contato = tbl_contato.id " +
                              "where tbl_contato_contrato.Contrato = 2;";
                    break;

                case 3:
                    comando = "select tbl_contato.Nome, tbl_contato.Contato, tbl_contato.Telefone, tbl_contato.email as 'E-mail', tbl_contato_contrato.contrato " +
                              "from tbl_contato " +
                              "join tbl_contato_contrato on tbl_contato_contrato.Contato = tbl_contato.id " +
                              "where tbl_contato_contrato.Contrato = 1;";
                    break;

                default:
                    comando = "select tbl_contato.Nome, tbl_contato.Contato, tbl_contato.Telefone, tbl_contato.email as 'E-mail', tbl_contato_contrato.contrato " +
                              "from tbl_contato " +
                              "join tbl_contato_contrato on tbl_contato_contrato.Contato = tbl_contato.id " +
                              "order by tbl_contato.Nome ASC;";
                    break;
                }

                if (Sistema.IniciaTelaClientes)
                {
                    _dgvClientesAtual.DataSource     = Sistema.PreencheDGV(comando);
                    dgvClientesAtualizada.DataSource = _dgvClientesAtual.DataSource;

                    Sistema.IniciaTelaClientes = false;

                    return(true);
                }
                else
                {
                    DataGridView _dgvTemp = new DataGridView
                    {
                        // Atualiza a tabela atual temporária
                        DataSource = Sistema.PreencheDGV(comando)
                    };

                    // Se a tabela atualizada for diferente da tabela anterior
                    if (_dgvClientesAtual != _dgvTemp)
                    {
                        dgvClientesAtualizada.DataSource = _dgvTemp.DataSource;
                        _dgvClientesAtual = _dgvTemp;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(false);
            }
        }
Example #14
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;
            }
        }
Example #15
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);
                }
            }
        }
Example #16
0
        /// <summary>
        ///Atualiza a tabela de tarefas
        /// </summary>
        public static bool AtualizaDGVTarefas(int posicaoCmbFiltroTarefas)
        {
            if (Sistema.TestaConexao())
            {
                string comando = "";

                switch (posicaoCmbFiltroTarefas)
                {
                case 0:
                    comando = "select tbl_contato.ID, tbl_contato.Nome AS `Empresa`, tbl_funcionarios.Nome AS 'Atribuido a', tbl_tarefas.Assunto, tbl_status.`Status`, tbl_tarefas.DataFinal AS 'Data Conclusão', tbl_tarefas.prioridade " +
                              "from tbl_tarefas " +
                              "Join tbl_contato on tbl_contato.ID = tbl_tarefas.empresa " +
                              "Join tbl_funcionarios on tbl_funcionarios.id = tbl_tarefas.Funcionario " +
                              "Join tbl_status on tbl_status.id = tbl_tarefas.`Status` " +
                              "Where tbl_tarefas.`Status` = 1 OR tbl_tarefas.`Status` = 2 OR tbl_tarefas.`Status` = 3 OR tbl_tarefas.`Status` = 4 " +
                              "order by tbl_tarefas.id desc;";
                    break;

                case 1:
                    comando = "select tbl_contato.ID, tbl_contato.Nome AS `Empresa`, tbl_funcionarios.Nome AS 'Atribuido a', tbl_tarefas.Assunto, tbl_status.`Status`, tbl_tarefas.DataFinal AS 'Data Conclusão', tbl_tarefas.prioridade " +
                              "from tbl_tarefas " +
                              "Join tbl_contato on tbl_contato.ID = tbl_tarefas.empresa " +
                              "Join tbl_funcionarios on tbl_funcionarios.id = tbl_tarefas.Funcionario " +
                              "Join tbl_status on tbl_status.id = tbl_tarefas.`Status` " +
                              "Where tbl_tarefas.`Status` = 5 " +
                              "order by tbl_tarefas.id desc;";
                    break;

                case 2:
                    comando = "select tbl_contato.ID, tbl_contato.Nome AS `Empresa`, tbl_funcionarios.Nome AS 'Atribuido a', tbl_tarefas.Assunto, tbl_status.`Status`, tbl_tarefas.DataFinal AS 'Data Conclusão', tbl_tarefas.prioridade " +
                              "from tbl_tarefas " +
                              "Join tbl_contato on tbl_contato.ID = tbl_tarefas.empresa " +
                              "Join tbl_funcionarios on tbl_funcionarios.id = tbl_tarefas.Funcionario " +
                              "Join tbl_status on tbl_status.id = tbl_tarefas.`Status` " +
                              "order by tbl_tarefas.id desc;";
                    break;
                }


                if (Sistema.IniciaTelaTarefas)
                {
                    // Atualiza a tabela tarefas pendentes
                    _dgvTarefasAtual.DataSource     = Sistema.PreencheDGV(comando);
                    dgvTarefasAtualizada.DataSource = _dgvTarefasAtual.DataSource;

                    return(true);
                }
                else
                {
                    DataGridView _dgvTemp = new DataGridView()
                    {
                        //Atualiza a tabela atual temporária
                        DataSource = Sistema.PreencheDGV(comando)
                    };

                    //Se a tabela atualizada for diferente da tabela anterior
                    if (_dgvTarefasAtual != _dgvTemp)
                    {
                        dgvTarefasAtualizada.DataSource = _dgvTemp.DataSource;
                        _dgvTarefasAtual.DataSource     = _dgvTemp.DataSource;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(false);
            }
        }
Example #17
0
        public static void AbrirCliente()
        {
            LimparVariaveis();

            List <string> lista = new List <string>();

            try
            {
                //Carrega os dados
                lista = Sistema.ConsultaContato("select nome, razaosocial, telefone, contato, setor, datacadastro, email, site, obs, cpf, "
                                                + "rg, cnpj, inscricaomunicipal, inscricaoestadual, cep, endereco, bairro, cidade, "
                                                + "estado, complemento, pontoreferencia "
                                                + "from tbl_contato where id = " + ID + ";");

                //Originais
                Nome               = lista[0];
                RazaoSocial        = lista[1];
                Telefone           = lista[2];
                Contato            = lista[3];
                Setor              = lista[4];
                DataCadastro       = lista[5];
                Email              = lista[6];
                Site               = lista[7];
                Obs                = lista[8];
                CPF                = lista[9];
                RG                 = lista[10];
                CNPJ               = lista[11];
                InscricaoMunicipal = lista[12];
                InscricaoEstadual  = lista[13];
                CEP                = lista[14];
                if (lista[15].Contains(","))
                {
                    Endereco = lista[15].Substring(0, lista[15].LastIndexOf(','));
                    Numero   = lista[15].Substring(lista[15].LastIndexOf(',') + 2, (lista[15].Length - (lista[15].LastIndexOf(',') + 2)));
                }
                else
                {
                    Endereco = lista[15];
                }
                Bairro          = lista[16];
                Cidade          = lista[17];
                Estado          = lista[18];
                Complemento     = lista[19];
                PontoReferencia = lista[20];

                Contrato      = Convert.ToInt32(Sistema.ConsultaSimples("select contrato from tbl_contato_contrato where contato = " + ID + ";")) - 1;
                numeroTarefas = Sistema.ConsultaSimples("select count(id) from tbl_tarefas where empresa = " + ID + ";");

                //Backup
                _nome              = lista[0];
                _razaoSocial       = lista[1];
                _telefoneComercial = lista[2];
                _contato           = lista[3];
                _setor             = lista[4];
                _dataCadastro      = lista[5];
                _email             = lista[6];
                _site              = lista[7];
                _obs  = lista[8];
                _cpf  = lista[9];
                _rg   = lista[10];
                _cnpj = lista[11];
                _inscricaoMunicipal = lista[12];
                _inscricaoEstadual  = lista[13];
                _cep = lista[14];
                if (lista[15].Contains(","))
                {
                    _endereco = lista[15].Substring(0, lista[15].LastIndexOf(','));
                    _numero   = lista[15].Substring(lista[15].LastIndexOf(',') + 2, (lista[15].Length - (lista[15].LastIndexOf(',') + 2)));
                }
                else
                {
                    _endereco = lista[15];
                }
                _bairro          = lista[16];
                _cidade          = lista[17];
                _estado          = lista[18];
                _complemento     = lista[19];
                _pontoReferencia = lista[20];

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

                Log.AbrirCliente();
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #18
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);
        }