Пример #1
0
    protected void ButtonInsert_Click1(object sender, EventArgs e)
    {
        string urlFoto = (string)Session["UrlFotoProdOutlet"];

        if (string.IsNullOrEmpty(urlFoto))
        {
            errNoImg.Visible = true;
            artErr.Visible   = true;
            artSucc.Visible  = false;
            lblErr.Text      = "Attenzione verificare che sia stata inserita un immagine.";
        }
        else
        {
            decimal prodPrezzo      = 0;
            decimal prodPrezzoScont = 0;

            if ((decimal.TryParse(txtProdottoPrezzo.Text, out prodPrezzo)) && (decimal.TryParse(txtProdottoPrezzoSconto.Text, out prodPrezzoScont)))
            {
                DataSetMateraArredamentiTableAdapters.OutletTableAdapter taOutlet = new DataSetMateraArredamentiTableAdapters.OutletTableAdapter();
                taOutlet.Insert(txtProdotto.Text, txtProdottoDesc.Text, txtProdottoDescS.Text, decimal.Parse(txtProdottoPrezzo.Text),
                                decimal.Parse(txtProdottoPrezzoSconto.Text), true, urlFoto);
                Session["UrlFotoProdOutlet"] = "";
                errNoImg.Visible             = false;
                artErr.Visible  = false;
                artSucc.Visible = true;
            }
            else
            {
                artErr.Visible  = true;
                artSucc.Visible = false;
                lblErr.Text     = "Attenzione verificare che il prezzo sia inserito nel formato corretto";
            }
        }
    }
Пример #2
0
    protected void RunCommandButton(Object src, GridViewCommandEventArgs e)
    {
        int index = Convert.ToInt32(e.CommandArgument);

        if (e.CommandName == "CancellaArticolo")
        {
            DataSetMateraArredamentiTableAdapters.OutletTableAdapter taOutlet = new DataSetMateraArredamentiTableAdapters.OutletTableAdapter();
            taOutlet.Delete(int.Parse(GridView1.Rows[index].Cells[2].Text));



            // cancello anche l'immagine rappresentativa dell'articolo

            string pathFoto = GridView1.Rows[index].Cells[9].Text;

            string nomeFile = pathFoto.Replace("img/outlet/", "");
            GridView1.DataBind();
            //try
            //{
            //    File.Delete(Server.MapPath("~/img/outlet/") + nomeFile);

            //}
            //catch (Exception ex)
            //{

            //}
        }
    }
Пример #3
0
    protected void ButtonAgg_Click(object sender, EventArgs e)
    {
        int idOutlet = (int)Session["IDProdottoOutlet"];

        try
        {
            DataSetMateraArredamentiTableAdapters.OutletTableAdapter taOutlet = new DataSetMateraArredamentiTableAdapters.OutletTableAdapter();
            taOutlet.Update(txtProdotto.Text, txtProdottoDesc.Text, txtProdottoDescS.Text, decimal.Parse(txtProdottoPrezzo.Text), decimal.Parse(txtProdottoPrezzoSconto.Text), true, txtProdottoFoto.Text, idOutlet);
        }
        catch (Exception ex)
        {
            artErr.Visible  = true;
            artSucc.Visible = false;
            lblErr.Text     = ex.Message;
        }
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string idOutlet = Request.QueryString["IdOutlet"];

        if (idOutlet != null)
        {
            //si tratta di una modifica
            Session["IDProdottoOutlet"] = int.Parse(idOutlet);

            if (
                (txtProdotto.Text == "") && (txtProdottoDesc.Text == "") && (txtProdottoDescS.Text == "") &&
                (txtProdottoPrezzo.Text == "") && (txtProdottoPrezzoSconto.Text == "") &&
                (txtProdottoFoto.Text == ""))
            {
                DataSetMateraArredamentiTableAdapters.OutletTableAdapter taOutlet = new DataSetMateraArredamentiTableAdapters.OutletTableAdapter();

                DataTable dtOutlet = taOutlet.GetDataByID(int.Parse(idOutlet));



                txtProdotto.Text             = dtOutlet.Rows[0]["ProdottoNome"].ToString();
                txtProdottoDesc.Text         = dtOutlet.Rows[0]["ProdottoDescHome"].ToString();
                txtProdottoDescS.Text        = dtOutlet.Rows[0]["ProdottoDescScheda"].ToString();
                txtProdottoPrezzo.Text       = dtOutlet.Rows[0]["ProdottoPrezzo"].ToString();
                txtProdottoPrezzoSconto.Text = dtOutlet.Rows[0]["ProdottoPrezzoSconto"].ToString();
                txtProdottoFoto.Text         = dtOutlet.Rows[0]["ProdottoFoto"].ToString();

                //string prova = Server.MapPath("~/img/outlet/") + txtProdottoFoto.Text.Replace("/img/outlet/", "").Replace('/','\\');


                imgProdotto.ImageUrl = "~/" + txtProdottoFoto.Text;
            }
            ButtonAgg.Visible    = true;
            ButtonInsert.Visible = false;
        }
        else
        {
            ButtonAgg.Visible    = false;
            ButtonInsert.Visible = true;
        }
    }