Beispiel #1
0
    protected void LinkButtonEdat_Command(object sender, CommandEventArgs e)
    {
        this.EditPanel.Visible = true;
        this.AddPanel.Visible  = false;
        this.ShowPanel.Visible = false;

        long ID = long.Parse(e.CommandArgument.ToString());

        CommonClassLibrary.TypeCate cate = innofood.TypeCates.Where(x => x.Id == ID).First();
        this.Labelidname.Text        = cate.Name;
        this.Image_category.ImageUrl = "Image/" + cate.UrlImage;
        this.aaa_TextBox.Text        = ID.ToString();



        long Idtext = long.Parse(cate.Name);

        CommonClassLibrary.TextContent textc = innofood.TextContents.Where(x => x.Id == Idtext).First();

        editName_TextBox.Text   = textc.Thai;
        editNameEN_TextBox.Text = textc.English;
    }
Beispiel #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string img = "";
        int    ID  = int.Parse(aaa_TextBox.Text);

        try
        {
            CommonClassLibrary.TextContent o = innofood.TextContents.Where(x => x.Id == ID).First();

            o.Thai        = editName_TextBox.Text;
            o.English     = editNameEN_TextBox.Text;
            o.LastUpdated = DateTime.Now;

            innofood.SaveChanges();

            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "แก้ไขข้อมูลสำเร็จ" + "');", true);

            //this.SuccessPanel.Visible = true;
            //this.ErrorPanel.Visible = false;
            //this.SuccessLabel.Text = "แก้ไขข้อมูลสำเร็จ";
        }
        catch (Exception ex)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "แก้ไขข้อมูลไม่สำเร็จ" + "');", true);
            //this.SuccessPanel.Visible = false;
            //this.ErrorPanel.Visible = true;
            //this.ErrorLabel.Text = "แก้ไขข้อมูลไม่สำเร็จ";
        }

        if (this.EditFileUpload.HasFile)
        {
            HttpPostedFile UpFileProduct = EditFileUpload.PostedFile;

            string UpFilePro = System.IO.Path.GetExtension(UpFileProduct.FileName);


            if (UpFilePro == ".jpg" || UpFilePro == ".png" || UpFilePro == ".JPG" || UpFilePro == ".PNG" || UpFilePro == ".jpeg" || UpFilePro == ".JPEG")
            {
                string imageFileName = "IMF" + "_" + DateTime.Now.ToString("ddMMyyyy-HHmmss");
                imageFileName += ".jpg";
                img            = imageFileName;
                string path = System.IO.Path.Combine(Server.MapPath("~/Image/"), imageFileName);
                // string path = System.IO.Path.Combine(Server.MapPath("D:/OWP/DigitalServicesRestaurant/ManagementWebSite/Image/"), imageFileName);
                UpFileProduct.SaveAs(path);

                try
                {
                    CommonClassLibrary.TypeCate oo = innofood.TypeCates.Where(x => x.Id == ID).First();

                    oo.UrlImage = img;

                    innofood.SaveChanges();

                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "แก้ไขข้อมูลสำเร็จ" + "');", true);

                    //this.SuccessPanel.Visible = true;
                    //this.ErrorPanel.Visible = false;
                    //this.SuccessLabel.Text = "แก้ไขข้อมูลสำเร็จ";
                }
                catch (Exception ex)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "แก้ไขข้อมูลไม่สำเร็จ" + "');", true);


                    //this.SuccessPanel.Visible = false;
                    //this.ErrorPanel.Visible = true;
                    //this.ErrorLabel.Text = "แก้ไขข้อมูลไม่สำเร็จ";
                }
            }
        }
    }