Esempio n. 1
0
        protected void btnSubmitMonth_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertMonthID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสเดือน')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertMonthNameSmall.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อเดือนย่อ')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertMonthNameFull.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อเดือนเต็ม')", true);
                return;
            }
            ClassMonth m = new ClassMonth();

            m.MONTH_ID    = Convert.ToInt32(txtInsertMonthID.Text);
            m.MONTH_SHORT = txtInsertMonthNameSmall.Text;
            m.MONTH_LONG  = txtInsertMonthNameFull.Text;

            m.InsertMonth();
            BindData();
            ClearData();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
        }
Esempio n. 2
0
        void BindData1()
        {
            ClassMonth m  = new ClassMonth();
            DataTable  dt = m.GetMonthSearch(txtSearchMonthID.Text, txtSearchMonthNameSmall.Text, txtSearchMonthNameFull.Text);

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Esempio n. 3
0
        void BindData()
        {
            ClassMonth m  = new ClassMonth();
            DataTable  dt = m.GetMonth("", "", "");

            GridView1.DataSource = dt;
            GridView1.DataBind();
            SetViewState(dt);
        }
Esempio n. 4
0
        protected void btnSearchRefresh_Click(object sender, EventArgs e)
        {
            ClearData();
            ClassMonth m  = new ClassMonth();
            DataTable  dt = m.GetMonth("", "", "");

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

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

            GridView1.EditIndex = -1;
            BindData1();
        }
Esempio n. 6
0
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtMonthIDEdit        = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMonthIDEdit");
            TextBox txtMonthNameSmallEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMonthNameSmallEdit");
            TextBox txtMonthNameFullEdit  = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMonthNameFullEdit");

            ClassMonth m = new ClassMonth(Convert.ToInt32(txtMonthIDEdit.Text)
                                          , txtMonthNameSmallEdit.Text
                                          , txtMonthNameFullEdit.Text);

            m.UpdateMonth();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
            GridView1.EditIndex = -1;
            BindData1();
        }
Esempio n. 7
0
 protected void btnSearchMonth_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearchMonthID.Text) && string.IsNullOrEmpty(txtSearchMonthNameSmall.Text) && string.IsNullOrEmpty(txtSearchMonthNameFull.Text))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);
         return;
     }
     else
     {
         ClassMonth m  = new ClassMonth();
         DataTable  dt = m.GetMonthSearch(txtSearchMonthID.Text, txtSearchMonthNameSmall.Text, txtSearchMonthNameFull.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }