/// <summary> /// Verifica se a tarefa esta bloqueada /// </summary> public static bool TarefaBloqueada() { try { if (ID == 0) { return(false); } else { if (Sistema.ConsultaSimples("Select travar from tbl_tarefas where id = " + ID + ";") == "S") { return(true); } else { return(false); } } } catch (NullReferenceException) { return(false); } }
/// <summary> /// Método responsável por retornar o tipo de contrato do contato solicitado. /// </summary> /// <param name="nomeEmpresa">Nome da empresa</param> public static string ConsultaTipoContrato(string nomeEmpresa) { int idCliente = 0; string comando = null; comando = "Select ID from tbl_contato where nome = '" + nomeEmpresa + "';"; idCliente = int.Parse(Sistema.ConsultaSimples(comando)); comando = "Select contrato from tbl_contato_contrato where contato = " + idCliente + ";"; return(Sistema.ConsultaSimples(comando)); }
/// <summary> /// Método responsável por retornar se a tarefa esta bloqueada. /// </summary> /// <param name="idFornecedor">Qual a tarefa que deseja conferir.</param> public static bool FornecedorBloqueado() { string comando = "Select travar from tbl_fornecedor where ID = '" + ID + "';"; if (Sistema.ConsultaSimples(comando) == "S") { return(true); } else { return(false); } }
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; } }
/// <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); }
/// <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)); }
/// <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; } }
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); }
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); }
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; } }
/// <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; } }
/// <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); } } }
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); }