protected void btnSubmitStatusPerson_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertStatusPersonID.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสสถานภาพ')", true); return; } if (string.IsNullOrEmpty(txtInsertStatusPersonName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อสถานภาพ')", true); return; } ClassStatusPerson sp = new ClassStatusPerson(); sp.STATUS_ID = Convert.ToInt32(txtInsertStatusPersonID.Text); sp.STATUS_NAME = txtInsertStatusPersonName.Text; if (sp.CheckUseStatusPersonID()) { sp.InsertStatusPerson(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสสถานภาพนี้ อยู่ในระบบแล้ว !')", true); } }
void BindData1() { ClassStatusPerson sp = new ClassStatusPerson(); DataTable dt = sp.GetStatusPersonSearch(txtSearchStatusPersonID.Text, txtSearchStatusPersonName.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
void BindData() { ClassStatusPerson sp = new ClassStatusPerson(); DataTable dt = sp.GetStatusPerson("", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void btnSearchRefresh_Click(object sender, EventArgs e) { ClearData(); ClassStatusPerson sp = new ClassStatusPerson(); DataTable dt = sp.GetStatusPerson("", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { TextBox txtStatusPersonIDEDIT = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtStatusPersonIDEDIT"); TextBox txtStatusPersonNameEDIT = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtStatusPersonNameEDIT"); ClassStatusPerson sp = new ClassStatusPerson(Convert.ToInt32(txtStatusPersonIDEDIT.Text), txtStatusPersonNameEDIT.Text); sp.UpdateStatusPerson(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); ClassStatusPerson sp = new ClassStatusPerson(); sp.STATUS_ID = id; sp.DeleteStatusPerson(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void btnSearchStatusPerson_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSearchStatusPersonID.Text) && string.IsNullOrEmpty(txtSearchStatusPersonName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true); return; } else { ClassStatusPerson sp = new ClassStatusPerson(); DataTable dt = sp.GetStatusPersonSearch(txtSearchStatusPersonID.Text, txtSearchStatusPersonName.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); } }