void BindData1()
 {
     if (ddlSearchPosiGroup.SelectedIndex != 0)
     {
         ClassSalMinMax smm = new ClassSalMinMax();
         DataTable dt = smm.GetSalMinMax(ddlSearchPosiGroup.SelectedValue, "", "", "", "");
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
     if (ddlSearchPosi.SelectedIndex != 0)
     {
         ClassSalMinMax smm = new ClassSalMinMax();
         DataTable dt = smm.GetSalMinMax("", ddlSearchPosi.SelectedValue, "", "", "");
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
     if (!string.IsNullOrEmpty(txtSearchSalMin.Text))
     {
         ClassSalMinMax smm = new ClassSalMinMax();
         DataTable dt = smm.GetSalMinMax("", "", txtSearchSalMin.Text, "", "");
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
     if (!string.IsNullOrEmpty(txtSearchSalMax.Text))
     {
         ClassSalMinMax smm = new ClassSalMinMax();
         DataTable dt = smm.GetSalMinMax("", "", "", txtSearchSalMax.Text, "");
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
     if (!string.IsNullOrEmpty(txtSearchSalMin.Text))
     {
         ClassSalMinMax smm = new ClassSalMinMax();
         DataTable dt = smm.GetSalMinMax("", "", "", "", txtSearchSalMinTemp.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }
 protected void lbuRefresh_Click(object sender, EventArgs e)
 {
     ClearData();
     ClassSalMinMax smm = new ClassSalMinMax();
     DataTable dt = smm.GetSalMinMax("", "", "", "", "");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 void BindData()
 {
     ClassSalMinMax smm = new ClassSalMinMax();
     DataTable dt = smm.GetSalMinMax("", "", "", "", "");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            Label lblPosiGoverSalaryIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblPosiGoverSalaryIDEdit");
            DropDownList ddlPosiGoverSalaryGroupEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlPosiGoverSalaryGroupEdit");
            DropDownList ddlPosiGoverSalaryEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlPosiGoverSalaryEdit");
            TextBox txtPosiGoverSalaryMinEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtPosiGoverSalaryMinEdit");
            TextBox txtPosiGoverSalaryMaxEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtPosiGoverSalaryMaxEdit");
            TextBox txtPosiGoverSalaryMinTempEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtPosiGoverSalaryMinTempEdit");

            ClassSalMinMax smm = new ClassSalMinMax(Convert.ToInt32(lblPosiGoverSalaryIDEdit.Text)
                , Convert.ToInt32(ddlPosiGoverSalaryGroupEdit.SelectedValue)
                , Convert.ToInt32(ddlPosiGoverSalaryEdit.SelectedValue)
                , Convert.ToInt32(txtPosiGoverSalaryMinEdit.Text)
                , Convert.ToInt32(txtPosiGoverSalaryMaxEdit.Text)
                , Convert.ToInt32(txtPosiGoverSalaryMinTempEdit.Text));

            smm.UpdateSalMinMax();
            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);
            ClassSalMinMax smm = new ClassSalMinMax();
            smm.P_ID = id;
            smm.DeleteSalMinMax();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            if (ddlSearchPosiGroup.SelectedIndex != 0 || ddlSearchPosi.SelectedIndex != 0 || txtSearchSalMin.Text != "" || txtSearchSalMax.Text != "" || txtSearchSalMinTemp.Text != "")
            {
                GridView1.EditIndex = -1;
                BindData1();
            }
            else
            {
                GridView1.EditIndex = -1;
                BindData();
            }
        }
        protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            if (ddlInsertPosiGroup.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาเลือก ตำแหน่งประเภท')", true);
                return;
            }
            if (ddlInsertPosi.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาเลือก ตำแหน่่ง')", true);
                return;
            }
            ClassSalMinMax smm = new ClassSalMinMax();
            smm.P_POS_GOVER_ACADEMIC = Convert.ToInt32(ddlInsertPosiGroup.SelectedValue);
            smm.P_POS_ID = Convert.ToInt32(ddlInsertPosi.SelectedValue);
            smm.P_SAL_MIN = Convert.ToInt32(txtInsertSalMin.Text);
            smm.P_SAL_MAX = Convert.ToInt32(txtInsertSalMax.Text);
            smm.P_SAL_MIN_TEMP = Convert.ToInt32(txtInsertSalMinTemp.Text);

            smm.InsertSalMinMax();
            BindData();
            ClearData();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
        }
        protected void lbuSearch_Click(object sender, EventArgs e)
        {
            if (ddlSearchPosiGroup.SelectedIndex == 0 && ddlSearchPosi.SelectedIndex == 0 && txtSearchSalMin.Text == "" && txtSearchSalMax.Text == "" && txtSearchSalMinTemp.Text == "")
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);

                return;
            }
            else
            {
                if (ddlSearchPosiGroup.SelectedIndex != 0)
                {
                    ClassSalMinMax smm = new ClassSalMinMax();
                    DataTable dt = smm.GetSalMinMax(ddlSearchPosiGroup.SelectedValue, "", "", "", "");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    SetViewState(dt);
                }
                if (ddlSearchPosi.SelectedIndex != 0)
                {
                    ClassSalMinMax smm = new ClassSalMinMax();
                    DataTable dt = smm.GetSalMinMax("", ddlSearchPosi.SelectedValue, "", "", "");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    SetViewState(dt);
                }
                if (!string.IsNullOrEmpty(txtSearchSalMin.Text))
                {
                    ClassSalMinMax smm = new ClassSalMinMax();
                    DataTable dt = smm.GetSalMinMax("", "", txtSearchSalMin.Text, "", "");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    SetViewState(dt);
                }
                if (!string.IsNullOrEmpty(txtSearchSalMax.Text))
                {
                    ClassSalMinMax smm = new ClassSalMinMax();
                    DataTable dt = smm.GetSalMinMax("", "", "", txtSearchSalMax.Text, "");
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    SetViewState(dt);
                }
                if (!string.IsNullOrEmpty(txtSearchSalMin.Text))
                {
                    ClassSalMinMax smm = new ClassSalMinMax();
                    DataTable dt = smm.GetSalMinMax("", "", "", "", txtSearchSalMinTemp.Text);
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    SetViewState(dt);
                }
            }
        }