Exemplo n.º 1
0
        protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtYearName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ปีพุทธศักราช')", true);
                return;
            }
            ClassYear y = new ClassYear();
            y.YEAR_ID = Convert.ToInt32(txtYearName.Text);

            if (y.CheckUseYearName())
            {
                y.InsertYear();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true);
            }
        }
Exemplo n.º 2
0
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            TextBox txtYearNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtYearNameEdit");

            ClassYear y = new ClassYear(Convert.ToInt32(txtYearNameEdit.Text));

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