Пример #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;
    }
Пример #2
0
    public void saveImage()
    {
        HttpPostedFile UpFileProduct = Picture_FileUpload.PostedFile;

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

        if (this.Picture_FileUpload.PostedFile.FileName.ToString() != "")
        {
            long IDProduct1 = (long)new CommonClassLibrary.CommonDataSetTableAdapters.TextContentTableAdapter().InsertQuery(Name_TextBox.Text, NameEN_TextBox.Text, " ", DateTime.Now, DateTime.Now, 1);


            if (UpFilePro == ".jpg" || UpFilePro == ".png" || UpFilePro == ".JPG" || UpFilePro == ".PNG" || UpFilePro == ".jpeg" || UpFilePro == ".JPEG")
            {
                string imageFileName = "IMF" + "_" + DateTime.Now.ToString("ddMMyyyy-HHmmss");
                imageFileName += ".jpg";
                string aaa  = 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 tc = new CommonClassLibrary.TypeCate()
                    {
                        Name       = IDProduct1.ToString(),
                        UrlImage   = aaa,
                        CreateDate = DateTime.Now,
                        LastUpdate = DateTime.Now,
                        Status     = 1
                    };


                    innofood.TypeCates.Add(tc);
                    innofood.SaveChanges();

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



                    //this.SuccessPanel.Visible = true;
                    //this.ErrorPanel.Visible = false;
                    //this.SuccessLabel.Text = "บันทึกข้อมูลสำเร็จ";
                    Response.Redirect("~/ListCategory.aspx");
                }

                catch (Exception ex)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "บันทึกข้อมูลไม่สำเร็จ" + "');", true);


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


                //if (new CommonClassLibrary.CommonDataSetTableAdapters.CategoryTableAdapter().Insert(IDProduct1.ToString(), aaa, DateTime.Now, DateTime.Now, 1) == 1)
                //{
                //    this.SuccessLabel.Text = "บันทึกข้อมูลสำเร็จ";
                //    Response.Redirect("~/AddCategory.aspx");
                //}
                //else
                //{

                //    FileInfo DeleteImage = new FileInfo(@"C:/FTP/Imilk/Image/" + aaa);
                //    DeleteImage.Delete();
                //    this.SuccessPanel.Visible = false;
                //    this.ErrorPanel.Visible = true;
                //    this.ErrorLabel.Text = "บันทึกข้อมูลไม่สำเร็จ";
                //}
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "บันทึกข้อมูลไม่สำเร็จ กรุณาเลือกรูปภาพ" + "');", true);


            //this.SuccessPanel.Visible = false;
            //this.ErrorPanel.Visible = true;
            //this.ErrorLabel.Text = "บันทึกข้อมูลไม่สำเร็จ กรุณาเลือกรูปภาพ";
        }
    }
Пример #3
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 = "แก้ไขข้อมูลไม่สำเร็จ";
                }
            }
        }
    }