protected void saveAsNewButton_Click( object sender, EventArgs e ) { BHLProvider bp = new BHLProvider(); if ( validate() ) { if ( codeTextBox.Text.Trim().Length == 0 ) { errorControl.AddErrorText( "Please include a unique institution code before saving" ); errorControl.Visible = true; return; } else { CustomGenericList<Institution> institutions = bp.InstituationSelectAll(); string code = codeTextBox.Text.Trim().ToUpper(); foreach ( Institution inst in institutions ) { if ( inst.InstitutionCode.ToUpper().Equals( code ) ) { errorControl.AddErrorText( "The institution code " + inst.InstitutionCode.ToUpper() + " is not a unique code, please use another one." ); errorControl.Visible = true; return; } } } Institution institution = new Institution( codeTextBox.Text.Trim().ToUpper(), nameTextBox.Text.Trim(), noteTextBox.Text.Trim(), urlTextBox.Text.Trim(), chkIsMemberLibrary.Checked ); institution.IsNew = true; bp.SaveInstitution( institution ); } else { return; } Response.Redirect( "/Admin/Dashboard.aspx" ); }
protected void saveButton_Click( object sender, EventArgs e ) { if ( validate() ) { if ( hidCode.Value.Length == 0 ) { errorControl.AddErrorText("Please select an instution before saving" ); errorControl.Visible = true; return; } Institution institution = new Institution( hidCode.Value, nameTextBox.Text.Trim(), noteTextBox.Text.Trim(), urlTextBox.Text.Trim(), chkIsMemberLibrary.Checked ); institution.IsNew = false; BHLProvider bp = new BHLProvider(); bp.SaveInstitution( institution ); } else { return; } Response.Redirect( "/Admin/Dashboard.aspx" ); }