Beispiel #1
0
        protected void btnSubmitMinistry_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertMinistryID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสกระทรวง')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertMinistryName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อกระทรวง')", true);
                return;
            }
            ClassMinistry m = new ClassMinistry();

            m.MINISTRY_ID   = Convert.ToInt32(txtInsertMinistryID.Text);
            m.MINISTRY_NAME = txtInsertMinistryName.Text;

            if (m.CheckUseMINISTRYID())
            {
                m.InsertMINISTRY();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสกระทรวงนี้ อยู่ในระบบแล้ว !')", true);
            }
        }
Beispiel #2
0
        void BindData1()
        {
            ClassMinistry m  = new ClassMinistry();
            DataTable     dt = m.GetMinistrySearch(txtSearchMinistryID.Text, txtSearchMinistryName.Text);

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Beispiel #3
0
        void BindData()
        {
            ClassMinistry m  = new ClassMinistry();
            DataTable     dt = m.GetMinistry("", "");

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

            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);
            ClassMinistry m  = new ClassMinistry();

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

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

            ClassMinistry m = new ClassMinistry(Convert.ToInt32(txtMinistryIDEdit.Text)
                                                , txtMinistryNameEdit.Text);

            m.UpdateMINISTRY();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
            GridView1.EditIndex = -1;
            BindData1();
        }
Beispiel #7
0
 protected void btnSearchMinistry_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearchMinistryID.Text) && string.IsNullOrEmpty(txtSearchMinistryName.Text))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);
         return;
     }
     else
     {
         ClassMinistry m  = new ClassMinistry();
         DataTable     dt = m.GetMinistrySearch(txtSearchMinistryID.Text, txtSearchMinistryName.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }