protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { Judul.Focus(); bersih(); KdBuku.Text = _MBuku.autonumber(); } BindGrid(); }
protected void btnUbah_Click(object sender, EventArgs e) { try { _MBuku = new clsMBuku(); int _hasil; _MBuku.PKdBuku = KdBuku.Text; _MBuku.PJudul = Judul.Text; _MBuku.PHarga = System.Convert.ToDouble(Harga.Text); _MBuku.PPengarang = Pengarang.Text; string GbrBuku = ""; if (FUGbr.HasFile == true) { GbrBuku = System.IO.Path.GetFileName(FUGbr.PostedFile.FileName); FUGbr.SaveAs(Server.MapPath("~/Gambar/Upload/") + GbrBuku); } _MBuku.PGambar = GbrBuku; _MBuku.PStock = System.Convert.ToInt32(Stok.Text); _MBuku.PKdJenis = ddJenis.SelectedItem.Value.ToString(); _hasil = _MBuku.Ubah(); if (_hasil == 1) { string pesan = "alert(\"Data Behasil Diubah\");"; ScriptManager.RegisterStartupScript (this, GetType(), "UBAH DATA", pesan, true); bersih(); KdBuku.Text = _MBuku.autonumber(); } else { string pesan = "alert(\"Data Tidak Berhasil Diubah\");"; ScriptManager.RegisterStartupScript (this, typeof(string), "UBAH DATA", pesan, true); } } catch (Exception ex) { string errorex = ex.Message; string pesan = "alert(\"ERROR LAINNYA;'" + errorex + "\");"; ScriptManager.RegisterStartupScript (this, GetType(), "UBAH DATA", pesan, true); } }