Ejemplo n.º 1
0
    protected void ButtonOk_Click(object sender, EventArgs e)
    {
        using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext())
        {
            Konten_Class Konten_Class = new Konten_Class(db);

            TBKonten Konten = new TBKonten();

            if (ButtonOk.Text == "Tambah")
            {
                Konten = Konten_Class.Tambah(EnumKontenJenis.Post, TextBoxJudul.Text, HttpUtility.HtmlDecode(TextBoxIsi.Text));
            }
            else if (ButtonOk.Text == "Ubah")
            {
                Konten = Konten_Class.Ubah(Request.QueryString["id"].ToInt(), EnumKontenJenis.Post, TextBoxJudul.Text, HttpUtility.HtmlDecode(TextBoxIsi.Text));
            }

            db.SubmitChanges();

            if (FileUploadCover.HasFile)
            {
                FileUploadCover.SaveAs(Server.MapPath("~/images/konten/") + Konten.IDKonten + ".jpg");
            }
        }

        Response.Redirect("Default.aspx");
    }
Ejemplo n.º 2
0
    protected void ButtonOk_Click(object sender, EventArgs e)
    {
        using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext())
        {
            Konten_Class Konten_Class = new Konten_Class(db);

            if (ButtonOk.Text == "Tambah")
            {
                Konten_Class.Tambah(EnumKontenJenis.Halaman, TextBoxJudul.Text, HttpUtility.HtmlDecode(TextBoxIsi.Text));
            }
            else if (ButtonOk.Text == "Ubah")
            {
                Konten_Class.Ubah(Request.QueryString["id"].ToInt(), EnumKontenJenis.Halaman, TextBoxJudul.Text, HttpUtility.HtmlDecode(TextBoxIsi.Text));
            }

            db.SubmitChanges();
        }

        Response.Redirect("Default.aspx");
    }