/// <summary>
        /// Handles the OnSelectedIndexChanged event of the dcbRequests control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs"/> instance containing the event data.</param>
        protected void dcbRequests_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            hlGoToRequest.Visible = dcbRequests.SelectedIdNullable.HasValue;
            if (dcbRequests.SelectedIdNullable.HasValue)
            {
                hlGoToRequest.NavigateUrl = UrlsData.AP_RequestEdit(dcbRequests.SelectedId);
            }

            ProceedRequest(dcbRequests.SelectedIdNullable);
        }
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            plComment.Visible = true;
            dcbContract.MaskFilters.Clear();
            dcbContract.MaskFilters.Add("#Number", "Number");
            dcbContract.MaskFilters.Add("#CreatedAt", "CreatedAt");

            dcbRequests.MaskFilters.Clear();
            dcbRequests.MaskFilters.Add("#Number", "Number");
            dcbRequests.MaskFilters.Add("#CreatedAt", "CreatedAt");
            dcbRequests.MaskFilters.Add("#RequestType", "tbl_RequestSourceType.Title");

            dcbRequirementSeverityOfExposure.SiteID = dcbRequests.SiteID = dcbProducts.SiteID = dcbCompany.SiteID =
                dcbRequirementType.SiteID           = dcbServiceLevel.SiteID = dcbRequirementPriority.SiteID =
                    dcbRequirementComplexity.SiteID = ucPublicationCategory.SiteID =
                        dcbContract.SiteID          = dcbOrder.SiteID = dcbInvoice.SiteID =
                            dcbEvaluationRequirementsProducts.SiteID = dcbCurrency.SiteID =
                                dcbInternalUnit.SiteID          = dcbUnit.SiteID = dcbRequirementImplementationComplete.SiteID = dcbRequirementSpeedTime.SiteID =
                                    dcbRequestSourceType.SiteID = dcbRequirementSatisfaction.SiteID = SiteId;
            ucPublicationCategory.BindData();
            rdpCreatedAt.SelectedDate = DateTime.Now;

            if (CurrentUser.Instance.CompanyID.HasValue)
            {
                dcbCompany.SelectedId   = (Guid)CurrentUser.Instance.CompanyID;
                dcbCompany.SelectedText = DataManager.Company.SelectById(SiteId, (Guid)CurrentUser.Instance.CompanyID).Name;
            }

            ucResponsible.SelectedValue = CurrentUser.Instance.ContactID;

            if (Session["Selected-Text"] != null)
            {
                ucComment.Content        = HttpUtility.HtmlDecode(HttpUtility.HtmlDecode(((string)Session["Selected-Text"])));
                Session["Selected-Text"] = null;
            }

            if (Session["Source-RequestId"] != null)
            {
                dcbRequests.SelectedIdNullable = (Guid?)Session["Source-RequestId"];

                var request = DataManager.Request.SelectById(SiteId, (Guid)Session["Source-RequestId"]);
                if (request != null)
                {
                    dcbRequests.SelectedText = dcbRequests.Mask.Replace("#Number", request.Number)
                                               .Replace("#CreatedAt", request.CreatedAt.ToString("dd.MM.yyyy"))
                                               .Replace("#RequestType", request.tbl_RequestSourceType.Title);

                    dcbRequestSourceType.SelectedIdNullable = request.RequestSourceTypeID;
                }

                Session["Source-RequestId"] = null;
                ProceedRequest(dcbRequests.SelectedIdNullable);
            }

            var requirement = DataManager.Requirement.SelectById(SiteId, _requirementId);

            if (requirement != null)
            {
                plComments.Visible = true;
                plComment.Visible  = false;

                gridRequests.Where.Add(new GridWhere()
                {
                    CustomQuery =
                        string.Format(
                            "(tbl_Request.ID = '{0}' OR tbl_Request.ID IN " +
                            "(SELECT RequestID FROM tbl_RequestToRequirement WHERE RequirementID = '{1}'))",
                            requirement.RequestID.HasValue ? (Guid)requirement.RequestID : Guid.Empty,
                            _requirementId.ToString())
                });

                ucParentRequirment.CurrentRequirementId = requirement.ID;
                ucParentRequirment.ParentRequirementId  = requirement.ParentID;

                ucRequirementStatus.RequirementStatusId = requirement.RequirementStatusID;
                ucRequirementStatus.RequirementTypeId   = requirement.RequirementTypeID;
                ucRequirementStatus.CompanyId           = requirement.CompanyID;
                ucRequirementStatus.ServiceLevelId      = requirement.ServiceLevelID;

                lrlNumber.Text            = requirement.Number;
                rdpCreatedAt.SelectedDate = requirement.CreatedAt;
                txtShortDescription.Text  = requirement.ShortDescription;
                dcbRequestSourceType.SelectedIdNullable = requirement.RequestSourceTypeID;

                if (requirement.ProductID.HasValue)
                {
                    dcbProducts.SelectedIdNullable = requirement.ProductID;
                    dcbProducts.SelectedText       = DataManager.Product.SelectById(SiteId, (Guid)requirement.ProductID).Title;
                }

                if (requirement.CompanyID.HasValue)
                {
                    dcbCompany.SelectedIdNullable = requirement.CompanyID;
                    dcbCompany.SelectedText       = requirement.tbl_Company.Name;
                }

                ucContact.SelectedValue               = requirement.ContactID;
                txtProductSeriesNumber.Text           = requirement.ProductSeriesNumber;
                dcbRequirementType.SelectedIdNullable = requirement.RequirementTypeID;
                dcbRequirementSeverityOfExposure.SelectedIdNullable = requirement.RequirementSeverityOfExposureID;

                dcbRequirementSeverityOfExposure.Filters.Clear();

                dcbRequirementSeverityOfExposure.Filters.Add(new DictionaryComboBox.DictionaryFilterColumn()
                {
                    Name   = "RequirementTypeID",
                    DbType = DbType.Guid,
                    Value  = requirement.RequirementTypeID.ToString()
                });

                dcbServiceLevel.SelectedIdNullable          = requirement.ServiceLevelID;
                dcbRequirementPriority.SelectedIdNullable   = requirement.RequirementPriorityID;
                dcbRequirementComplexity.SelectedIdNullable = requirement.RequirementComplexityID;
                if (requirement.PublicationCategoryID.HasValue)
                {
                    ucPublicationCategory.SelectedCategoryId = (Guid)requirement.PublicationCategoryID;
                }

                ucResponsible.SelectedValue            = requirement.ResponsibleID;
                rdpRealizationDateActual.SelectedDate  = requirement.RealizationDateActual;
                rdpRealizationDatePlanned.SelectedDate = requirement.RealizationDatePlanned;

                if (requirement.ContractID.HasValue)
                {
                    dcbContract.SelectedIdNullable = requirement.ContractID;
                    dcbContract.SelectedText       = dcbContract.Mask.Replace("#Number", requirement.tbl_Contract.Number)
                                                     .Replace("#CreatedAt", requirement.tbl_Contract.CreatedAt.ToString("dd.MM.yyyy"));
                }

                if (requirement.OrderID.HasValue)
                {
                    dcbOrder.SelectedIdNullable = requirement.OrderID;
                    dcbOrder.SelectedText       = requirement.tbl_Order.Number;
                }

                if (requirement.InvoiceID.HasValue)
                {
                    dcbInvoice.SelectedIdNullable = requirement.InvoiceID;
                    dcbInvoice.SelectedText       = requirement.tbl_Invoice.Number;
                }

                if (requirement.EvaluationRequirementsProductID.HasValue)
                {
                    dcbEvaluationRequirementsProducts.SelectedIdNullable = requirement.EvaluationRequirementsProductID;
                    dcbEvaluationRequirementsProducts.SelectedText       = DataManager.Product.SelectById(SiteId, (Guid)requirement.EvaluationRequirementsProductID).Title;
                }

                dcbInternalUnit.SelectedIdNullable = requirement.InternalUnitID;
                rntxtInternalQuantity.Value        = (double)requirement.InternalQuantity;
                txtEstimateCommentInternal.Text    = requirement.EstimateCommentInternal;
                txtEstimateCommentForClient.Text   = requirement.EstimateCommentForClient;

                txtAnyProductName.Text         = requirement.AnyProductName;
                rntxtQuantity.Value            = (double)requirement.Quantity;
                dcbCurrency.SelectedIdNullable = requirement.CurrencyID;
                rntxtCurrencyPrice.Value       = (double)requirement.CurrencyPrice;
                rntxtCurrencyAmount.Value      = (double)requirement.CurrencyAmount;
                dcbUnit.SelectedIdNullable     = requirement.UnitID;
                rntxtRate.Value   = (double)requirement.Rate;
                rntxtPrice.Value  = (double)requirement.Price;
                rntxtAmount.Value = (double)requirement.Amount;
                dcbRequirementImplementationComplete.SelectedIdNullable = requirement.RequirementImplementationCompleteID;
                dcbRequirementSpeedTime.SelectedIdNullable    = requirement.RequirementSpeedTimeID;
                dcbRequirementSatisfaction.SelectedIdNullable = requirement.RequirementSatisfactionID;
                txtEstimationComment.Text = requirement.EstimationComment;

                UpdateRequestsList();

                if (requirement.RequestID.HasValue)
                {
                    dcbRequests.SelectedIdNullable = requirement.RequestID;
                    var request = DataManager.Request.SelectById(SiteId, (Guid)requirement.RequestID);
                    dcbRequests.SelectedText = dcbRequests.Mask.Replace("#Number", request.Number)
                                               .Replace("#CreatedAt", request.CreatedAt.ToString("dd.MM.yyyy"))
                                               .Replace("#RequestType", request.tbl_RequestSourceType.Title);
                }
            }
            else
            {
                gridRequests.Where.Add(new GridWhere()
                {
                    CustomQuery = string.Format("(tbl_Request.ID = '{0}')", Guid.Empty)
                });

                var requirementType = DataManager.RequirementType.SelectDefault(SiteId);
                if (requirementType != null)
                {
                    ucRequirementStatus.RequirementTypeId = requirementType.ID;
                    dcbRequirementSeverityOfExposure.Filters.Clear();
                    dcbRequirementSeverityOfExposure.Filters.Add(new DictionaryComboBox.DictionaryFilterColumn()
                    {
                        Name   = "RequirementTypeID",
                        DbType = DbType.Guid,
                        Value  = requirementType.ID.ToString()
                    });
                }
            }
            hlGoToRequest.Visible = dcbRequests.SelectedIdNullable.HasValue;
            if (dcbRequests.SelectedIdNullable.HasValue)
            {
                hlGoToRequest.NavigateUrl = UrlsData.AP_RequestEdit(dcbRequests.SelectedId);
            }
        }