예제 #1
0
        protected void btnSubmitGender_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertGenderID.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสเพศ')", true);
                return;
            }
            if (string.IsNullOrEmpty(txtInsertGenderName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อเพศ')", true);
                return;
            }
            ClassGender g = new ClassGender();

            g.Gender_ID   = Convert.ToInt32(txtInsertGenderID.Text);
            g.Gender_Name = txtInsertGenderName.Text;

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