protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertRankNameFull.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อยศเต็ม')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertRankNameSmall.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อยศย่อ')", true);
                return;
            }
            ClassRank r = new ClassRank();
            r.RANK_NAME_TH = txtInsertRankNameFull.Text;
            r.RANK_NAME_TH_MIN = txtInsertRankNameSmall.Text;

            if (r.CheckUseRankNameInsert())
            {
                r.InsertRank();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true);
            }
        }
 protected void lbuRefresh_Click(object sender, EventArgs e)
 {
     ClearData();
     ClassRank r = new ClassRank();
     DataTable dt = r.GetRank("", "");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 protected void lbuSearch_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearchRankNameFull.Text) && string.IsNullOrEmpty(txtSearchRankNameSmall.Text))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);
         return;
     }
     else
     {
         ClassRank r = new ClassRank();
         DataTable dt = r.GetRank(txtSearchRankNameFull.Text, txtSearchRankNameSmall.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }
        protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
            ClassRank r = new ClassRank();
            r.RANK_ID = id;
            r.DeleteRank();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            GridView1.EditIndex = -1;
            BindData1();
        }
 void BindData1()
 {
     ClassRank r = new ClassRank();
     DataTable dt = r.GetRank(txtSearchRankNameFull.Text, txtSearchRankNameSmall.Text);
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 void BindData()
 {
     ClassRank r = new ClassRank();
     DataTable dt = r.GetRank("", "");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            Label lblRankIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblRankIDEdit");
            TextBox txtRankNameFullEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtRankNameFullEdit");
            TextBox txtRankNameSmallEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtRankNameSmallEdit");

            ClassRank r = new ClassRank(Convert.ToInt32(lblRankIDEdit.Text)
                , txtRankNameFullEdit.Text
                , txtRankNameSmallEdit.Text);

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