protected void btnSubmitSubStaffType_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertSubStaffTypeID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสประเภทบุคลากรย่อย')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertSubStaffTypeName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อประเภทบุคลากรย่อย')", true);
                return;
            }
            ClassSubStaffType sst = new ClassSubStaffType();

            sst.SUBSTAFFTYPE_ID   = Convert.ToInt32(txtInsertSubStaffTypeID.Text);
            sst.SUBSTAFFTYPE_NAME = txtInsertSubStaffTypeName.Text;

            if (sst.CheckUseSubStaffTypeID())
            {
                sst.InsertSubStaffType();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสประเภทบุคลากรย่อยนี้ อยู่ในระบบแล้ว !')", true);
            }
        }
        void BindData1()
        {
            ClassSubStaffType sst = new ClassSubStaffType();
            DataTable         dt  = sst.GetSubStaffType(txtSearchSubStaffTypeID.Text, txtSearchSubStaffTypeName.Text);

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
        void BindData()
        {
            ClassSubStaffType sst = new ClassSubStaffType();
            DataTable         dt  = sst.GetSubStaffType("", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
        protected void btnSearchRefresh_Click(object sender, EventArgs e)
        {
            ClearData();
            ClassSubStaffType sst = new ClassSubStaffType();
            DataTable         dt  = sst.GetSubStaffType("", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtSubStaffTypeIDEdit   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtSubStaffTypeIDEdit");
            TextBox txtSubStaffTypeNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtSubStaffTypeNameEdit");

            ClassSubStaffType sst = new ClassSubStaffType(Convert.ToInt32(txtSubStaffTypeIDEdit.Text), txtSubStaffTypeNameEdit.Text);

            sst.UpdateSubStaffType();
            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);
            ClassSubStaffType sst = new ClassSubStaffType();

            sst.SUBSTAFFTYPE_ID = id;
            sst.DeleteSubStaffType();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            GridView1.EditIndex = -1;
            BindData1();
        }
 protected void SearchSubStaffType_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearchSubStaffTypeID.Text) && string.IsNullOrEmpty(txtSearchSubStaffTypeName.Text))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);
         return;
     }
     else
     {
         ClassSubStaffType sst = new ClassSubStaffType();
         DataTable         dt  = sst.GetSubStaffTypeSearch(txtSearchSubStaffTypeID.Text, txtSearchSubStaffTypeName.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }