Exemplo n.º 1
0
        void BindData1()
        {
            ClassAmphur a  = new ClassAmphur();
            DataTable   dt = a.GetAmphurSearch(txtSearchAmphurID.Text, txtSearchAmphurTH.Text, txtSearchAmphurEN.Text, txtSearchProvinceID.Text);

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Exemplo n.º 2
0
        void BindData()
        {
            ClassAmphur a  = new ClassAmphur();
            DataTable   dt = a.GetAmphur("", "", "", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Exemplo n.º 3
0
        protected void btnSearchRefresh_Click(object sender, EventArgs e)
        {
            ClearData();
            ClassAmphur a  = new ClassAmphur();
            DataTable   dt = a.GetAmphur("", "", "", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Exemplo n.º 4
0
        protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e)
        {
            int         id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
            ClassAmphur a  = new ClassAmphur();

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

            GridView1.EditIndex = -1;
            BindData1();
        }
Exemplo n.º 5
0
        protected void btnSearchAmphur_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSearchAmphurID.Text) && string.IsNullOrEmpty(txtSearchAmphurTH.Text) && string.IsNullOrEmpty(txtSearchAmphurEN.Text) && string.IsNullOrEmpty(txtSearchProvinceID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);

                return;
            }
            else
            {
                ClassAmphur a  = new ClassAmphur();
                DataTable   dt = a.GetAmphurSearch(txtSearchAmphurID.Text, txtSearchAmphurTH.Text, txtSearchAmphurEN.Text, txtSearchProvinceID.Text);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                SetViewState(dt);
            }
        }
Exemplo n.º 6
0
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtAmphurIDEdit   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtAmphurIDEdit");
            TextBox txtAmphurTHEdit   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtAmphurTHEdit");
            TextBox txtAmphurENEdit   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtAmphurENEdit");
            TextBox txtProvinceIDEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtProvinceIDEdit");

            ClassAmphur a = new ClassAmphur(Convert.ToInt32(txtAmphurIDEdit.Text)
                                            , txtAmphurTHEdit.Text
                                            , txtAmphurENEdit.Text
                                            , Convert.ToInt32(txtProvinceIDEdit.Text));

            a.UpdateAmphur();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
            GridView1.EditIndex = -1;
            BindData1();
        }
Exemplo n.º 7
0
        protected void btnSubmitAmphur_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertAmphurID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสอำเภอ')", true);
                return;
            }

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

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

            a.AMPHUR_ID   = Convert.ToInt32(txtInsertAmphurID.Text);
            a.AMPHUR_TH   = txtInsertAmphurTH.Text;
            a.AMPHUR_EN   = txtInsertAmphurEN.Text;
            a.PROVINCE_ID = Convert.ToInt32(txtInsertProvinceID.Text);

            if (a.CheckUseAmphurID())
            {
                a.InsertAmphur();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสอำเภอนี้ อยู่ในระบบแล้ว !')", true);
            }
        }