public override string getForm(CPBaseClass cp, int dstFormId, string rqs, DateTime rightNow, applicationClass application) { string returnHtml = ""; try { CPBlockBaseClass layout = cp.BlockNew(); CPCSBaseClass cs = cp.CSNew(); string body; layout.OpenLayout("MultiFormAjaxSample - Form 3"); // manuiplate the html, pre-populating fields, hiding parts not needed, etc. // get the resulting form from the layout object // add the srcFormId as a hidden // wrap it in a form for the javascript to use during submit body = layout.GetHtml(); body += cp.Html.Hidden(commonModule.rnSrcFormId, dstFormId.ToString()); returnHtml = cp.Html.Form(body, "", "", "mfaForm3", rqs); } catch (Exception ex) { cp.Site.ErrorReport(ex, "getForm"); } return returnHtml; }
public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application) { int nextFormId = srcFormId; try { string button; CPCSBaseClass cs = cp.CSNew(); string lastName; Boolean isInputOK = true; // ajax routines return a different name for button button = cp.Doc.GetText("ajaxButton"); if (button == "") { button = cp.Doc.GetText(commonModule.rnButton); } // check the input requirements // if user errors are handled with javascript, no need to display a message, just prevent save lastName = cp.Doc.GetText("lastName"); if (lastName == "") { isInputOK = false; } // if no user errors, process input // if errors, just return default nextFormId which will redisplay this form if (isInputOK) { application.lastName = lastName; application.changed = true; // determine the next form switch (button) { case commonModule.buttonNext: // nextFormId = commonModule.formIdThree; break; } } } catch (Exception ex) { cp.Site.ErrorReport(ex, "processForm"); } return nextFormId; }
// // // public static applicationClass getApplication(CPBaseClass cp, Boolean createRecordIfMissing) { applicationClass application = new applicationClass(); try { CPCSBaseClass cs = cp.CSNew(); CPCSBaseClass csSrc = cp.CSNew(); // get id of this user's application // use visit property if they keep the same application for the visit // use visitor property if each time they open thier browser, they get the previous application // use user property if they only get to the application when they are associated to the current user (they should be authenticated first) application.completed = false; application.changed = false; application.id = cp.Visit.GetInteger("multiformAjaxSample ApplicationId"); if (application.id != 0) { if (!cs.Open("MultiFormAjax Application", "(dateCompleted is null)")) { application.id = 0; } } if (cs.OK()) { application.firstName = cs.GetText("firstName"); application.lastName = cs.GetText("lastName"); application.email = cs.GetText("email"); } else { if (csSrc.Open("people", "id=" + cp.User.Id)) { application.firstName = csSrc.GetText("firstName"); application.lastName = csSrc.GetText("lastName"); application.email = csSrc.GetText("email"); } csSrc.Close(); } cs.Close(); } catch (Exception ex) { cp.Site.ErrorReport(ex, "Error in getApplication"); } return application; }
// // // public static applicationClass getApplication(CPBaseClass cp, Boolean createRecordIfMissing) { applicationClass application = new applicationClass(); try { CPCSBaseClass cs = cp.CSNew(); CPCSBaseClass csSrc = cp.CSNew(); // get id of this user's application // use visit property if they keep the same application for the visit // use visitor property if each time they open thier browser, they get the previous application // use user property if they only get to the application when they are associated to the current user (they should be authenticated first) application.completed = false; application.changed = false; application.id = cp.Visit.GetInteger("multiformAjaxSample ApplicationId"); if (application.id != 0) { if (!cs.Open("MultiFormAjax Application", "(dateCompleted is null)")) { application.id = 0; } } if (cs.OK()) { application.firstName = cs.GetText("firstName"); application.lastName = cs.GetText("lastName"); application.email = cs.GetText("email"); } else { if (csSrc.Open("people", "id=" + cp.User.Id)) { application.firstName = csSrc.GetText("firstName"); application.lastName = csSrc.GetText("lastName"); application.email = csSrc.GetText("email"); } csSrc.Close(); } cs.Close(); } catch (Exception ex) { cp.Site.ErrorReport(ex, "Error in getApplication"); } return(application); }
public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application) { int nextFormId = srcFormId; try { string button; CPCSBaseClass cs = cp.CSNew(); // ajax routines return a different name for button button = cp.Doc.GetText("ajaxButton"); if (button == "") { button = cp.Doc.GetText(commonModule.rnButton); } if (button == commonModule.buttonFinish) { // process the form application.completed = true; application.changed = true; } // determine the next form switch (button) { case commonModule.buttonPrevious: // nextFormId = commonModule.formIdTwo; break; case commonModule.buttonFinish: // nextFormId = commonModule.formIdFour; break; } } catch (Exception ex) { cp.Site.ErrorReport(ex, "processForm"); } return nextFormId; }
// // // public static void saveApplication(CPBaseClass cp, applicationClass application, DateTime rightNow) { try { CPCSBaseClass cs = cp.CSNew(); if (application.changed) { if (application.id > 0) { cs.Open(cnMultiFormAjaxApplications, "(id=" + application.id + ")"); } if (!cs.OK()) { if (cs.Insert("MultiFormAjax Application")) { // // create a new record. // Set application Id incase needed later // Set visit property to save the application Id // application.id = cs.GetInteger("id"); cp.Visit.SetProperty("multiformAjaxSample ApplicationId", application.id.ToString()); cs.SetField("visitId", cp.Visit.Id.ToString()); } } if (cs.OK()) { cs.SetField("firstName", application.firstName); cs.SetField("lastName", application.lastName); cs.SetField("email", application.email); if (application.completed) { cs.SetField("datecompleted", rightNow.ToString()); } } cs.Close(); } } catch (Exception ex) { cp.Site.ErrorReport(ex, "Error in getApplication"); } } // End saveApplication
public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application) { int nextFormId = srcFormId; try { string button; CPCSBaseClass cs = cp.CSNew(); // ajax routines return a different name for button button = cp.Doc.GetText("ajaxButton"); if (button == "") { button = cp.Doc.GetText(commonModule.rnButton); } if ((button == commonModule.buttonSave) | (button == commonModule.buttonOK)) { // process the form } // determine the next form switch (button) { case commonModule.buttonRestart: // nextFormId = commonModule.formIdOne; break; } } catch (Exception ex) { cp.Site.ErrorReport(ex, "processForm"); } return nextFormId; }
public override string getForm(CPBaseClass cp, int dstFormId, string rqs, DateTime rightNow, applicationClass application) { string returnHtml = ""; try { CPBlockBaseClass layout = cp.BlockNew(); CPCSBaseClass cs = cp.CSNew(); string body; layout.OpenLayout("MultiFormAjaxSample - Form 3"); // manuiplate the html, pre-populating fields, hiding parts not needed, etc. // get the resulting form from the layout object // add the srcFormId as a hidden // wrap it in a form for the javascript to use during submit body = layout.GetHtml(); body += cp.Html.Hidden(commonModule.rnSrcFormId, dstFormId.ToString()); returnHtml = cp.Html.Form(body, "", "", "mfaForm3", rqs); } catch (Exception ex) { cp.Site.ErrorReport(ex, "getForm"); } return(returnHtml); }
public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application) { int nextFormId = srcFormId; try { string button; CPCSBaseClass cs = cp.CSNew(); // ajax routines return a different name for button button = cp.Doc.GetText("ajaxButton"); if (button == "") { button = cp.Doc.GetText(commonModule.rnButton); } if (button == commonModule.buttonFinish) { // process the form application.completed = true; application.changed = true; } // determine the next form switch (button) { case commonModule.buttonPrevious: // nextFormId = commonModule.formIdTwo; break; case commonModule.buttonFinish: // nextFormId = commonModule.formIdFour; break; } } catch (Exception ex) { cp.Site.ErrorReport(ex, "processForm"); } return(nextFormId); }
public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application) { int nextFormId = srcFormId; try { string button; CPCSBaseClass cs = cp.CSNew(); string firstName; Boolean isInputOK = true; // ajax routines return a different name for button button = cp.Doc.GetText("ajaxButton"); if (button == "") { button = cp.Doc.GetText(commonModule.rnButton); } // check the input requirements // if user errors are handled with javascript, no need to display a message, just prevent save firstName = cp.Doc.GetText("firstName"); if (firstName == "") { isInputOK = false; } // if no user errors, process input // if errors, just return default nextFormId which will redisplay this form if (isInputOK) { application.firstName = firstName; application.changed = true; // determine the next form switch (button) { case commonModule.buttonNext: // nextFormId = commonModule.formIdTwo; break; } } } catch (Exception ex) { cp.Site.ErrorReport(ex, "processForm"); } return(nextFormId); }
public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application) { int nextFormId = srcFormId; try { string button; CPCSBaseClass cs = cp.CSNew(); // ajax routines return a different name for button button = cp.Doc.GetText("ajaxButton"); if (button == "") { button = cp.Doc.GetText(commonModule.rnButton); } if ((button == commonModule.buttonSave) | (button == commonModule.buttonOK)) { // process the form } // determine the next form switch (button) { case commonModule.buttonRestart: // nextFormId = commonModule.formIdOne; break; } } catch (Exception ex) { cp.Site.ErrorReport(ex, "processForm"); } return(nextFormId); }
public abstract int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightNow, applicationClass application);
public abstract string getForm(CPBaseClass cp, int dstFormId, string rqs, DateTime rightNow, applicationClass application);
// // // public static void saveApplication(CPBaseClass cp, applicationClass application, DateTime rightNow) { try { CPCSBaseClass cs = cp.CSNew(); if (application.changed ){ if (application.id > 0) { cs.Open(cnMultiFormAjaxApplications, "(id=" + application.id + ")"); } if (!cs.OK()) { if (cs.Insert("MultiFormAjax Application")) { // // create a new record. // Set application Id incase needed later // Set visit property to save the application Id // application.id = cs.GetInteger("id"); cp.Visit.SetProperty("multiformAjaxSample ApplicationId", application.id.ToString()); cs.SetField("visitId", cp.Visit.Id.ToString()); } } if (cs.OK()) { cs.SetField("firstName", application.firstName); cs.SetField("lastName", application.lastName); cs.SetField("email", application.email); if (application.completed) { cs.SetField("datecompleted", rightNow.ToString()); } } cs.Close(); } } catch (Exception ex) { cp.Site.ErrorReport(ex, "Error in getApplication"); } }
abstract public string getForm(CPBaseClass cp, int dstFormId, string rqs, DateTime rightNow, applicationClass application);
abstract public int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightNow, applicationClass application);