protected void lbuRefresh_Click(object sender, EventArgs e)
 {
     ClearData();
     ClassPositionWork pw = new ClassPositionWork();
     DataTable dt = pw.GetPositionWork("");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 protected void lbuSearch_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearchPositionWorkName.Text))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);
         return;
     }
     else
     {
         ClassPositionWork pw = new ClassPositionWork();
         DataTable dt = pw.GetPositionWork(txtSearchPositionWorkName.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }
        protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertPositionWorkName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อตำแหน่งในสายงาน')", true);
                return;
            }
            ClassPositionWork pw = new ClassPositionWork();
            pw.POSITION_WORK_NAME = txtInsertPositionWorkName.Text;

            if (pw.CheckUsePositionWorkName())
            {
                pw.InsertPositionWork();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true);
            }
        }
        protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
            ClassPositionWork pw = new ClassPositionWork();
            pw.POSITION_WORK_ID = id;
            pw.DeletePositionWork();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            GridView1.EditIndex = -1;
            BindData1();
        }
 void BindData1()
 {
     ClassPositionWork pw = new ClassPositionWork();
     DataTable dt = pw.GetPositionWork(txtSearchPositionWorkName.Text);
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 void BindData()
 {
     ClassPositionWork pw = new ClassPositionWork();
     DataTable dt = pw.GetPositionWork("");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            Label lblPositionWorkIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblPositionWorkIDEdit");
            TextBox txtPositionWorkNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtPositionWorkNameEdit");

            ClassPositionWork pw = new ClassPositionWork(Convert.ToInt32(lblPositionWorkIDEdit.Text), txtPositionWorkNameEdit.Text);

            if (pw.CheckUsePositionWorkName())
            {
                pw.UpdatePositionWork();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
                GridView1.EditIndex = -1;
                BindData1();
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true);
            }
        }