Example #1
0
        protected void Editar(object sender, EventArgs e)
        {
            DAL.DALRefeicao aDALRefeicao = new DAL.DALRefeicao();

            Button button = sender as Button;

            int id = Convert.ToInt32(button.ID);

            Session["EditR"]         = id;
            TextBoxIngredientes.Text = aDALRefeicao.Select(id).ElementAt(0).Ingredientes;
            TextBoxModoPreparo.Text  = aDALRefeicao.Select(id).ElementAt(0).ModoPreparo;
            TextBoxNome.Text         = aDALRefeicao.Select(id).ElementAt(0).Nome;

            Button2.CssClass += " display";

            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "Editar()", true);
        }
Example #2
0
        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;
            }
        }