Exemple #1
0
        protected void dgUpdate_CourseSection(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            Label        lblTempID         = (Label)e.Item.Cells[0].FindControl("txtID");
            DropDownList txtTempCourseCode = (DropDownList)e.Item.Cells[0].FindControl("ddlCourseCode");
            TextBox      txtTempSectionNo  = (TextBox)e.Item.Cells[1].FindControl("txtSectionNo");

            Regex sectionRegex = new Regex(@"^\d{1,5}$");
            Match checkSection = sectionRegex.Match(txtTempSectionNo.Text);


            if (lblTempID.Text.Trim() == "" || txtTempCourseCode.Text.Trim() == "" || txtTempSectionNo.Text.Trim() == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Please fill in the course section information first!', 'error')</script>'");
            }
            else if (!checkSection.Success)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Section number must be digit only', 'error')</script>'");
            }
            else
            {
                CourseSection lec = new CourseSection();
                if (lec.Update(lblTempID.Text, txtTempCourseCode.Text, txtTempSectionNo.Text) == false)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'This " + txtTempSectionNo.Text + " course section cannot have same section no, try another number!', 'error')</script>'");
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Updated!', text: 'This course section " + txtTempSectionNo.Text + " (" + txtTempCourseCode.Text + ") course section is updated successfully', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'cpCourseSection.aspx'; }});</script>'");
                }
            }
        }