protected void lbuSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertGradLevName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อระดับการศึกษา')", true); return; } ClassGradLev gl = new ClassGradLev(); gl.GRAD_LEV_NAME = txtInsertGradLevName.Text; if (gl.CheckUseGradLevName()) { gl.InsertGradLev(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true); } }
protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { Label lblGradLevIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblGradLevIDEdit"); TextBox txtGradLevNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtGradLevNameEdit"); ClassGradLev gl = new ClassGradLev(lblGradLevIDEdit.Text , txtGradLevNameEdit.Text); if (gl.CheckUseGradLevName()) { gl.UpdateGradLev(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true); } }