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