protected void lbuRefresh_Click(object sender, EventArgs e)
 {
     ClearData();
     ClassClanInsignia ci = new ClassClanInsignia();
     DataTable dt = ci.GetClanInsignia("");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 protected void lbuSearch_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearchClanInsigName.Text))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);
         return;
     }
     else
     {
         ClassClanInsignia ci = new ClassClanInsignia();
         DataTable dt = ci.GetClanInsignia(txtSearchClanInsigName.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }
        protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertClanInsigName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อกลุ่มเครื่องราชฯ')", true);
                return;
            }
            ClassClanInsignia ci = new ClassClanInsignia();
            ci.NAME_CLANINSIGNIA_THA = txtInsertClanInsigName.Text;

            if (ci.CheckUseClanInsignia())
            {
                ci.InsertClanInsignia();
                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);
            ClassClanInsignia ci = new ClassClanInsignia();
            ci.ID_CLANINSIGNIA = id;
            ci.DeleteClanInsignia();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            GridView1.EditIndex = -1;
            BindData1();
        }
 void BindData1()
 {
     ClassClanInsignia ci = new ClassClanInsignia();
     DataTable dt = ci.GetClanInsignia(txtSearchClanInsigName.Text);
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 void BindData()
 {
     ClassClanInsignia ci = new ClassClanInsignia();
     DataTable dt = ci.GetClanInsignia("");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            Label lblClanInsigIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblClanInsigIDEdit");
            TextBox txtClanInsigNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtClanInsigNameEdit");

            ClassClanInsignia ci = new ClassClanInsignia(Convert.ToInt32(lblClanInsigIDEdit.Text),
                txtClanInsigNameEdit.Text);

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