Beispiel #1
0
        void BindData1()
        {
            ClassDistrict d  = new ClassDistrict();
            DataTable     dt = d.GetDistrictSearch(txtSearchDistrictID.Text, txtSearchDistrictTH.Text, txtSearchDistrictEN.Text, txtSearchAmphurID.Text, txtSearchProvinceID.Text, txtSearchPostCode.Text, txtSearchNote.Text);

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Beispiel #2
0
        protected void btnSubmitDistrict_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertDistrictID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสตำบล')", true);
                return;
            }

            if (string.IsNullOrEmpty(txtInsertDistrictTH.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อตำบลภาษาไทย')", true);
                return;
            }

            if (string.IsNullOrEmpty(txtInsertDistrictEN.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อตำบลภาษาอังกฤษ')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertAmphurID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสอำเภอ')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertProvinceID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสจังหวัด')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertPostCode.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสไปรษณีย์')", true);
                return;
            }

            ClassDistrict d = new ClassDistrict();

            d.DISTRICT_ID = Convert.ToInt32(txtInsertDistrictID.Text);
            d.DISTRICT_TH = txtInsertDistrictTH.Text;
            d.DISTRICT_EN = txtInsertDistrictEN.Text;
            d.AMPHUR_ID   = Convert.ToInt32(txtInsertAmphurID.Text);
            d.PROVINCE_ID = Convert.ToInt32(txtInsertProvinceID.Text);
            d.POST_CODE   = Convert.ToInt32(txtInsertPostCode.Text);
            d.NOTE        = txtInsertNote.Text;

            if (d.CheckUseDistrictID())
            {
                d.InsertDistrict();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสอำเภอนี้ อยู่ในระบบแล้ว !')", true);
            }
        }
Beispiel #3
0
        void BindData()
        {
            ClassDistrict d  = new ClassDistrict();
            DataTable     dt = d.GetDistrict("", "", "", "", "", "", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Beispiel #4
0
        protected void btnSearchRefresh_Click(object sender, EventArgs e)
        {
            ClearData();
            ClassDistrict d  = new ClassDistrict();
            DataTable     dt = d.GetDistrict("", "", "", "", "", "", "");

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

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

            GridView1.EditIndex = -1;
            BindData1();
        }
Beispiel #6
0
        protected void btnSearchDistrict_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSearchDistrictID.Text) && string.IsNullOrEmpty(txtSearchDistrictTH.Text) && string.IsNullOrEmpty(txtSearchDistrictEN.Text) && string.IsNullOrEmpty(txtSearchAmphurID.Text) && string.IsNullOrEmpty(txtSearchProvinceID.Text) && string.IsNullOrEmpty(txtSearchPostCode.Text) && string.IsNullOrEmpty(txtSearchNote.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);

                return;
            }
            else
            {
                ClassDistrict d  = new ClassDistrict();
                DataTable     dt = d.GetDistrictSearch(txtSearchDistrictID.Text, txtSearchDistrictTH.Text, txtSearchDistrictEN.Text, txtSearchAmphurID.Text, txtSearchProvinceID.Text, txtSearchPostCode.Text, txtSearchNote.Text);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                SetViewState(dt);
            }
        }
Beispiel #7
0
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtDistrictIDEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDistrictIDEdit");
            TextBox txtDistrictTHEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDistrictTHEdit");
            TextBox txtDistrictENEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDistrictENEdit");
            TextBox txtAmphurIDEdit   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtAmphurIDEdit");

            TextBox txtProvinceIDEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtProvinceIDEdit");
            TextBox txtPostCodeEdit   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtPostCodeEdit");
            TextBox txtNoteEdit       = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtNoteEdit");

            ClassDistrict d = new ClassDistrict(Convert.ToInt32(txtDistrictIDEdit.Text)
                                                , txtDistrictTHEdit.Text
                                                , txtDistrictENEdit.Text
                                                , Convert.ToInt32(txtAmphurIDEdit.Text)
                                                , Convert.ToInt32(txtProvinceIDEdit.Text)
                                                , Convert.ToInt32(txtPostCodeEdit.Text)
                                                , txtNoteEdit.Text);

            d.UpdateDistrict();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
            GridView1.EditIndex = -1;
            BindData1();
        }