Esempio n. 1
0
    public static object InsertBuildingPermit(List <BuildingPDirty> insertParams)
    {
        try
        {
            int rowsInserted = 0;

            Validator validator = new Validator(insertParams[0]);

            if (validator.AllAreValid)
            {
                BuildingPDirty buildingPDirty = insertParams[0];
                buildingPDirty.PassedValidation = true;

                BuildingP           buildingP           = new BuildingP(insertParams[0]);
                BuildingPCollection buildingPCollection = new BuildingPCollection();
                buildingPCollection.BuildingPList.Add(buildingP);

                DataA dataA = new DataA();
                rowsInserted = dataA.InsertPermitData(buildingPCollection);
            }
            else
            {
                return("inputsInvalid");
            }

            return(rowsInserted);
        }
        catch (Exception)
        {
            return("serverError");
        }
    }
        protected void SubmitButtonClick(object sender, EventArgs e)
        {
            try
            {
                BuildingPDirty buildingPDirty = new BuildingPDirty(
                    tbxApplicantFirstName.Value,
                    tbxApplicantLastName.Value,
                    tbxSquareFeet.Value,
                    tbxHeightInFeet.Value,
                    tbxStartDate.Value,
                    tbxEstimatedEndDate.Value,
                    tbxAddress.Value,
                    tbxCity.Value,
                    tbxZip.Value,
                    ddlRemodelOrNewConstruction.SelectedValue);

                Validator validatorSubmission = new Validator(buildingPDirty);

                if (!validatorSubmission.AllAreValid)
                {
                    buildingPDirty.PassedValidation = false;
                    ToggleInputValidationMessages(validatorSubmission);
                }
                else
                {
                    buildingPDirty.PassedValidation = true;

                    BuildingP buildingP = new BuildingP(buildingPDirty);
                    ToggleInputValidationMessages(validatorSubmission);

                    BuildPCollection buildingPCollection = new BuildPCollection();
                    buildingPCollection.BuildingPList.Add(buildingP);

                    DataA dataA = new DataA();

                    if (dataA.InsertPermitData(buildingPCollection) == 1)
                    {
                        insertFeedback.InnerHtml =
                            "<span style='color:green;font-weight:bold;'>Application submitted</span>";
                    }
                    else
                    {
                        insertFeedback.InnerHtml =
                            "<span style='color:red;font-weight:bold;'>Application submission failed. Please try again.</span>";
                    }

                    LoadPermits();
                }
            }
            catch (Exception ex)
            {
                this.ReportExceptions(ex, "Error while saving new permit. ", "");
            }
        }