protected void lbuSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertReligionName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อศาสนา')", true); return; } ClassReligion r = new ClassReligion(); r.RELIGION_NAME = txtInsertReligionName.Text; if (r.CheckUseReligionName()) { r.InsertReligion(); 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 lblReligionIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblReligionIDEdit"); TextBox txtReligionNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtReligionNameEdit"); ClassReligion r = new ClassReligion(Convert.ToInt32(lblReligionIDEdit.Text), txtReligionNameEdit.Text); if (r.CheckUseReligionName()) { r.UpdateReligion(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true); } }