protected void lbuRefresh_Click(object sender, EventArgs e)
 {
     ClearData();
     ClassNational n = new ClassNational();
     DataTable dt = n.GetNational("", "", "");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
        protected void lbuSearch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSearchNationID.Text) && string.IsNullOrEmpty(txtSearchNationENG.Text) && string.IsNullOrEmpty(txtSearchNationTHA.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);

                return;
            }
            else
            {
                ClassNational n = new ClassNational();
                DataTable dt = n.GetNational(txtSearchNationID.Text, txtSearchNationENG.Text, txtSearchNationTHA.Text);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                SetViewState(dt);
            }
        }
        protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertNationID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ อักษรย่อสัญชาติ/เชื้อชาติ 2 ตัวอักษร')", true);
                return;
            }

            if (string.IsNullOrEmpty(txtInsertNationENG.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อสัญชาติ/เชื้อชาติภาษาอังกฤษ')", true);
                return;
            }

            if (string.IsNullOrEmpty(txtInsertNationTHA.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อสัญชาติ/เชื้อชาติภาษาไทย')", true);
                return;
            }
            ClassNational n = new ClassNational();
            n.NATION_ID = txtInsertNationID.Text;
            n.NATION_ENG = txtInsertNationENG.Text;
            n.NATION_THA = txtInsertNationTHA.Text;

            if (n.CheckUseNationNameInsert())
            {
                n.InsertNational();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true);
            }
        }
 void BindData1()
 {
     ClassNational n = new ClassNational();
     DataTable dt = n.GetNational(txtSearchNationID.Text, txtSearchNationENG.Text, txtSearchNationTHA.Text);
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 void BindData()
 {
     ClassNational n = new ClassNational();
     DataTable dt = n.GetNational("", "", "");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            Label lblNationSEQ = (Label)GridView1.Rows[e.RowIndex].FindControl("lblNationSEQ");
            TextBox txtNationIDEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtNationIDEdit");
            TextBox txtNationENGEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtNationENGEdit");
            TextBox txtNationTHAEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtNationTHAEdit");

            ClassNational n = new ClassNational(Convert.ToInt32(lblNationSEQ.Text)
                , txtNationIDEdit.Text
                , txtNationENGEdit.Text
                , txtNationTHAEdit.Text);

            if (n.CheckUseNationNameUpdate())
            {
                n.UpdateNational();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
                GridView1.EditIndex = -1;
                BindData1();
            }
            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);
            ClassNational n = new ClassNational();
            n.NATION_SEQ = id;
            n.DeleteNational();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            GridView1.EditIndex = -1;
            BindData1();
        }