Пример #1
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);
            }
        }
Пример #2
0
 /// <summary>
 /// Destrava a tarefa selecionada
 /// </summary>
 public static void DestravaTarefa()
 {
     if (TarefaBloqueada())
     {
         Sistema.ExecutaComando("Update tbl_tarefas set travar = 'N' where id = " + ID + ";");
     }
 }
Пример #3
0
        public static void AbrirFornecedor(int fornecedor)
        {
            string comando = "Insert into tbl_log values (0," + Sistema.IDUsuarioLogado + ", 'Abriu o fornecedor ID: " + fornecedor + " - " +
                             DateTime.Now.ToShortDateString() + " às " + DateTime.Now.ToShortTimeString() + "');";

            Sistema.ExecutaComando(comando);
        }
Пример #4
0
 /// <summary>
 /// Método responsável por destravar o fornecedor
 /// </summary>
 /// <returns></returns>
 public static void DestravaFornecedor()
 {
     if (FornecedorBloqueado())
     {
         Sistema.ExecutaComando("Update tbl_fornecedor set travar = 'N' where ID = '" + ID.ToString() + "';");
     }
 }
Пример #5
0
        public static void ApagarCliente()
        {
            string comando = "Insert into tbl_log values (0," + Sistema.IDUsuarioLogado + ", 'Apagou o cliente ID: " + Cliente.ID + " - " +
                             DateTime.Now.ToShortDateString() + " às " + DateTime.Now.ToShortTimeString() + "');";

            Sistema.ExecutaComando(comando);
        }
Пример #6
0
        public static void AlterarDadosConexao()
        {
            string comando = "Insert into tbl_log values (0," + Sistema.IDUsuarioLogado + ", 'Alterou as informações de conexão SQL - " +
                             DateTime.Now.ToShortDateString() + " às " + DateTime.Now.ToShortTimeString() + "');";

            Sistema.ExecutaComando(comando);
        }
Пример #7
0
        public static void AbrirTarefa(int tarefa)
        {
            string comando = "Insert into tbl_log values (0," + Sistema.IDUsuarioLogado + ", 'Abriu a Tarefa ID: " + tarefa + " - " +
                             DateTime.Now.ToShortDateString() + " às " + DateTime.Now.ToShortTimeString() + "');";

            Sistema.ExecutaComando(comando);
        }
Пример #8
0
        /// <summary>
        /// Cria um log do logoff do usuário
        /// </summary>
        public static void Logoff()
        {
            string comando = "Insert into tbl_log values (0," + Sistema.IDUsuarioLogado + ", 'Logoff efetuado - " +
                             DateTime.Now.ToShortDateString() + " às " + DateTime.Now.ToShortTimeString() + "');";

            Sistema.ExecutaComando(comando);
        }
Пример #9
0
        /// <summary>
        /// Método responsável por travar o fornecedor
        /// </summary>
        /// <param name="_idFornecedor">ID da tarefa que deseja travar</param>
        /// <returns></returns>
        public static bool TravaFornecedor()
        {
            bool resultado = false;

            if (!FornecedorBloqueado())
            {
                Sistema.ExecutaComando("Update tbl_fornecedor set travar = 'S' where ID = '" + ID.ToString() + "';");
                resultado = true;
            }

            return(resultado);
        }
Пример #10
0
        /// <summary>
        /// Trava a tarefa
        /// </summary>
        public static bool TravaTarefa()
        {
            bool resultado = false;

            if (!TarefaBloqueada())
            {
                Sistema.ExecutaComando("Update tbl_tarefas set travar = 'S' where id = " + ID + ";");
                resultado = true;
            }

            return(resultado);
        }
Пример #11
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;
     }
 }
Пример #12
0
        public static void ApagarCliente()
        {
            Sistema.ExecutaComando("delete from tbl_tarefas where empresa = " + ID + ";");
            Sistema.ExecutaComando("delete from tbl_contato_subsubgrupo where contato = " + ID + ";");
            Sistema.ExecutaComando("delete from tbl_contato_subgrupo where contato = " + ID + ";");
            Sistema.ExecutaComando("delete from tbl_contato_telefone where contato = " + ID + ";");
            Sistema.ExecutaComando("delete from tbl_contato_contrato where contato = " + ID + ";");
            Sistema.ExecutaComando("delete from tbl_contato where id = " + ID + ";");

            Log.ApagarCliente();

            LimparVariaveis();
        }
Пример #13
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);
        }
Пример #14
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);
        }
Пример #15
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);
        }
Пример #16
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;
            }
        }
Пример #17
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);
        }
Пример #18
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);
        }
Пример #19
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);
        }
Пример #20
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);
        }
Пример #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);
                }
            }
        }
Пример #22
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;
            }
        }