Пример #1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Session["ExcluirR"]);

            DAL.DALRefeicao aDALRefeicao = new DAL.DALRefeicao();
            Modelo.Refeicao aR           = new Modelo.Refeicao(id, "", "", "", "");
            aDALRefeicao.Delete(aR);
            Response.Redirect("~\\WebFormRefeicoes.aspx");
        }
Пример #2
0
        protected void Excluir(object sender, EventArgs e)
        {
            DAL.DALRefeicao aDALRefeicao = new DAL.DALRefeicao();

            Button button = sender as Button;

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

            Session["ExcluirR"] = id;

            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "Excluir()", true);
        }
Пример #3
0
        protected void Insert(object sender, EventArgs e)
        {
            DAL.DALRefeicao aDALRefeicao = new DAL.DALRefeicao();
            Modelo.Refeicao aR           = new Modelo.Refeicao(0, TextBoxIngredientes.Text, TextBoxModoPreparo.Text, "", TextBoxNome.Text);

            Metodos_Gerais MG    = new Metodos_Gerais();
            string         error = " ";

            if (MG.IsNull(TextBoxIngredientes.Text))
            {
                if (MG.IsNull(TextBoxModoPreparo.Text))
                {
                    if (MG.IsNull(TextBoxNome.Text))
                    {
                        aDALRefeicao.Insert(aR);
                        int count = aDALRefeicao.Count();
                        int id    = aDALRefeicao.SelectAll().ElementAt(count - 1).id;

                        if (FileUpload1.HasFile)
                        {
                            string filename = "Imagens\\Receitas\\Refeicao" + id + ".jpg";

                            FileUpload1.SaveAs(Request.PhysicalApplicationPath + filename);
                            aR = new Modelo.Refeicao(id, TextBoxIngredientes.Text, TextBoxModoPreparo.Text, filename, TextBoxNome.Text);

                            aDALRefeicao.UpdateImagem(aR);
                        }
                        Response.Redirect("~\\WebFormRefeicoes.aspx");
                    }
                    else
                    {
                        error = "Nome";
                        Error(error);
                    }
                }
                else
                {
                    error = "Modo de Preparo";
                    Error(error);
                }
            }
            else
            {
                error = "Ingredientes";
                Error(error);
            }
        }
Пример #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Session["EditR"]);

            DAL.DALRefeicao aDALRefeicao = new DAL.DALRefeicao();
            Modelo.Refeicao aR           = new Modelo.Refeicao(id, TextBoxIngredientes.Text, TextBoxModoPreparo.Text, "", TextBoxNome.Text);
            Metodos_Gerais  MG           = new Metodos_Gerais();
            string          error        = " ";

            if (MG.IsNull(TextBoxIngredientes.Text))
            {
                if (MG.IsNull(TextBoxModoPreparo.Text))
                {
                    if (MG.IsNull(TextBoxNome.Text))
                    {
                        aDALRefeicao.Update(aR);

                        if (FileUpload1.HasFile)
                        {
                            string filename = "Imagens\\Receitas\\Refeicao" + id + ".jpg";

                            FileUpload1.SaveAs(Request.PhysicalApplicationPath + filename);
                            aR = new Modelo.Refeicao(id, TextBoxIngredientes.Text, TextBoxModoPreparo.Text, filename, TextBoxNome.Text);

                            aDALRefeicao.UpdateImagem(aR);
                        }

                        Response.Redirect("~\\WebFormRefeicoes.aspx");
                    }
                    else
                    {
                        error = "Nome";
                        Error(error);
                    }
                }
                else
                {
                    error = "Modo de Preparo";
                    Error(error);
                }
            }
            else
            {
                error = "Ingredientes";
                Error(error);
            }
        }
Пример #5
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);
        }
Пример #6
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;
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Convert.ToInt32(Session["Nivel"]) == 2 || Convert.ToInt32(Session["Nivel"]) == 3)
            {
                DAL.DALRefeicao aDALRefeicao = new DAL.DALRefeicao();

                HtmlGenericControl divflex, divmae;

                divflex = new HtmlGenericControl("div");
                divmae  = new HtmlGenericControl("div");

                int count = aDALRefeicao.Count(), v = 0;
                for (int a = 0; a <= count - 1; a++)
                {
                    Image img;
                    Label l1;
                    HtmlGenericControl div;
                    LiteralControl     br;
                    Button             b1, b2;


                    div = new HtmlGenericControl("div");



                    div.Attributes["class"] = "ph-refeicao container-receita-listar";

                    img = new Image();

                    img.ImageUrl = aDALRefeicao.SelectAll().ElementAt(a).Url_Imagem;
                    img.CssClass = "Refeicao-Img pull-left";

                    div.Controls.Add(img);

                    l1 = new Label();

                    l1.CssClass = "txt14";
                    l1.Text     = aDALRefeicao.SelectAll().ElementAt(a).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.SelectAll().ElementAt(a).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.SelectAll().ElementAt(a).ModoPreparo;

                    div.Controls.Add(l1);
                    b1 = new Button();
                    b2 = new Button();

                    b1.Text = "Editar";
                    b2.Text = "Excluir";

                    b1.CssClass = "login10-form-btn-m-15";
                    b2.CssClass = "login10-form-btn-m-15";

                    b1.ID = aDALRefeicao.SelectAll().ElementAt(a).id.ToString();
                    b2.ID = " " + aDALRefeicao.SelectAll().ElementAt(a).id.ToString();

                    b1.Click += new EventHandler(Editar);
                    b2.Click += new EventHandler(Excluir);

                    div.Controls.Add(b1);
                    div.Controls.Add(b2);

                    if (v < 2)
                    {
                        divflex.Attributes["class"] = "d-flex6";
                        divflex.Controls.Add(div);


                        v += +1;
                    }
                    else
                    {
                        divmae.Controls.Add(divflex);
                        divflex = new HtmlGenericControl();
                        divflex.Controls.Add(div);
                        v = 1;
                    }
                    divmae.Controls.Add(divflex);
                    PlaceHolder1.Controls.Add(divmae);
                }
            }
            else
            {
                Response.Redirect("~\\WebFormPacotesListar.aspx");
            }
        }