private void AddQuoteRequest()
    {
        //Users objUser = DataRepository.UsersProvider.GetByUserId(Common.GetUserID());
        QuoteRequestService objQuoteService      = new QuoteRequestService();
        JobDetailsService   objJobDetailsService = new JobDetailsService();
        QuoteRequest        objQuoteReq          = new QuoteRequest();
        JobDetails          objJobDetails        = new JobDetails();
        CraQualifications   objCRAQual           = new CraQualifications();

        objQuoteReq.UserId = Common.GetUserID();
        //objQuoteReq.UserIdSource = objUser;

        objJobDetails.JobDuties = txtJobDuties.Text.Trim();
        if (txtTentativeDate.Text.Trim() != "")
        {
            objJobDetails.TentativeStartDate = DateTime.Parse(txtTentativeDate.Text);
        }
        objJobDetails.DurationContract = txtDurationContract.Text;
        objJobDetails.AvgDays          = txtAvgDays.Text;

        for (int i = 0; i < lstBoxCountries.Items.Count; i++)
        {
            if (lstBoxCountries.Items[i].Selected)
            {
                JobDetailsCountries objJobDetailsCountries = new JobDetailsCountries();
                objJobDetailsCountries.CountryId = int.Parse(lstBoxCountries.Items[i].Value);
                objJobDetails.JobDetailsCountriesCollection.Add(objJobDetailsCountries);
            }
        }

        for (int i = 0; i < lstStates.Items.Count; i++)
        {
            if (lstStates.Items[i].Selected)
            {
                JobDetailsStates objJobDetailsStates = new JobDetailsStates();
                objJobDetailsStates.StateId = int.Parse(lstStates.Items[i].Value);
                objJobDetails.JobDetailsStatesCollection.Add(objJobDetailsStates);
            }
        }


        objCRAQual.MinYearsExperience       = txtMinimumExp.Text;
        objCRAQual.ReqTherapeuticExperience = txtTherapicExp.Text;
        if (ddlFieldExp.SelectedIndex != 0)
        {
            objCRAQual.FieldTypeExperience = ddlFieldExp.SelectedValue;
        }
        objCRAQual.PositionTitle = txtPositionTitle.Text.Trim();

        objQuoteReq.JobDetailsCollection.Add(objJobDetails);
        objQuoteReq.CraQualificationsCollection.Add(objCRAQual);
        TList <QuoteCandidates> selectedCandidatesList = GetSelectedCandidates();

        if (selectedCandidatesList.Count > 0)
        {
            objQuoteReq.QuoteCandidatesCollection = selectedCandidatesList;
        }

        bool result = objQuoteService.DeepSave(objQuoteReq, ADB.Data.DeepSaveType.IncludeChildren,
                                               typeof(TList <JobDetails>), typeof(TList <CraQualifications>), typeof(TList <QuoteCandidates>));

        if (result)
        {
            objJobDetailsService.DeepSave(objJobDetails, DeepSaveType.IncludeChildren, typeof(TList <JobDetailsStates>), typeof(TList <JobDetailsCountries>));
        }

        //bool result = false;
        //objQuoteService.Save(objQuoteReq);
        SendEmail(objQuoteReq.QuoteRequestId.ToString());
        MultiViewQuoteRequest.ActiveViewIndex = MultiViewQuoteRequest.ActiveViewIndex + 1;

        if (result)
        {
            lblSuccessfull.Text = "Thank you for submitting your quote request.";
        }
        else
        {
            lblSuccessfull.Text = "A problem accurred while trying to save your quote request.";
        }
    }
    private void UpdateQuoteRequest()
    {
        QuoteRequestService objQuoteService      = new QuoteRequestService();
        JobDetailsService   objJobDetailsService = new JobDetailsService();

        QuoteRequest objQuoteReq = DataRepository.QuoteRequestProvider.GetByQuoteRequestId(QuoteRequestID);

        objQuoteService.DeepLoad(objQuoteReq, true, DeepLoadType.IncludeChildren
                                 , typeof(TList <JobDetails>), typeof(TList <CraQualifications>), typeof(TList <QuoteCandidates>));

        objJobDetailsService.DeepLoad(objQuoteReq.JobDetailsCollection[0], true,
                                      DeepLoadType.IncludeChildren, typeof(TList <JobDetailsStates>), typeof(TList <JobDetailsCountries>));

        JobDetails        objJobDetails = objQuoteReq.JobDetailsCollection[0];
        CraQualifications objCRAQual    = objQuoteReq.CraQualificationsCollection[0];

        objJobDetails.JobDuties = txtJobDuties.Text.Trim();
        if (txtTentativeDate.Text.Trim() != "")
        {
            objJobDetails.TentativeStartDate = DateTime.Parse(txtTentativeDate.Text);
        }
        else
        {
            objJobDetails.TentativeStartDate = null;
        }

        objJobDetails.DurationContract = txtDurationContract.Text;
        objJobDetails.AvgDays          = txtAvgDays.Text;

        objJobDetails.JobDetailsCountriesCollection.Clear();
        for (int i = 0; i < lstBoxCountries.Items.Count; i++)
        {
            if (lstBoxCountries.Items[i].Selected)
            {
                //JobDetailsCountries objJobDetailsSearched = objJobDetails.JobDetailsCountriesCollection.Find(JobDetailsCountriesColumn.CountryId, lstBoxCountries.Items[i].Value);
                //if (objJobDetailsSearched == null)
                //{
                JobDetailsCountries objJobDetailsCountries = new JobDetailsCountries();
                objJobDetailsCountries.CountryId = int.Parse(lstBoxCountries.Items[i].Value);
                objJobDetails.JobDetailsCountriesCollection.Add(objJobDetailsCountries);
                //}
            }
        }

        objJobDetails.JobDetailsStatesCollection.Clear();
        for (int i = 0; i < lstStates.Items.Count; i++)
        {
            if (lstStates.Items[i].Selected)
            {
                JobDetailsStates objJobDetailsStates = new JobDetailsStates();
                objJobDetailsStates.StateId = int.Parse(lstStates.Items[i].Value);
                objJobDetails.JobDetailsStatesCollection.Add(objJobDetailsStates);
            }
        }

        objCRAQual.MinYearsExperience       = txtMinimumExp.Text;
        objCRAQual.ReqTherapeuticExperience = txtTherapicExp.Text;
        if (ddlFieldExp.SelectedIndex != 0)
        {
            objCRAQual.FieldTypeExperience = ddlFieldExp.SelectedValue;
        }
        objCRAQual.PositionTitle = txtPositionTitle.Text.Trim();

        //objQuoteReq.JobDetailsCollection.Add(objJobDetails);
        //objQuoteReq.CraQualificationsCollection.Add(objCRAQual);

        objQuoteReq.QuoteCandidatesCollection.Clear();
        TList <QuoteCandidates> selectedCandidatesList = GetSelectedCandidates();

        if (selectedCandidatesList.Count > 0)
        {
            objQuoteReq.QuoteCandidatesCollection = selectedCandidatesList;
        }

        bool result = objQuoteService.DeepSave(objQuoteReq, ADB.Data.DeepSaveType.IncludeChildren,
                                               typeof(TList <JobDetails>), typeof(TList <CraQualifications>), typeof(TList <QuoteCandidates>));

        if (result)
        {
            objJobDetailsService.DeepSave(objJobDetails, DeepSaveType.IncludeChildren, typeof(TList <JobDetailsStates>), typeof(TList <JobDetailsCountries>));
        }

        //bool result = false;
        //objQuoteService.Save(objQuoteReq);

        MultiViewQuoteRequest.ActiveViewIndex = MultiViewQuoteRequest.ActiveViewIndex + 1;

        if (result)
        {
            lblSuccessfull.Text = "Your quote request is updated.";
        }
        else
        {
            lblSuccessfull.Text = "A problem accurred while trying to save your quote request.";
        }
    }