protected void Button1_Click(object sender, EventArgs e) { DAL.DALTransacaoPacote aDALTPacote; Modelo.TransacaoPacote aTP; DAL.DALClientes aDALClientes = new DAL.DALClientes(); DAL.DALPacote aDALPacote = new DAL.DALPacote(); DAL.DALHistorico aDALHistorico = new DAL.DALHistorico(); Modelo.Historico aH; int i, u; i = Convert.ToInt32(Session["idpacote"]); u = Convert.ToInt32(Session["idlogin"]); string error = " "; aDALTPacote = new DAL.DALTransacaoPacote(); if (aDALTPacote.VerificarT(i, u)) { aDALTPacote.Delete(i, u); Response.Redirect("~\\WebFormPacotesC.aspx"); } else { double preco = aDALPacote.Select(i).ElementAt(0).Preco; aTP = new Modelo.TransacaoPacote(0, i, u); if (aDALPacote.Select(i).ElementAt(0).Preco < aDALClientes.Select1(u).ElementAt(0).Saldo) { aDALTPacote.Insert(aTP); aDALClientes.UpdateComprar(aDALPacote.Select(i).ElementAt(0).Preco, aDALClientes.Select1(u).ElementAt(0).Saldo, u); aH = new Modelo.Historico(0, DateTime.Now, aDALPacote.Select(i).ElementAt(0).Preco, aDALClientes.Select1(u).ElementAt(0).Saldo, u, i); aDALHistorico.InsertPacote(aH); Response.Redirect("~\\WebFormPacotesListar.aspx"); } else { error = "Saldo insuficiente para realizar a transação"; Error(error); } } }
public void Delete(Modelo.Pacote obj) { SqlConnection conn = new SqlConnection(connectionString); DAL.DALAvaliacao DA = new DALAvaliacao(); DAL.DALTransacaoPacote DT = new DALTransacaoPacote(); DAL.DALPacote_Refeicao DPR = new DALPacote_Refeicao(); DAL.DALHistorico DH = new DALHistorico(); DA.DeletePacote(obj.id); DT.DeletePacote(obj.id); DPR.DeletePacote(obj.id); DH.DeletePacote(obj.id); conn.Open(); SqlCommand com = conn.CreateCommand(); SqlCommand cmd = new SqlCommand("DELETE FROM Pacote WHERE id = @Pacote_id", conn); cmd.Parameters.AddWithValue("@Pacote_id", obj.id); cmd.ExecuteNonQuery(); conn.Close(); }
public void Delete(Modelo.Clientes obj) { DAL.DALHistorico AH = new DALHistorico(); DAL.DALAvaliacao DA = new DALAvaliacao(); DAL.DALEndereco DE = new DALEndereco(); DAL.DALTransacaoPacote DT = new DALTransacaoPacote(); DT.DeleteCliente(obj.id); DE.DeleteUsuario(obj.id); DA.DeleteCliente(obj.id); AH.DeleteUsuario(obj.id); SqlConnection conn = new SqlConnection(connectionString); conn.Open(); SqlCommand com = conn.CreateCommand(); SqlCommand cmd = new SqlCommand("DELETE FROM Clientes WHERE id = @Clientes_id", conn); cmd.Parameters.AddWithValue("@Clientes_id", obj.id); cmd.ExecuteNonQuery(); conn.Close(); }
protected void Page_Load(object sender, EventArgs e) { int count; DAL.DALPacote aDALPacote = new DAL.DALPacote(); Metodos_Gerais aMetodos = new Metodos_Gerais(); DAL.DALTransacaoPacote aDALTPacote = new DAL.DALTransacaoPacote(); count = aDALPacote.A(); int type = Convert.ToInt32(DropDownList1.SelectedValue); for (int i = 0; i <= count - 1; i++) { int id = aDALPacote.SelectAll(type).ElementAt(i).id; if (aDALTPacote.VerificarT(id, Convert.ToInt32(Session["idlogin"]))) { Panel p1, p2, p3; Image img; Label l1, l2; HtmlGenericControl h3, h5; Button b1; h3 = new HtmlGenericControl("h3"); h5 = new HtmlGenericControl("h5"); l1 = new Label(); l1.Text = aDALPacote.SelectAll(type).ElementAt(i).Nome; l1.CssClass = "txt5"; l2 = new Label(); l2.Text = aMetodos.VerificarDouble(aDALPacote.SelectAll(type).ElementAt(i).Preco); l2.CssClass = "txt6"; img = new Image(); img.ImageUrl = aDALPacote.SelectAll(type).ElementAt(i).Url_Imagem; b1 = new Button(); b1.CssClass = "login-form-btn center-block"; b1.Text = "Ver Mais"; b1.PostBackUrl = "~/WebFormPacoteDetalhar.aspx?Pacote=" + id; p2 = new Panel(); p2.CssClass = "thumbnail"; p3 = new Panel(); p3.CssClass = "caption text-center"; p1 = new Panel(); p1.CssClass = "col-sm-3"; p2.Controls.Add(img); h3.Controls.Add(l1); p3.Controls.Add(h3); h5.Controls.Add(l2); p3.Controls.Add(h5); p3.Controls.Add(b1); p2.Controls.Add(p3); p1.Controls.Add(p2); PlaceHolder1.Controls.Add(p1); } else { } } }
protected void Page_Load(object sender, EventArgs e) { DAL.DALTransacaoPacote aDALTPacote = new DAL.DALTransacaoPacote(); DAL.DALAvaliacao aDALAvaliacao = new DAL.DALAvaliacao(); DAL.DALPacote_Refeicao aDALPacote_Refeicao = new DAL.DALPacote_Refeicao(); DAL.DALRefeicao aDALRefeicao = new DAL.DALRefeicao(); if (Convert.ToInt32(Session["Nivel"]) == 2 || Convert.ToInt32(Session["Nivel"]) == 3) { div2.Attributes["style"] = "display : none"; divControl.Attributes["class"] = "d-flex"; divComprar.Attributes["class"] = "display"; section.Attributes["class"] = "margintop-15"; } if (Convert.ToInt32(Request.QueryString["Pacote"]) > 0) { Session["idpacote"] = Convert.ToInt32(Request.QueryString["Pacote"]); int i, id, pacote, count, countall; DAL.DALPacote aDALPacote = new DAL.DALPacote(); Metodos_Gerais aMetodos = new Metodos_Gerais(); i = Convert.ToInt32(Session["idpacote"]); id = Convert.ToInt32(Session["idlogin"]); pacote = Convert.ToInt32(Session["idpacote"]); count = aDALPacote_Refeicao.CountPacote(pacote); countall = aDALRefeicao.Count(); LabelNome.Text = aDALPacote.Select(i).ElementAt(0).Nome; LabelPreco.Text = aMetodos.VerificarDouble(aDALPacote.Select(i).ElementAt(0).Preco); if (!IsPostBack) { Rating1.CurrentRating = aDALAvaliacao.Media(pacote); Rating1.ReadOnly = true; } if (!IsPostBack) { Nome.Text = aDALPacote.Select(i).ElementAt(0).Nome; Preco.Text = aDALPacote.Select(i).ElementAt(0).Preco.ToString(); TextBox1.Text = aDALPacote.Select(i).ElementAt(0).Descricao; TextBox1.Enabled = false; } ImagePacote.ImageUrl = aDALPacote.Select(i).ElementAt(0).Url_Imagem; if (aDALTPacote.VerificarT(pacote, id)) { if (aDALAvaliacao.SelectNota(pacote, id) == 0) { if (!IsPostBack) { Rating1.ReadOnly = false; Rating1.CurrentRating = 3; Button2.CssClass = "login15-form-btn-c"; } } else { Rating1.ReadOnly = true; Rating1.CurrentRating = aDALAvaliacao.SelectNota(pacote, id); Button2.CssClass = "display"; } divComprar.Attributes["class"] = "display"; divCancel.Attributes["class"] = ""; Label8.Text = "Você tem certeza em cancelar esse pacote?"; } if (countall > 0) { for (int b = 0; b <= countall - 1; b++) { if (aDALPacote_Refeicao.CountPC(pacote, aDALRefeicao.SelectAll().ElementAt(b).id)) { ListItem List = new ListItem(); List.Text = aDALRefeicao.SelectAll().ElementAt(b).Nome; List.Value = aDALRefeicao.SelectAll().ElementAt(b).id.ToString(); DropDownList1.Items.Add(List); } } } else { section.Attributes["class"] = "margintop-15 display"; } if (count > 0) { HtmlGenericControl divm; divm = new HtmlGenericControl("div"); for (int a = 0; a <= count - 1; a++) { Image img; Label l1; HtmlGenericControl div; LiteralControl br; int refeicao; refeicao = aDALPacote_Refeicao.Select(pacote).ElementAt(a).id_Refeicao; div = new HtmlGenericControl("div"); div.Attributes["class"] = "ph-refeicao container-receita"; img = new Image(); img.ImageUrl = aDALRefeicao.Select(refeicao).ElementAt(0).Url_Imagem; img.CssClass = "Refeicao-Img pull-left"; div.Controls.Add(img); l1 = new Label(); l1.CssClass = "txt14"; l1.Text = aDALRefeicao.Select(refeicao).ElementAt(0).Nome; div.Controls.Add(l1); l1 = new Label(); l1.CssClass = "txt13"; l1.Text = "Ingredientes: "; br = new LiteralControl("<br/>"); div.Controls.Add(br); div.Controls.Add(l1); l1 = new Label(); l1.CssClass = "txt12"; l1.Text = aDALRefeicao.Select(refeicao).ElementAt(0).Ingredientes; div.Controls.Add(l1); l1 = new Label(); l1.CssClass = "txt13"; l1.Text = "Modo Preparo :"; br = new LiteralControl("<br/>"); div.Controls.Add(br); div.Controls.Add(l1); l1 = new Label(); l1.CssClass = "txt12"; l1.Text = aDALRefeicao.Select(refeicao).ElementAt(0).ModoPreparo; div.Controls.Add(l1); divm.Controls.Add(div); } PlaceHolder1.Controls.Add(divm); } } if (Convert.ToInt32(Request.QueryString["Edit"]) == 1) { ImagePacote.CssClass += " display"; divName.Attributes["class"] = "Name"; divPreco.Attributes["class"] = "Preco"; LabelPreco.CssClass += " display"; ImgInput.Attributes["class"] = "Pacote-Img-div "; LabelNome.CssClass += " display"; CancelEdit.Attributes["class"] = ""; Edit.Attributes["class"] = ""; divExcluir.Attributes["class"] = "display"; Button1.CssClass = " display"; TextBox1.Enabled = true; } }