// protected void ReadData() { try { string comando = "SELECT Codigo, NomeCompleto, Login, Anotacoes FROM Usuarios ORDER BY Codigo"; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; DataTable dt = new DataTable(); dt = (DataTable)db.Query(comando); //copia os dados de dt para datasource do gridview Usuarios.DataSource = dt; Usuarios.DataBind(); dt.Dispose(); Codigo.Text = ""; NomeCompleto.Text = ""; Login.Text = ""; Senha.Text = ""; Anotacoes.Text = ""; } catch (Exception ex) { Mensagem.Text = $"Houve uma falha inesperada no registro dos dados: {ex.Message} "; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
void RecuperarDados() { try { string comando = "SELECT Codigo,Nome,Descricao,Data_Agendamento AS Data,Hora_Agendamento AS Hora FROM Pedido WHERE Status='Agendado' ORDER BY Data_Agendamento,Hora_Agendamento DESC"; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; System.Data.DataTable tb = new System.Data.DataTable(); tb = (System.Data.DataTable)db.Query(comando); Pedido.DataSource = tb; Pedido.DataBind(); Pedido.Dispose(); ControleCotacao.Visible = false; this.Master.MasterForm = false; Limpar.Visible = false; } catch (Exception ex) { Erro.Text = "Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
/*protected void DashboardData() * { * try * { * string comando = "SELECT COUNT (Codigo) FROM Pedido"; * * AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); * db.ConnectionString = conexao; * System.Data.DataTable tb = new System.Data.DataTable(); * tb = (System.Data.DataTable)db.Query(comando); * * CotFeitas.Text = tb.Rows[0][0].ToString(); * //Aguardando.Text = tb.Rows[1][0].ToString(); * //CotNaoFeitas.Text = tb.Rows[0][2].ToString(); * * * } * catch (Exception ex) * { * RecoverExceptions re = new RecoverExceptions(); * re.SaveException(ex); * Erro.Text = "Houve uma falha inesperada"; * } * }*/ protected void Ordenar_SelectedIndexChanged(object sender, EventArgs e) { try { string Comando = string.Empty; if (Ordenar.SelectedIndex == 0) { Pedido.DataSource = null; Pedido.DataBind(); Pedido.Dispose(); } else if (Ordenar.SelectedIndex == 1) { Comando = "SELECT Codigo,Nome,Descricao FROM Pedido WHERE Status='Cotacao Finalizada' ORDER BY Atual_Status ASC"; RecuperarDados(Comando); } else if (Ordenar.SelectedIndex == 2) { Comando = "SELECT Codigo,Nome,Descricao FROM Pedido WHERE Status='Calote' ORDER BY Atual_Status ASC"; RecuperarDados(Comando); } else { Comando = "SELECT Codigo,Nome,Descricao FROM Pedido WHERE Status='Cartorio Protocolado' ORDER BY Atual_Status ASC"; RecuperarDados(Comando); } } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Erro.Text = "Houve uma falha inesperada"; } }
protected void RecuperarDados() { try { string comando = "SELECT Codigo,Nome,Descricao,Atual_Status FROM Pedido WHERE Status='Aguardando Nota' ORDER BY Atual_Status ASC"; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; System.Data.DataTable tb = new System.Data.DataTable(); tb = (System.Data.DataTable)db.Query(comando); Pedido.DataSource = tb; Pedido.DataBind(); Pedido.Dispose(); Pergunta.Visible = false; ControleCotacao.Visible = false; Aviso.Visible = false; this.Master.MasterForm = false; Limpar.Visible = false; } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Erro.Text = "Houve uma falha inesperada."; } }
//BOTAO SELECT protected void Usuarios_SelectedIndexChanged(object sender, EventArgs e) { try { Codigo.Text = Usuarios.SelectedRow.Cells[1].Text; string comando = "SELECT * FROM Usuarios WHERE Codigo=" + Codigo.Text; OleDBTransaction db = new OleDBTransaction(); db.ConnectionString = conexao; DataTable tb = (DataTable)db.Query(comando); if (tb.Rows.Count == 1) { NomeCompleto.Text = tb.Rows[0]["NomeCompleto"].ToString(); Login.Text = tb.Rows[0]["Login"].ToString(); Senha.Text = tb.Rows[0]["Senha"].ToString(); Anotacoes.Text = tb.Rows[0]["Anotacoes"].ToString(); Excluir.Visible = true; } } catch (Exception ex) { Mensagem.Text = $"Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
void RecuperarDados() { try { string comando = "SELECT Codigo,Nome,Descricao,Data_Pagamento AS Data FROM Pedido WHERE Status='Aguardando Pagamento' ORDER BY Data_Pagamento ASC"; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; System.Data.DataTable tb = new System.Data.DataTable(); tb = (System.Data.DataTable)db.Query(comando); Pedido.DataSource = tb; Pedido.DataBind(); Pedido.Dispose(); ControleCotacao.Visible = false; this.Master.MasterForm = false; Pergunta.Visible = false; Valor.Text = ""; Valor.Visible = false; Salvar.Visible = false; Sim.Visible = true; Nao.Visible = true; } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Erro.Text = "Houve uma falha inesperada."; } }
protected void ExcluirCot_Click(object sender, EventArgs e) { if (MotivoSelect.SelectedIndex == 0) { ErroMotivo.Text = "Informe o motivo"; } else { try { TimeSpan ts = new TimeSpan(3, 0, 0); string comando = "INSERT INTO CotNaoAceitas(Motivo,Razao,Data) VALUES('" + MotivoSelect.SelectedIndex.ToString() + "','" + "Cotacao recusada" + "','" + DateTime.UtcNow.Subtract(ts).ToString() + "');"; string commando = "DELETE * FROM Pedido WHERE Codigo=" + Codigo.Text + ";"; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); db.Query(commando); Erro.Text = "Operação feita com sucesso"; RecuperarDados(); } catch (Exception ex) { Codigo.Text = "Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } } }
protected void Funcionarios_SelectedIndexChanged(object sender, EventArgs e) { try { Codigo.Text = Funcionarios.SelectedRow.Cells[1].Text; string comando = "SELECT * FROM Funcionarios WHERE Codigo=" + Codigo.Text; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; System.Data.DataTable tb = (System.Data.DataTable)db.Query(comando); if (tb.Rows.Count == 1) { Nome.Text = tb.Rows[0]["Nome"].ToString(); Login.Text = tb.Rows[0]["Login"].ToString(); Senha.Text = tb.Rows[0]["Senha"].ToString(); Anotacoes.Text = tb.Rows[0]["Anotacoes"].ToString(); Excluir.Visible = true; Limpar.Visible = true; codfunc.Visible = true; } } catch (Exception ex) { Codigo.Text = "Houve uma falha"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Agendar_Click(object sender, EventArgs e) { try { if (DataAgendamento.Text.Trim() == "" || HoraAgendamento.Text.Trim() == "") { ErroAgendamento.InnerText = "Preencha corretamente os campos"; } else { TimeSpan ts = new TimeSpan(3, 0, 0); string comando = "UPDATE Pedido SET Status=" + "'Agendado'" + ",Atual_Status='" + DateTime.UtcNow.Subtract(ts).ToString() + "',Data_Agendamento='" + DataAgendamento.Text + "',Hora_Agendamento='" + HoraAgendamento.Text + "' WHERE Codigo=" + Codigo.Text; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); Erro.Text = "Coleta Agendada com sucesso"; RecuperarDados(); } } catch (Exception ex) { Erro.Text = "Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Enviar_Click(object sender, EventArgs e) { try { if (Boleto.Text.Trim() == "") { Aviso.Visible = true; } else { TimeSpan ts = new TimeSpan(3, 0, 0); string comando = "UPDATE Pedido SET Status='Aguardando Pagamento',Atual_Status='" + DateTime.UtcNow.Subtract(ts).ToString() + "',Boleto='" + Boleto.Text + "' WHERE Codigo=" + Codigo.Text; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); Erro.Text = "Número de boleto enviado com sucesso."; RecuperarDados(); } } catch (Exception ex) { Erro.Text = "Houve uma falha inesperada."; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void RecuperarDados() { try { string comando = "SELECT Codigo, Nome, Descricao,Data FROM Pedido WHERE Status='Aguardando Cotacao' ORDER BY Codigo ASC"; //DATATABLE System.Data.DataTable tb = new System.Data.DataTable(); //CONEXAO AO BANCO DE DADOS, ENVIO DOS COMANDOS SQL AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; tb = (System.Data.DataTable)db.Query(comando); Pedido.DataSource = tb; Pedido.DataBind(); tb.Dispose(); Pesquisa.Text = ""; Limpar.Visible = false; Limpar_Busca.Visible = false; Responder.Visible = false; EnviarMsg.Visible = false; editor.Visible = false; ControleCotacao.Visible = false; this.Master.MasterForm = false; } catch (Exception ex) { Erro.Text = "Houve um erro ao carregar os pedidos"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void RecuperarDados() { try { string comando = "SELECT * FROM Funcionarios ORDER BY Nome ASC"; System.Data.DataTable tb = new System.Data.DataTable(); AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; tb = (System.Data.DataTable)db.Query(comando); Funcionarios.DataSource = tb; Funcionarios.DataBind(); Funcionarios.Dispose(); Codigo.Text = ""; Nome.Text = ""; Login.Text = ""; Senha.Text = ""; Anotacoes.Text = ""; Excluir.Visible = false; Limpar.Visible = false; codfunc.Visible = false; Mensagem.Text = ""; } catch (Exception ex) { Mensagem.Text = "Houve uma falha inesperada. Por Favor, tente novamente mais tarde"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Buscar_Click(object sender, EventArgs e) { try { Erro.Text = ""; if (Pesquisa.Text.Trim() == "") { Erro.Text = "Insira um valor no campo pesquisa"; } else { string comando = "SELECT Codigo,Nome,Descricao FROM Pedido WHERE Status='Aguardando Cotacao' AND Nome + Descricao LIKE '%" + Pesquisa.Text + "%'"; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; System.Data.DataTable tb = new System.Data.DataTable(); tb = (System.Data.DataTable)db.Query(comando); Pedido.DataSource = tb; Pedido.DataBind(); Pedido.Dispose(); Limpar_Busca.Visible = true; } } catch (Exception ex) { Erro.Text = "Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Pedido_SelectedIndexChanged(object sender, EventArgs e) { try { Codigo.Text = Pedido.SelectedRow.Cells[1].Text; this.Master.Codigo = Codigo.Text.ToString(); string comando = "SELECT * FROM Pedido WHERE Codigo=" + Codigo.Text; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; System.Data.DataTable tb = new System.Data.DataTable(); tb = (System.Data.DataTable)db.Query(comando); CodCot.Text = "Código da cotação: "; Nome.Text = "Nome do Cliente: "; Data.Text = "Data do Pedido: "; Status.Text = "Status do Pedido: "; AtualStatus.Text = "Data de atualização do status: "; if (tb.Rows.Count == 1) { Nome.Text += tb.Rows[0]["Nome"].ToString(); Data.Text += tb.Rows[0]["Data"].ToString(); Status.Text += tb.Rows[0]["Status"].ToString(); AtualStatus.Text += tb.Rows[0]["Atual_Status"].ToString(); this.Master.MasterObservacao = tb.Rows[0]["Observacao"].ToString(); this.Master.MasterNome = tb.Rows[0]["Nome"].ToString(); this.Master.MasterEmail = tb.Rows[0]["Email"].ToString(); this.Master.MasterTelefone = tb.Rows[0]["Telefone"].ToString(); this.Master.MasterComprimento = tb.Rows[0]["Comprimento"].ToString(); this.Master.MasterLargura = tb.Rows[0]["Largura"].ToString(); this.Master.MasterAltura = tb.Rows[0]["Altura"].ToString(); this.Master.MasterPeso = tb.Rows[0]["Peso"].ToString(); this.Master.MasterDescricao = tb.Rows[0]["Descricao"].ToString(); this.Master.MasterCepColeta = tb.Rows[0]["CEP_Coleta"].ToString(); this.Master.MasterCidadeColeta = tb.Rows[0]["Cidade_Coleta"].ToString(); this.Master.MasterRuaColeta = tb.Rows[0]["Rua_Coleta"].ToString(); this.Master.MasterNumeroColeta = tb.Rows[0]["Numero_Coleta"].ToString(); this.Master.MasterBairroColeta = tb.Rows[0]["Bairro_Coleta"].ToString(); this.Master.MasterEstadoColeta = tb.Rows[0]["Estado_Coleta"].ToString(); this.Master.MasterCepEntrega = tb.Rows[0]["CEP_Entrega"].ToString(); this.Master.MasterCidadeEntrega = tb.Rows[0]["Cidade_Entrega"].ToString(); this.Master.MasterRuaEntrega = tb.Rows[0]["Rua_Entrega"].ToString(); this.Master.MasterNumeroEntrega = tb.Rows[0]["Numero_Entrega"].ToString(); this.Master.MasterBairroEntrega = tb.Rows[0]["Bairro_Entrega"].ToString(); this.Master.MasterEstadoEntrega = tb.Rows[0]["Estado_Entrega"].ToString(); this.Master.MasterForm = true; ControleCotacao.Visible = true; Pergunta.Visible = true; Limpar.Visible = true; } } catch (Exception ex) { Erro.Text = "Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Enviar_Click(object sender, EventArgs e) { try { if (NovaDataPagamento.Text.Length < 10 && NotaFiscal.Text.Trim() == "") { Aviso.Visible = true; } else { TimeSpan ts = new TimeSpan(3, 0, 0); AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; string comando = "UPDATE Pedido SET Status='Agendar Pagamento', Atual_Status='" + DateTime.UtcNow.Subtract(ts).ToString() + "', Nota_Fiscal='" + NotaFiscal.Text + "', Data_Pagamento='" + NovaDataPagamento.Text + "' WHERE Codigo=" + Codigo.Text; db.Query(comando); Erro.Text = "Nota salva com sucesso"; RecuperarDados(); } } catch (Exception ex) { Erro.Text = "Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Enviar_Click(object sender, EventArgs e) { try { if (NomeLogin.Text.Trim() == "") { Mensagem.Text = "Preencha o campo Login"; } else if (Senha.Text.Trim() == "") { Mensagem.Text = "Preencha o campo Senha"; } else { string comando = "SELECT * FROM Funcionarios WHERE Login='******'AND Senha='" + Senha.Text + "';"; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; System.Data.DataTable tb = (System.Data.DataTable)db.Query(comando); if (tb.Rows.Count == 1) { Session["Codigo"] = tb.Rows[0]["Codigo"].ToString(); Session["Nome"] = tb.Rows[0]["Nome"].ToString(); // AUTENTICAÇÃO DE USUARIO FormsAuthentication.Initialize(); //Define os dados do ticket de autenticação FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, Session["Nome"].ToString(), DateTime.Now, DateTime.Now.AddMinutes(30), false, Session["Nome"].ToString(), FormsAuthentication.FormsCookiePath); // Grava o ticket no cookie de autenticação Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket))); // redirecionar para a Dasboard Response.Redirect("~/Pages/Admin/Dashboard.aspx"); } else { Mensagem.Text = "Dados Inválidos"; } } } catch (ThreadAbortException) { // IGNORE: this is normal behavior for Redirect method } catch (Exception ex) { Mensagem.Text = "Houve uma falha inesperada. Por Favor, tente novamente mais tarde"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Salvar_Click(object sender, EventArgs e) { try { if (NomeCompleto.Text.Trim() == "") { Mensagem.Text = "O nome deve ser digitado"; } else if (Login.Text.Trim() == "") { Mensagem.Text = "O nome de login ser digitado"; } else if (EsteLoginExiste(Login.Text.Trim())) { Mensagem.Text = "Este nome de login já existe, tente outro."; } else if (Senha.Text.Trim() == "") { Mensagem.Text = "A senha deve ser digitada"; } else { string comando = ""; if (Codigo.Text == "") { comando = $"INSERT INTO Usuarios(NomeCompleto, Login, Senha, Anotacoes)" + $" Values('{NomeCompleto.Text}', '{Login.Text}', '{Senha.Text}', '{Anotacoes.Text}');"; } else { comando = $"UPDATE Usuarios SET NomeCompleto='{NomeCompleto.Text}', Login='******', Senha='{Senha.Text}', Anotacoes='{Anotacoes.Text}' WHERE CODIGO={Codigo.Text}"; } //3.Conectar ao banco e enviar o comando sql AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); ReadData(); } } catch (Exception ex) { Mensagem.Text = $"Houve uma falha inesperada no registro dos dados: {ex.Message} "; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Salvar_Click(object sender, EventArgs e) { try { AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; TimeSpan ts = new TimeSpan(3, 0, 0); string comando = string.Empty; if (MotivoList.SelectedIndex == 1) { comando = "UPDATE Pedido SET Status='Aguardando Nota',Atual_Status='" + DateTime.UtcNow.Subtract(ts).ToString() + "' WHERE Codigo=" + Codigo.Text; db.Query(comando); RecuperarDados(); Erro.Text = "Coleta voltou para emissão de nota."; } else if (Valor.Text.Trim() == "") { Aviso.Visible = true; } else if (MotivoList.SelectedIndex == 2) { comando = "UPDATE Pedido SET Status='Calote',Atual_Status='" + DateTime.UtcNow.Subtract(ts).ToString() + "',Valor='" + Valor.Text + "' WHERE Codigo=" + Codigo.Text; db.Query(comando); RecuperarDados(); Erro.Text = "Coleta perdoada."; } else if (MotivoList.SelectedIndex == 3) { comando = "UPDATE Pedido SET Status='Cartorio',Atual_Status='" + DateTime.UtcNow.Subtract(ts).ToString() + "',Valor='" + Valor.Text + "' WHERE Codigo=" + Codigo.Text; db.Query(comando); RecuperarDados(); Erro.Text = "Coleta movida para cartório."; } else { comando = "UPDATE Pedido SET Status='Coleta Finalizada',Atual_Status='" + DateTime.UtcNow.Subtract(ts).ToString() + "',Valor='" + Valor.Text + "' WHERE Codigo=" + Codigo.Text; db.Query(comando); RecuperarDados(); Erro.Text = "Coleta Finalizada"; } } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Erro.Text = "Houve uma falha inesperada."; } }
protected void Salvar_Click(object sender, EventArgs e) { try { if (Nome.Text.Trim() == "") { Mensagem.Text = "Preencha o campo Nome"; } else if (Login.Text.Trim() == "") { Mensagem.Text = "Preencha o campo Login"; } else if (Senha.Text.Trim() == "") { Mensagem.Text = "Preencha o campo Senha"; } else if (Anotacoes.Text.Trim() == "") { Mensagem.Text = "Preencha o campo Anotações"; } else if (LoginExiste(Login.Text.Trim()) == true) { Mensagem.Text = "Este login já existe"; } else { string comando = ""; if (Codigo.Text == "") { comando = "INSERT INTO Funcionarios(Nome,Login,Senha,Anotacoes) VALUES('" + Nome.Text + "','" + Login.Text + "','" + Senha.Text + "','" + Anotacoes.Text + "');"; } else { comando = "UPDATE Funcionarios SET Nome='" + Nome.Text + "',Login='******',Senha='" + Senha.Text + "',Anotacoes='" + Anotacoes.Text + "' WHERE Codigo=" + Codigo.Text + ";"; } AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); RecuperarDados(); } } catch (Exception ex) { Mensagem.Text = "Houve uma falha inesperada. Por Favor, tente novamente mais tarde"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void EnviarMsg_Click(object sender, EventArgs e) { try { if (Resgate.Value == "") { Erro.Text = "A mensagem não pode ser vazia"; } else { string comando = "UPDATE Pedido SET Status=" + "'Aguardando Resposta'" + ",Atual_Status='" + DateTime.Now.ToString() + "' Where Codigo=" + Codigo.Text; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); /* * MailMessage email = new MailMessage(); * SmtpClient smtp = new SmtpClient(); * * email.Subject = "Cotação " + Nome.Text; * email.To.Add(Email.Text); * MailAddress from = new MailAddress("*****@*****.**"); * email.From = from; * email.Body = "Olá, " + Nome.Text + "\n"; * email.Body = Resgate.Value; * email.IsBodyHtml = false; * * // PASSO 2 - ENVIAR A MENSAGEM POR SMTP (SEND EMAIL TRANSFER PROTOCOL) * * smtp.Host = "smtp.live.com"; * smtp.Port = 587; * smtp.EnableSsl = true; * smtp.Credentials = new NetworkCredential("*****@*****.**", "suasenha"); * smtp.Send(email); */ Erro.Text = "Mensagem enviada com sucesso."; RecuperarDados(); } } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Erro.Text = "Houve uma falha inesperada.Por Favor tente mais tarde"; } }
protected void Excluir_Click(object sender, EventArgs e) { try { AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; if (MotivoList.SelectedIndex == 0) { ErroMotivo.InnerText = "Informe o motivo"; } else if (MotivoList.SelectedIndex == 3 && Reagendou == true) { if (HoraAgendamento.Text.Trim() == "" || DataAgendamento.Text.Trim() == "") { ErroMotivo.InnerText = "Preencha todos os campos"; } else { string comando = "UPDATE Pedido SET Data_Agendamento='" + DataAgendamento.Text + "',Hora_Agendamento='" + HoraAgendamento.Text + "' WHERE Codigo=" + Codigo.Text; db.Query(comando); Erro.Text = "Coleta reagendada com sucesso"; RecuperarDados(); } } else { string comando = "INSERT INTO CotNaoAceitas(Motivo,Razao) VALUES('" + MotivoList.SelectedValue.ToString() + "','" + "Coleta nao realizada" + "');"; string commando = "DELETE * FROM Pedido WHERE Codigo=" + Codigo.Text; db.Query(comando); db.Query(commando); Erro.Text = "Coleta Removida com sucesso"; RecuperarDados(); } } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Erro.Text = "Houve uma falha inesperada"; } }
protected void Observacao_TextChanged(object sender, EventArgs e) { try { string comando = "UPDATE Pedido SET Observacao='" + Observacao.Text + "'WHERE Codigo=" + codigo.Text; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); Obs.Visible = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert", "HideLabel();", true); } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Obs.Text = "Houve uma falha inesperada"; } }
protected void Realizada_Click(object sender, EventArgs e) { try { TimeSpan ts = new TimeSpan(3, 0, 0); string comando = "UPDATE Pedido SET Status='Aguardando Nota',Atual_Status='" + DateTime.UtcNow.Subtract(ts).ToString() + "' WHERE Codigo=" + Codigo.Text; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); Erro.Text = "Transporte atualizado com sucesso"; RecuperarDados(); } catch (Exception ex) { Erro.Text = "Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Enviar_Click(object sender, EventArgs e) { try { if (Mensagem.Text.Trim() == "" || Nome.Text.Trim() == "" || Email.Text.Trim() == "") { Erro.Text = "Digite todos os dados corretamente"; } else { // ENVIA O EMAIL PARA O DONO SITE MailMessage email = new MailMessage(); // PASSO 1 - CRIAR A MENSAGEM email.Subject = "Fale Conosco"; email.To.Add("*****@*****.**"); MailAddress from = new MailAddress("*****@*****.**"); email.From = from; email.Body = "DADOS ENVIADOS PELO FORM DE CONTATO\n"; email.Body += "NOME: " + Nome.Text + "\n"; email.Body += "EMAIL: " + Email.Text + "\n"; email.Body += "MENSAGEM: " + Mensagem.Text + "\n"; email.IsBodyHtml = false; // PASSO 2 - ENVIAR POR SMTP A MENSAGEM SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.seudominio.com.br"; smtp.Port = 587; smtp.EnableSsl = false; smtp.Credentials = new NetworkCredential("*****@*****.**", "suaSenha"); smtp.Send(email); // FIM } } catch (Exception ex) { Erro.Text = ex.Message; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void Excluir_Click(object sender, EventArgs e) { try { OleDBTransaction db = new OleDBTransaction(); db.ConnectionString = conexao; string comando = "DELETE FROM Usuarios WHERE Codigo=" + Codigo.Text; db.Query(comando); ReadData(); //RecuperarDados(); } catch (Exception ex) { Mensagem.Text = $"Houve uma falha inesperada"; RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); } }
protected void RecuperarDados(string comando) { try { AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; System.Data.DataTable tb = new System.Data.DataTable(); tb = (System.Data.DataTable)db.Query(comando); Pedido.DataSource = tb; Pedido.DataBind(); Pedido.Dispose(); } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Erro.Text = "Houve uma falha inesperada"; } }
protected void Excluir_Click(object sender, EventArgs e) { try { string comando = "DELETE FROM Funcionarios WHERE Codigo=" + Codigo.Text + ";"; AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); Mensagem.Text = "Registro apagado com sucesso"; RecuperarDados(); } catch (Exception ex) { Mensagem.Text = "Houve uma falha inesperada"; //Instancia a Classe RecoverExceptions RecoverExceptions re = new RecoverExceptions(); //Salva a exceção re.SaveException(ex); } }
protected void Enviar_Click(object sender, EventArgs e) { try { TimeSpan ts = new TimeSpan(3, 0, 0); string email = Email.Text.Trim(); bool valida = email.Contains("@") && email.Contains(".com"); Cidade_Coleta.Text = Cidade_Coleta.Text.Replace('\'', ' '); Cidade_Entrega.Text = Cidade_Entrega.Text.Replace('\'', ' '); if (Nome.Text.Trim() == "") { Mensagem.Text = "Preencha o campo Nome"; } else if (!valida) { Mensagem.Text = "Insira um email válido"; } else if (Telefone.Text.Trim() == "") { Mensagem.Text = "Preencha corretamente o campo Telefone"; } else if (Comprimento.Text.Trim() == "" || Largura.Text.Trim() == "" || Altura.Text.Trim() == "" || Peso.Text.Trim() == "") { Mensagem.Text = "Preencha corretamente os campos de dimensões dos produtos"; } else if (CEP_Coleta.Text.Trim() == "" || CEP_Entrega.Text.Trim() == "") { Mensagem.Text = "Preencha o campo CEP"; } else if (Cidade_Coleta.Text.Trim() == "" || Cidade_Entrega.Text.Trim() == "") { Mensagem.Text = "Preencha o campo Cidade"; } else if (Rua_Coleta.Text.Trim() == "" || Rua_Entrega.Text.Trim() == "") { Mensagem.Text = "Preencha corretamente o campo Rua"; } else if (Numero_Coleta.Text.Trim() == "" || Numero_Entrega.Text.Trim() == "") { Mensagem.Text = "Preencha corretamente o campo Numero"; } else if (Bairro_Coleta.Text.Trim() == "" || Bairro_Entrega.Text.Trim() == "") { Mensagem.Text = "Preencha corretamente o campo Bairro"; } else if (Descricao.Text.Trim() == "") { Mensagem.Text = "Insira a descricao do produto"; } else { // CRIAÇÃO DO COMANDO SQL string comando = "INSERT INTO Pedido(Nome,Email,Telefone,Comprimento,Largura,Altura,Peso,Descricao,CEP_Coleta,Cidade_Coleta,Rua_Coleta,Numero_Coleta,Bairro_Coleta,Estado_Coleta," + "CEP_Entrega,Cidade_Entrega,Rua_Entrega,Numero_Entrega,Bairro_Entrega,Estado_Entrega,Data,Status) VALUES('" + Nome.Text + "','" + Email.Text + "','" + Telefone.Text + "','" + Comprimento.Text + "','" + Largura.Text + "','" + Altura.Text + "','" + Peso.Text + "','" + Descricao.Text + "','" + CEP_Coleta.Text + "','" + Cidade_Coleta.Text + "','" + Rua_Coleta.Text + "','" + Numero_Coleta.Text + "','" + Bairro_Coleta.Text + "','" + Estado_Coleta.Text + "','" + CEP_Entrega.Text + "','" + Cidade_Entrega.Text + "','" + Rua_Entrega.Text + "','" + Numero_Entrega.Text + "','" + Bairro_Entrega.Text + "','" + Estado_Entrega.Text + "','" + DateTime.UtcNow.Subtract(ts).ToString() + "','" + "Aguardando Cotacao" + "');"; // CONEXAO AO BANCO DE DADOS AppDatabase.OleDBTransaction db = new AppDatabase.OleDBTransaction(); db.ConnectionString = conexao; db.Query(comando); Mensagem.Text = "Pedido realizado com sucesso. Em breve entraremos em contato com você."; } } catch (Exception ex) { Mensagem.Text = "Houve uma falha inesperada. Tente novamente mais tarde"; //INSTANCIA A CLASSE RecoverExceptions QUE ESTA NA BIBLIOTECA ADSLIB2020 RecoverExceptions re = new RecoverExceptions(); //Salva a excecao re.SaveException(ex); } }
protected void Enviar_Click(object sender, EventArgs e) { string validaEmail = Email.Text.Trim(); bool valida = validaEmail.Contains("@") && validaEmail.Contains(".com"); if (Nome.Text.Trim() == "") { Erro.Text = "Preencha o campo nome"; } else if (Email.Text.Trim() == "") { Erro.Text = "Preencha o campo email"; } else if (Mensagem.Text.Trim() == "") { Erro.Text = "Preencha o campo mensagem"; } else if (!valida) { Erro.Text = "Insira um email válido"; } else { try { /* MailMessage email = new MailMessage(); * SmtpClient smtp = new SmtpClient(); * * email.Subject = "Fale Conosco"; * email.To.Add(Email.Text); * MailAddress from = new MailAddress("*****@*****.**"); * email.From = from; * email.Body = "Olá, " + Nome.Text + "\n"; * email.Body += "Recebemos a sua mensagem do formulário de contato da Lesto Cargo.\n" + * "Em breve estaremos entrando em contato para responder sua mensagem.\n"; * email.Body += "Dados da Mensagem:"; * email.Body += "Nome: " + Nome.Text + "\n"; * email.Body += "Email: " + Email.Text + "\n"; * email.Body += "Mensagem: " + Mensagem.Text + "\n"; * email.Body += "\n\nEste é um email automático. Por favor, não responda."; * email.IsBodyHtml = false; * * // PASSO 2 - ENVIAR A MENSAGEM POR SMTP (SEND EMAIL TRANSFER PROTOCOL) * * smtp.Host = "smtp.live.com"; * smtp.Port = 587; * smtp.EnableSsl = true; * smtp.Credentials = new NetworkCredential("*****@*****.**", "suasenha"); * smtp.Send(email); */ Erro.Text = "Mensagem enviada com sucesso."; Nome.Text = ""; Mensagem.Text = ""; Email.Text = ""; } catch (Exception ex) { RecoverExceptions re = new RecoverExceptions(); re.SaveException(ex); Erro.Text = "Houve uma falha inesperada."; } } }