private void BindCategoryType()
        {
            DiaryServiceClient diaryService = null;

            try
            {
                diaryService = new DiaryServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;
                collectionRequest.StartRow     = 0;
                collectionRequest.RowCount     = 0;

                CancellationCodeSearchReturnValue returnValue = new CancellationCodeSearchReturnValue();
                returnValue = diaryService.GetBookingCancelledCategories(_logonSettings.LogonId, collectionRequest);

                if (returnValue.Success)
                {
                    _ddlCategory.DataSource     = returnValue.CancellationCodes.Rows;
                    _ddlCategory.DataTextField  = "Description";
                    _ddlCategory.DataValueField = "Code";
                    _ddlCategory.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text     = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.Text     = ex.Message;
                _lblError.CssClass = "errorMessage";
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        diaryService.Close();
                    }
                }
            }
            //try
            //{
            //    _ddlCategory.DataSource = DataTables.GetCategoryType();
            //    _ddlCategory.DataTextField = "category";
            //    _ddlCategory.DataValueField = "category";
            //    _ddlCategory.DataBind();
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
Exemple #2
0
        public CancellationCodeSearchReturnValue GetBookingCancelledCategories(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest)
        {
            CancellationCodeSearchReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDiaryService = new DiaryService();
                returnValue   = oDiaryService.GetBookingCancelledReasons(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest);
            }
            else
            {
                returnValue         = new CancellationCodeSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
 public CancellationCodeSearchReturnValue GetBookingCancelledReasons(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest)
 {
     CancellationCodeSearchReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oDiaryService = new DiaryService();
         returnValue = oDiaryService.GetBookingCancelledReasons(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest);
     }
     else
     {
         returnValue = new CancellationCodeSearchReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }
        public CancellationCodeSearchReturnValue GetBookingCancelledReasons(Guid logonId, CollectionRequest collectionRequest)
        {
            CancellationCodeSearchReturnValue returnValue = new CancellationCodeSearchReturnValue();

            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:
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            // Can do everything
                            break;
                        default:
                            throw new Exception("Access denied");
                    }

                    // Create a data list creator for a list of banks
                    DataListCreator<CancellationCodeSearchItem> dataListCreator = new DataListCreator<CancellationCodeSearchItem>();

                    // Declare an inline event (annonymous delegate) to read the
                    // dataset if it is required
                    dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e)
                    {
                        DataSet dsReasons = new DataSet();
                        DataColumn dcCCode = new DataColumn("CRCode");
                        DataColumn dcCRDescription = new DataColumn("CRDescription");
                        DataTable dtReason = new DataTable();
                        dtReason.Columns.Add(dcCCode);
                        dtReason.Columns.Add(dcCRDescription);

                        DiaryParamsDts dts = SrvDiaryParameterLookup.GetDiaryParameter();
                        foreach (DiaryParamsDts.CancelledReasonsRow dr in dts.CancelledReasons.Rows)
                        {
                            if (!dr.CRDefault)
                            {
                                DataRow drNew = dtReason.NewRow();
                                drNew["CRCode"] = dr.CRCode;
                                drNew["CRDescription"] = dr.CRDescription;
                                dtReason.Rows.Add(drNew);
                            }
                        }
                        dsReasons.Tables.Add(dtReason);

                        e.DataSet = dsReasons;
                    };

                    // Create the data list
                    returnValue.CancellationCodes = dataListCreator.Create(logonId,
                        // Give the query a name so it can be cached
                        "CancellationCodeSearch",
                        // Tell it the query criteria used so if the cache is accessed
                        // again it knows if it is the same query
                        string.Empty,
                        collectionRequest,
                        // Import mappings to map the dataset row fields to the data
                        // list entity properties
                        new ImportMapping[] {
                            new ImportMapping("Code", "CRCode"),
                            new ImportMapping("Description", "CRDescription")
                            }
                        );
                }
                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;
        }
        private void BindReasonType()
        {
            DiaryServiceClient diaryService = null;
            try
            {
                diaryService = new DiaryServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;
                collectionRequest.StartRow = 0;
                collectionRequest.RowCount = 0;

                CancellationCodeSearchReturnValue returnValue = new CancellationCodeSearchReturnValue();
                returnValue = diaryService.GetBookingCancelledReasons(_logonSettings.LogonId, collectionRequest);

                if (returnValue.Success)
                {
                    _ddlReason.DataSource = returnValue.CancellationCodes.Rows;
                    _ddlReason.DataTextField = "Description";
                    _ddlReason.DataValueField = "Code";
                    _ddlReason.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.Text = ex.Message;
                _lblError.CssClass = "errorMessage";
            }
            finally
            {
                if (diaryService != null)
                {
                    if (diaryService.State != System.ServiceModel.CommunicationState.Faulted)
                        diaryService.Close();
                }
            }
            //try
            //{
            //    _ddlReason.DataSource = DataTables.GetReasonType();
            //    _ddlReason.DataTextField = "reason";
            //    _ddlReason.DataValueField = "reason";
            //    _ddlReason.DataBind();
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }