Exemple #1
0
        private bool AddOrganisation()
        {
            int  identityId = 0;
            bool success    = false;

            Entities.FacadeResult retVal = new Entities.FacadeResult(0);

            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            retVal = facOrganisation.Create(m_organisation, userId);

            if (!retVal.Success)
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();
                infringementDisplay.Visible = true;

                lblConfirmation.Text      = "There was an error adding the clients customer, please try again.";
                lblConfirmation.Visible   = true;
                lblConfirmation.ForeColor = Color.Red;
                success = false;
            }
            else
            {
                identityId = retVal.ObjectId;
                success    = true;
            }

            Repositories.DTOs.GeofenceNotificationSettings settings = new Repositories.DTOs.GeofenceNotificationSettings();
            settings.IdentityId = m_organisation.IdentityId;
            settings.Enabled    = chkBoxEnableNotification.Checked;
            if (chkBoxEnableNotification.Checked)
            {
                settings.NotificationType = Convert.ToInt32(cbNotificationType.SelectedValue);
                settings.NotifyWhen       = Convert.ToInt32(cbNotifyWhen.SelectedValue);
                settings.Recipient        = txtContactDetail.Text;
            }
            facOrganisation.AddOrUpdate(settings, userId);

            return(success);
        }
        /// <summary>
        /// Creates the location
        /// </summary>
        /// <returns>true if the create succeeded, false otherwise</returns>
        private bool CreateLocation()
        {
            Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation();
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult result = facOrganisationLocation.Create(m_location, _individual, userId);

            if (result.Success)
            {
                m_locationId = result.ObjectId;
                m_location.OrganisationLocationId = m_locationId;
            }
            else
            {
                infringementDisplay.Infringements = result.Infringements;
                infringementDisplay.DisplayInfringments();
            }

            return(result.Success);
        }
        /// <summary>
        /// Creates the reference
        /// </summary>
        /// <returns>true if the reference creation succeeded, false otherwise.</returns>
        private bool CreateReference()
        {
            bool retVal = false;

            Facade.IOrganisationReference facOrganisationReference = new Facade.Organisation();
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            m_referenceId = facOrganisationReference.Create(m_reference, userId);

            if (m_referenceId == 0)
            {
                retVal = false;
            }
            else
            {
                m_reference.OrganisationReferenceId = m_referenceId;
                retVal = true;
            }

            return(retVal);
        }
Exemple #4
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (cboPoint.SelectedValue == String.Empty)
                {
                    int ownerID = 0;

                    if (cboOwner.SelectedValue == string.Empty)
                    {
                        // Create a new client customer for the point owner (this can be upgraded to client in the future).
                        Entities.Organisation organisation = new Entities.Organisation();
                        organisation.OrganisationName = cboOwner.Text;
                        organisation.OrganisationType = eOrganisationType.ClientCustomer;
                        Facade.IOrganisation  facOrganisation = new Facade.Organisation();
                        Entities.FacadeResult result          = facOrganisation.Create(organisation, ((Entities.CustomPrincipal)Page.User).UserName);
                        if (result.Success)
                        {
                            ownerID = result.ObjectId;
                        }
                        else
                        {
                            // Organisation has already been created by someone else between validation and this call (unlikely)
                            ownerID = facOrganisation.GetForName(cboOwner.Text).IdentityId;
                        }
                    }
                    else
                    {
                        ownerID = int.Parse(cboOwner.SelectedValue);
                    }

                    // Set the point type, organisation, town, and name for the new point
                    switch ((eInstructionType)m_instruction.InstructionTypeId)
                    {
                    case eInstructionType.Drop:
                        Session[wizard.C_POINT_TYPE] = ePointType.Deliver;
                        Session[wizard.C_POINT_FOR]  = m_instruction.ClientsCustomerIdentityID;
                        break;

                    case eInstructionType.Load:
                        Session[wizard.C_POINT_TYPE] = ePointType.Collect;
                        Session[wizard.C_POINT_FOR]  = ownerID;
                        break;
                    }

                    Session[wizard.C_INSTRUCTION_INDEX] = m_instructionIndex;
                    Session[wizard.C_POINT_NAME]        = cboPoint.Text;
                    Session[wizard.C_TOWN_ID]           = Convert.ToInt32(cboTown.SelectedValue);

                    // The point name must be unique for this client
                    bool          foundPointName = false;
                    Facade.IPoint facPoint       = new Facade.Point();
                    DataSet       pointNames     = facPoint.GetAllForOrganisation((int)Session[wizard.C_POINT_FOR], ePointType.Any, cboPoint.Text);
                    foreach (DataRow row in pointNames.Tables[0].Rows)
                    {
                        if (((string)row["Description"]) == cboPoint.Text)
                        {
                            foundPointName = true;
                        }
                    }

                    if (foundPointName)
                    {
                        pnlCreateNewPoint.Visible = true;
                    }
                    else
                    {
                        // Allow the user to create the new point
                        GoToStep("CNP");
                    }
                }
                else
                {
                    int pointId = Convert.ToInt32(cboPoint.SelectedValue);

                    if (m_isUpdate)
                    {
                        if (m_instruction.InstructionID == 0)
                        {
                            // Adding a new instruction

                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Altering an existing instruction
                            // Cause the first collectdrop to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }
                        }
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Cause the first point to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                    }

                    GoToStep("PD");
                }
            }
        }
Exemple #5
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int identityId = -1;

                if (cboClient.SelectedValue == "")
                {
                    // The user has not selected an organistion, they may want to create a new one.
                    pnlCreateNewOrganisation.Visible = true;

                    if (chkCreateClient.Checked)
                    {
                        Facade.IOrganisation facOrganisation = new Facade.Organisation();

                        Entities.Organisation organisation = new Entities.Organisation();
                        organisation.OrganisationName        = cboClient.Text;
                        organisation.OrganisationDisplayName = cboClient.Text;
                        organisation.OrganisationType        = eOrganisationType.ClientCustomer;
                        organisation.IdentityStatus          = eIdentityStatus.Active;

                        string userId = ((Entities.CustomPrincipal)Page.User).UserName;

                        Entities.FacadeResult retVal = facOrganisation.Create(organisation, userId);
                        if (!retVal.Success)
                        {
                            infringementDisplay.Infringements = retVal.Infringements;
                            infringementDisplay.DisplayInfringments();
                            infringementDisplay.Visible = true;
                        }
                        else
                        {
                            identityId = retVal.ObjectId;
                        }
                    }
                }
                else
                {
                    identityId = Convert.ToInt32(cboClient.SelectedValue);
                }

                if (identityId > 0)
                {
                    if (m_isUpdate)
                    {
                        if (!m_isAmendment)
                        {
                            // Set the client's customer for this point
                            m_instruction.ClientsCustomerIdentityID = identityId;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }

                        // Display the point being used
                        GoToStep("P");
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (m_instruction.ClientsCustomerIdentityID != identityId)
                            {
                                // Remove all the point information because the client's customer has been changed
                                m_instruction.Point   = null;
                                m_instruction.PointID = 0;
                                m_instruction.ClientsCustomerIdentityID = identityId;

                                Session[wizard.C_INSTRUCTION] = m_instruction;
                            }
                        }
                        else
                        {
                            // Set the client's customer for this point
                            m_instruction.ClientsCustomerIdentityID = identityId;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }

                        GoToStep("P");
                    }
                }
            }
        }