예제 #1
0
        protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            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_SHORT = txtInsertMonthNameSmall.Text;
            m.MONTH_LONG = txtInsertMonthNameFull.Text;

            if (m.CheckUseMonthNameInsert())
            {
                m.InsertMonth();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true);
            }
        }
예제 #2
0
 protected void lbuRefresh_Click(object sender, EventArgs e)
 {
     ClearData();
     ClassMonth m = new ClassMonth();
     DataTable dt = m.GetMonth("", "");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
예제 #3
0
 protected void lbuSearch_Click(object sender, EventArgs e)
 {
     if (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.GetMonth(txtSearchMonthNameSmall.Text, txtSearchMonthNameFull.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }
예제 #4
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();
        }
예제 #5
0
 void BindData1()
 {
     ClassMonth m = new ClassMonth();
     DataTable dt = m.GetMonth(txtSearchMonthNameSmall.Text, txtSearchMonthNameFull.Text);
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
예제 #6
0
 void BindData()
 {
     ClassMonth m = new ClassMonth();
     DataTable dt = m.GetMonth("", "");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
예제 #7
0
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            Label lblMonthIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblMonthIDEdit");
            TextBox txtMonthNameSmallEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMonthNameSmallEdit");
            TextBox txtMonthNameFullEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMonthNameFullEdit");

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

            if (m.CheckUseMonthNameUpdate())
            {
                m.UpdateMonth();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
                GridView1.EditIndex = -1;
                BindData1();
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true);
            }
        }