コード例 #1
0
        /// <summary>
        /// Deletes cheque requests for client or office.
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="selectedChequeRequests">Collection of cheque requests for client or office for deletion</param>
        /// <param name="isClientChequeRequest">Flag whether deletion is for client or office</param>
        /// <returns>Deletes cheque requests for client or office.</returns>
        public ChequeRequestReturnValue DeleteChequeRequests(Guid logonId, List<int> selectedChequeRequestsIds, bool isClientChequeRequest)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    if (selectedChequeRequestsIds.Count > 0)
                    {
                        SrvClientChequeRequest srvClientChequeRequest = null;
                        SrvOfficeChequeRequest srvOfficeChequeRequest = null;

                        if (isClientChequeRequest)
                        {
                            srvClientChequeRequest = new SrvClientChequeRequest();
                        }
                        else
                        {
                            srvOfficeChequeRequest = new SrvOfficeChequeRequest();
                        }

                        for (int index = 0; index < selectedChequeRequestsIds.Count; index++)
                        {
                            int chequeRequestId = selectedChequeRequestsIds[index];

                            if (isClientChequeRequest)
                            {
                                srvClientChequeRequest.Delete(chequeRequestId, UserInformation.Instance.UserMemberId, DateTime.Now);
                            }
                            else
                            {
                                srvOfficeChequeRequest.Delete(chequeRequestId, UserInformation.Instance.UserMemberId, DateTime.Now);
                            }
                        }
                    }
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }

            return returnValue;
        }
コード例 #2
0
        /// <summary>
        /// Adds or edits office cheque requests depending on the 'IsClientChequeRequest' property
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="chequeRequest">ChequeRequest properties to add/edit cheque request.</param>
        /// <returns>Returns cheque request id after adding or editting cheque request.</returns>
        public ChequeRequestReturnValue SaveOfficeChequeRequest(Guid logonId, ChequeRequest chequeRequest)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    //163 - Create Office Cheque Requests

                    //if (!UserSecuritySettings.GetUserSecuitySettings(163))
                    if (!UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.CreateOfficeChequeRequest))
                        throw new Exception("You do not have sufficient permissions to carry out this request");

                    SrvOfficeChequeRequest srvOfficeChequeRequest = new SrvOfficeChequeRequest();
                    srvOfficeChequeRequest.Id = chequeRequest.ChequeRequestId;
                    srvOfficeChequeRequest.ProjectId = chequeRequest.ProjectId;
                    srvOfficeChequeRequest.Date = chequeRequest.ChequeRequestDate;
                    srvOfficeChequeRequest.DisbursementTypeId = chequeRequest.DisbursementTypeId;
                    srvOfficeChequeRequest.Description = chequeRequest.ChequeRequestDescription;
                    srvOfficeChequeRequest.Payee = chequeRequest.ChequeRequestPayee;
                    srvOfficeChequeRequest.OfficeBankId = chequeRequest.BankId;
                    srvOfficeChequeRequest.Amount = chequeRequest.ChequeRequestAmount;
                    srvOfficeChequeRequest.OfficeVATTable = chequeRequest.OfficeVATTable;
                    srvOfficeChequeRequest.VATRateId = chequeRequest.VATRateId;
                    srvOfficeChequeRequest.VATAmount = chequeRequest.VATAmount;
                    srvOfficeChequeRequest.IsAnticipated = chequeRequest.IsChequeRequestAnticipated;
                    srvOfficeChequeRequest.MemberId = chequeRequest.MemberId;

                    string errorMessage = string.Empty;
                    string caption = string.Empty;
                    bool isSaveSuccessful = srvOfficeChequeRequest.Save(out errorMessage, out caption);

                    if (chequeRequest.ChequeRequestId == 0)
                    {
                        chequeRequest.ChequeRequestId = srvOfficeChequeRequest.Id;
                    }

                    returnValue.ChequeRequest = chequeRequest;
                    returnValue.Success = isSaveSuccessful;

                    if (returnValue.Success)
                    {
                        // if client cheque request is saved then authorises it.
                        if (chequeRequest.IsChequeRequestAuthorised && UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.AuthoriseClientChequeRequest))
                        {
                            if (UserSecuritySettings.GetUserSecuitySettings((int)AccountsSettings.AuthoriseChequeRequestHigherAmount))
                            {

                                SrvOfficeChequeRequestCommon.AddAuthoriseOfficeChequeRequests(srvOfficeChequeRequest.Id, UserInformation.Instance.UserMemberId, DateTime.Now);
                            }
                            else
                            {
                                Decimal officeChequeRequestHigherAmount = Convert.ToDecimal(UserSecuritySettings.GetUserSecuitySettingsFeatureValue((int)AccountsSettings.OfficeChequeRequestHigherAmount));

                                if (Convert.ToDecimal(srvOfficeChequeRequest.Amount) > officeChequeRequestHigherAmount)
                                {
                                    errorMessage = "You are not allowed to Authorise Off Cheque Requests over the value of £" +
                                                     officeChequeRequestHigherAmount.ToString("0.00") + ".";
                                }
                                else
                                {

                                    SrvOfficeChequeRequestCommon.AddAuthoriseOfficeChequeRequests(srvOfficeChequeRequest.Id, UserInformation.Instance.UserMemberId, DateTime.Now);
                                }
                            }
                        }

                        chequeRequest.ChequeRequestId = srvOfficeChequeRequest.Id;
                        returnValue.ChequeRequest = chequeRequest;
                    }

                    returnValue.Message = errorMessage;
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception Ex)
            {
                returnValue.Success = false;
                returnValue.Message = Ex.Message;
            }

            return returnValue;
        }
コード例 #3
0
        /// <summary>
        /// Loads office cheque request details
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="officeChequeRequestId">Office Cheque Request id to get details</param>
        /// <returns>Loads office cheque request details</returns>
        public ChequeRequestReturnValue LoadOfficeChequeRequestDetails(Guid logonId, int officeChequeRequestId)
        {
            ChequeRequestReturnValue returnValue = new ChequeRequestReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    SrvOfficeChequeRequest srvOfficeChequeRequest = new SrvOfficeChequeRequest();
                    srvOfficeChequeRequest.Id = officeChequeRequestId;
                    srvOfficeChequeRequest.Load();

                    ChequeRequest chequeReq = new ChequeRequest();
                    chequeReq.ProjectId = srvOfficeChequeRequest.ProjectId;
                    chequeReq.ChequeRequestDate = srvOfficeChequeRequest.Date;
                    chequeReq.DisbursementTypeId = srvOfficeChequeRequest.DisbursementTypeId;
                    chequeReq.ChequeRequestDescription = srvOfficeChequeRequest.Description;
                    chequeReq.ChequeRequestPayee = srvOfficeChequeRequest.Payee;
                    chequeReq.BankId = srvOfficeChequeRequest.OfficeBankId;
                    chequeReq.ChequeRequestAmount = srvOfficeChequeRequest.Amount;
                    chequeReq.OfficeVATTable = srvOfficeChequeRequest.OfficeVATTable;
                    chequeReq.VATRateId = srvOfficeChequeRequest.VATRateId;
                    chequeReq.VATAmount = srvOfficeChequeRequest.VATAmount;
                    chequeReq.IsChequeRequestAuthorised = srvOfficeChequeRequest.IsAuthorised;
                    chequeReq.MemberId = srvOfficeChequeRequest.MemberId;
                    chequeReq.IsChequeRequestAnticipated = srvOfficeChequeRequest.IsAnticipated;
                    returnValue.ChequeRequest = chequeReq;
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception Ex)
            {
                returnValue.Success = false;
                returnValue.Message = Ex.Message;
            }

            return returnValue;
        }