protected void btnSubmitStaffType_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertStaffTypeID.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสประเภทข้าราชการ')", true); return; } if (string.IsNullOrEmpty(txtInsertStaffTypeName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อประเภทข้าราชการ')", true); return; } ClassStaffType s = new ClassStaffType(); s.STAFFTYPE_ID = Convert.ToInt32(txtInsertStaffTypeID.Text); s.STAFFTYPE_NAME = txtInsertStaffTypeName.Text; if (s.CheckUseStaffTypeID()) { s.InsertStaffType(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสประเภทข้าราชการนี้ อยู่ในระบบแล้ว !')", true); } }
void BindData1() { ClassStaffType s = new ClassStaffType(); DataTable dt = s.GetStaffTypeSearch(txtSearchStaffTypeID.Text, txtSearchStaffTypeName.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
void BindData() { ClassStaffType s = new ClassStaffType(); DataTable dt = s.GetStaffType("", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void btnSearchRefresh_Click(object sender, EventArgs e) { ClearData(); ClassStaffType s = new ClassStaffType(); DataTable dt = s.GetStaffType("", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); ClassStaffType s = new ClassStaffType(); s.STAFFTYPE_ID = id; s.DeleteStaffType(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { TextBox txtStaffTypeIDEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtStaffTypeIDEdit"); TextBox txtStaffTypeNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtStaffTypeNameEdit"); ClassStaffType s = new ClassStaffType(Convert.ToInt32(txtStaffTypeIDEdit.Text) , txtStaffTypeNameEdit.Text); s.UpdateStaffType(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void btnSearchStaffType_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSearchStaffTypeID.Text) && string.IsNullOrEmpty(txtSearchStaffTypeName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true); return; } else { ClassStaffType s = new ClassStaffType(); DataTable dt = s.GetStaffTypeSearch(txtSearchStaffTypeID.Text, txtSearchStaffTypeName.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); } }