Beispiel #1
0
        void BindData1()
        {
            ClassProvince p  = new ClassProvince();
            DataTable     dt = p.GetProvinceSearch(txtSearchProvinceID.Text, txtSearchProvinceTH.Text, txtSearchProvinceEN.Text);

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Beispiel #2
0
        void BindData()
        {
            ClassProvince p  = new ClassProvince();
            DataTable     dt = p.GetProvince("", "", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Beispiel #3
0
        protected void btnSearchRefresh_Click(object sender, EventArgs e)
        {
            ClearData();
            ClassProvince p  = new ClassProvince();
            DataTable     dt = p.GetProvince("", "", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Beispiel #4
0
        protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e)
        {
            int           id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
            ClassProvince p  = new ClassProvince();

            p.PROVINCE_ID = id;
            p.DeleteProvince();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            GridView1.EditIndex = -1;
            BindData1();
        }
Beispiel #5
0
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtProvinceIDEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtProvinceIDEdit");
            TextBox txtProvinceTHEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtProvinceTHEdit");
            TextBox txtProvinceENEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtProvinceENEdit");

            ClassProvince p = new ClassProvince(Convert.ToInt32(txtProvinceIDEdit.Text)
                                                , txtProvinceTHEdit.Text
                                                , txtProvinceENEdit.Text);

            p.UpdateProvince();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
            GridView1.EditIndex = -1;
            BindData1();
        }
Beispiel #6
0
        protected void btnSearchProvince_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSearchProvinceID.Text) && string.IsNullOrEmpty(txtSearchProvinceTH.Text) && string.IsNullOrEmpty(txtSearchProvinceEN.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);

                return;
            }
            else
            {
                ClassProvince p  = new ClassProvince();
                DataTable     dt = p.GetProvinceSearch(txtSearchProvinceID.Text, txtSearchProvinceTH.Text, txtSearchProvinceEN.Text);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                SetViewState(dt);
            }
        }
Beispiel #7
0
        protected void btnSubmitProvince_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertProvinceID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสจังหวัด')", true);
                return;
            }

            if (string.IsNullOrEmpty(txtInsertProvinceTH.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อจังหวัดภาษาไทย')", true);
                return;
            }

            if (string.IsNullOrEmpty(txtInsertProvinceEN.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อจังหวัดภาษาอังกฤษ')", true);
                return;
            }
            ClassProvince p = new ClassProvince();

            p.PROVINCE_ID = Convert.ToInt32(txtInsertProvinceID.Text);
            p.PROVINCE_TH = txtInsertProvinceTH.Text;
            p.PROVINCE_EN = txtInsertProvinceEN.Text;

            if (p.CheckUseProvinceID())
            {
                p.InsertProvince();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสรหัสจังหวัดนี้ อยู่ในระบบแล้ว !')", true);
            }
        }