private void SetAvailableData()
    {
        GetAllCustomerGroup();

        AvailableFilteredCustomerGroup = AllGroups.Where(p => !IncludedGroup.Any(inc => inc.CustomerGroupID == p.CustomerGroupID))
                                         .Where(p => !ExcludedGroup.Any(exc => exc.CustomerGroupID == p.CustomerGroupID)).ToList();
        //Hide regular excluded customer groups for new condition
        if (ConditionID == 0 && ExcludedConditionGroup != null && ExcludedConditionGroup.Count > 0)
        {
            AvailableFilteredCustomerGroup = AvailableFilteredCustomerGroup.Where(p => !ExcludedConditionGroup.Any(inc => inc.CustomerGroupID == p.CustomerGroupID)).ToList();
        }


        string strFilter = functioninput.Text;

        if (functionradio1.Checked)
        {
            AvailableFilteredCustomerGroup = AvailableFilteredCustomerGroup.Where(p => p.Name.StartsWith(strFilter, StringComparison.OrdinalIgnoreCase)).ToList();
        }
        else
        {
            AvailableFilteredCustomerGroup = AvailableFilteredCustomerGroup.Where(p => p.Name.IndexOf(strFilter, StringComparison.OrdinalIgnoreCase) >= 0).ToList();
        }


        lstSelected.DataSource = IncludedGroup;
        lstSelected.DataBind();
        lstExcluded.DataSource = ExcludedGroup;
        lstExcluded.DataBind();

        lstAvailable.DataSource = AvailableFilteredCustomerGroup;
        lstAvailable.DataBind();
    }
Exemple #2
0
 private void btnDelRowExcludedGroup_Click(object sender, RoutedEventArgs e)
 {
     Groups.Add(dgExcludedtGroup.SelectedItem as Group);
     Groups = new ObservableCollection <Group>(Groups.OrderBy(i => i));
     cmbAddRowTargetGroup.ItemsSource   = Groups;
     cmbAddRowExcludedGroup.ItemsSource = Groups;
     ExcludedGroup.Remove(dgExcludedtGroup.SelectedItem as Group);
 }
Exemple #3
0
 private void btnAddRowExcludedGroup_Click(object sender, RoutedEventArgs e)
 {
     if (cmbAddRowExcludedGroup.SelectedItem as Group != null)
     {
         ExcludedGroup.Add(cmbAddRowExcludedGroup.SelectedItem as Group);
         Groups.Remove(cmbAddRowExcludedGroup.SelectedItem as Group);
     }
 }
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        string Name = string.Empty;

        if (MyCommon.Parse_Quotes(Logix.TrimAll(functioninput.Text)) != null)
        {
            Name = Convert.ToString(MyCommon.Parse_Quotes(Logix.TrimAll(functioninput.Text)));
        }
        if (!String.IsNullOrEmpty(Name))
        {
            int AvailableListCount = AvailableFilteredCustomerGroup.Where(p => p.Name.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).ToList().Count;
            int IncludedGroupCount = IncludedGroup.Where(p => p.Name.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).ToList().Count;
            int ExcludedGroupCount = ExcludedGroup.Where(p => p.Name.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).ToList().Count;

            bool isValidText = true;
            if (functioninput.Text.ToLower().Equals(PhraseLib.Lookup("term.anycardholder", LanguageID).ToLower()) || functioninput.Text.ToLower().Equals(PhraseLib.Lookup("term.anycustomer", LanguageID).ToLower()) || functioninput.Text.ToLower().Equals(PhraseLib.Lookup("term.newcardholders", LanguageID).ToLower()))
            {
                isValidText = false;
            }
            if (!isValidText)
            {
                string alertMessage = Copient.PhraseLib.Lookup("term.enter", LanguageID) + " " + Copient.PhraseLib.Lookup("term.valid", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.customergroup", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.name", LanguageID).ToLower();
                ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "'); ", true);
            }
            else if (IncludedGroupCount > 0 || ExcludedGroupCount > 0)
            {
                string alertMessage = Copient.PhraseLib.Lookup("term.customergroup", LanguageID) + ": " + Name + " " + Copient.PhraseLib.Lookup("term.is", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.already", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.selected", LanguageID).ToLower();
                ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "');", true);
            }
            else if (AvailableListCount > 0)
            {
                string alertMessage = Copient.PhraseLib.Lookup("term.existing", LanguageID) + " " + Copient.PhraseLib.Lookup("term.customergroup", LanguageID).ToLower() + ": " + Name + " " + Copient.PhraseLib.Lookup("offer.message", LanguageID).ToLower();
                ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "');", true);

                IncludedGroup.Add(AvailableFilteredCustomerGroup.Where(p => p.Name.Equals(functioninput.Text, StringComparison.OrdinalIgnoreCase)).FirstOrDefault());
                HandleSelectedForSpecialGroup();
                SetAvailableData();
                SetButtons();
            }
            else
            {
                IncludedGroup.Add(CreateCustomerGroup());
                SetAvailableData();
                SetButtons();
            }
        }
        else
        {
            string alertMessage = Copient.PhraseLib.Lookup("term.enter", LanguageID) + " " + Copient.PhraseLib.Lookup("term.valid", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.customergroup", LanguageID).ToLower() + " " + Copient.PhraseLib.Lookup("term.name", LanguageID).ToLower();
            ScriptManager.RegisterStartupScript(UpdatePanelMain, UpdatePanelMain.GetType(), "AlertMessage", " AlertMessage('" + alertMessage + "');", true);
        }
    }
 protected void deselect2_Click(object sender, EventArgs e)
 {
     if (lstExcluded.SelectedItem != null)
     {
         //need to reverse the order - find the issue in case of removing the items from index 0
         var desc = from j in lstExcluded.GetSelectedIndices().ToList()
                    orderby j descending
                    select j;
         foreach (int i in desc)
         {
             ExcludedGroup.RemoveAt(i);
         }
         SetAvailableData();
     }
     SetButtons();
 }
    protected void select2_Click(object sender, EventArgs e)
    {
        if (lstAvailable.SelectedItem != null)
        {
            foreach (int i in lstAvailable.GetSelectedIndices())
            {
                if (AvailableFilteredCustomerGroup[i].CustomerGroupID == SystemCacheData.GetAnyCardHolderGroup().CustomerGroupID || AvailableFilteredCustomerGroup[i].CustomerGroupID == SystemCacheData.GetAnyCustomerGroup().CustomerGroupID || AvailableFilteredCustomerGroup[i].CustomerGroupID == SystemCacheData.GetNewCardHolderGroup().CustomerGroupID)
                {
                    infobar.InnerText = AvailableFilteredCustomerGroup[i].Name + " " + PhraseLib.Lookup("offer-eligibility-validateexlgroup", LanguageID).Replace("&#39;", "'");
                    infobar.Visible   = true;
                    break;
                }
                ExcludedGroup.Add(AvailableFilteredCustomerGroup[i]);
            }

            SetAvailableData();
        }
        SetButtons();
    }
    private void Save()
    {
        bool   isNewCondition   = false;
        string strIncludedGroup = string.Empty;
        string strExcludedGroup = string.Empty;

        try
        {
            if (OfferEligibileCustomerGroupCondition.ConditionID == 0)
            {
                isNewCondition = true;
            }
            if (chkDisallow_Edit.Visible)
            {
                OfferEligibileCustomerGroupCondition.DisallowEdit = chkDisallow_Edit.Checked;
            }

            if (spnHouseHold.Visible)
            {
                OfferEligibileCustomerGroupCondition.HouseHoldEnabled = chkHouseHold.Checked;
            }

            if (spnOffline.Visible)
            {
                OfferEligibileCustomerGroupCondition.EvaluateOfflineCustomer = chkOffline.Checked;
            }

            //Updated Include List
            var deletedlist = OfferEligibileCustomerGroupCondition.IncludeCondition.Where(p => !IncludedGroup.Any(inc => inc.CustomerGroupID == p.CustomerGroupID));
            foreach (CMS.AMS.Models.CustomerConditionDetails custdetail in deletedlist)
            {
                custdetail.Deleted = true;
            }
            historyString = PhraseLib.Lookup("history.con-customer-edit", LanguageID) + ": ";
            foreach (CMS.AMS.Models.CustomerGroup CustGroup in IncludedGroup)
            {
                if (!OfferEligibileCustomerGroupCondition.IncludeCondition.Exists(p => p.CustomerGroupID == CustGroup.CustomerGroupID))
                {
                    CMS.AMS.Models.CustomerConditionDetails condetail = new CMS.AMS.Models.CustomerConditionDetails();
                    condetail.CustomerGroupID = CustGroup.CustomerGroupID;
                    OfferEligibileCustomerGroupCondition.IncludeCondition.Add(condetail);
                    strIncludedGroup = strIncludedGroup + CustGroup.CustomerGroupID.ToString() + ",";
                }
            }
            historyString = historyString + strIncludedGroup.TrimEnd(',');
            //Update Exclude List exc

            var deletedexclist = OfferEligibileCustomerGroupCondition.ExcludeCondition.Where(p => !ExcludedGroup.Any(exc => exc.CustomerGroupID == p.CustomerGroupID));
            foreach (CMS.AMS.Models.CustomerConditionDetails custdetail in deletedexclist)
            {
                custdetail.Deleted = true;
            }
            bool IsExcludedExist = false;
            foreach (CMS.AMS.Models.CustomerGroup CustGroup in ExcludedGroup)
            {
                if (!OfferEligibileCustomerGroupCondition.ExcludeCondition.Exists(p => p.CustomerGroupID == CustGroup.CustomerGroupID))
                {
                    CMS.AMS.Models.CustomerConditionDetails condetail = new CMS.AMS.Models.CustomerConditionDetails();
                    condetail.CustomerGroupID = CustGroup.CustomerGroupID;
                    strExcludedGroup          = strExcludedGroup + CustGroup.CustomerGroupID.ToString() + ",";
                    OfferEligibileCustomerGroupCondition.ExcludeCondition.Add(condetail);
                    IsExcludedExist = true;
                }
            }
            if (ExcludedConditionGroup != null)
            {
                //if it is a new condition then add excluded customer groups which are currently exist in regualr customer condition
                if (isNewCondition)
                {
                    foreach (CMS.AMS.Models.CustomerGroup CustGroup in ExcludedConditionGroup)
                    {
                        if (!OfferEligibileCustomerGroupCondition.ExcludeCondition.Exists(p => p.CustomerGroupID == CustGroup.CustomerGroupID))
                        {
                            CMS.AMS.Models.CustomerConditionDetails condetail = new CMS.AMS.Models.CustomerConditionDetails();
                            condetail.CustomerGroupID = CustGroup.CustomerGroupID;
                            strExcludedGroup          = strExcludedGroup + CustGroup.CustomerGroupID.ToString() + ",";
                            OfferEligibileCustomerGroupCondition.ExcludeCondition.Add(condetail);
                            IsExcludedExist = true;
                        }
                    }
                }
                else
                {
                    //if it is an existing eligibility condition and user attempt to remove group from excluded condition which is exist in regular excluded condition then ask user to delete remove the same from regualr condition as well
                    var         mustExcludedList = deletedexclist.Where(p => ExcludedConditionGroup.Any(exc => exc.CustomerGroupID == p.CustomerGroupID)).Select(z => z.CustomerGroup);
                    List <long> ExcludedGroupIds = new List <long>();
                    foreach (CustomerGroup item in mustExcludedList)
                    {
                        ExcludedGroupIds.Add(item.CustomerGroupID);
                    }
                    if (ExcludedGroupIds.Count > 0)
                    {
                        //Delete the excluded condition
                        m_CustCondition.DeleteRegulerExcludedConditionsByCustomerGroupIDs(OfferID, EngineID, ExcludedGroupIds);
                    }
                }
            }
            if (IsExcludedExist)
            {
                historyString = historyString + " " + PhraseLib.Lookup("term.excluding", LanguageID) + " " + strExcludedGroup.TrimEnd(',');
            }
            m_offer.CreateUpdateOfferEligibleCustomerCondition(OfferID, EngineID, OfferEligibileCustomerGroupCondition);
            if (isNewCondition)
            {
                CMS.AMS.Models.CustomerGroup CustomerGroup = new CMS.AMS.Models.CustomerGroup();
                CustomerGroup.Name         = string.Format(Constants.DEFAULT_OFFER_GROUP_NAME, hdnOfferName.Value);
                CustomerGroup.IsOptinGroup = true;
                m_CustGroup.CreateOptInCustomerGroup(CustomerGroup);
                CMS.AMS.Models.CustomerGroupConditions CustomerCondition = new CMS.AMS.Models.CustomerGroupConditions();
                CustomerCondition.DisallowEdit         = OfferEligibileCustomerGroupCondition.DisallowEdit;
                CustomerCondition.RequiredFromTemplate = OfferEligibileCustomerGroupCondition.RequiredFromTemplate;
                CustomerCondition.IncludeCondition     = new List <CMS.AMS.Models.CustomerConditionDetails>();
                CustomerCondition.IncludeCondition.Add(new CMS.AMS.Models.CustomerConditionDetails());
                CustomerCondition.IncludeCondition[0].CustomerGroupID = CustomerGroup.CustomerGroupID;
                m_offer.CreateDefaultCustomerCondition(OfferID, EngineID, CustomerCondition);
            }
            m_offer.UpdateOfferStatusToModified(OfferID, EngineID, CurrentUser.AdminUser.ID);
            m_OAWService.ResetOfferApprovalStatus(OfferID);
            WriteToActivityLog();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Close", "CloseModel()", true);
        }
        catch (Exception ex)
        {
            infobar.InnerText = ErrorHandler.ProcessError(ex);
            infobar.Visible   = true;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!(lstSelected.Items.Count > 0))
        {
            infobar.InnerText = PhraseLib.Lookup("term-validateincludedgroupset", LanguageID).Replace("&#39;", "'");
            infobar.Visible   = true;
            return;
        }
        if (OfferEligibileCustomerGroupCondition.ConditionID == 0)
        {
            if (IsDefaultGroupNameExsits())
            {
                infobar.Visible   = true;
                infobar.InnerText = String.Format(String.Format(PhraseLib.Lookup("OfferEligibilityCustomerCondition.validatedefaultgroupname", LanguageID), Constants.DEFAULT_OFFER_GROUP_NAME), hdnOfferName.Value).Replace("&#39;", "'");
                return;
            }
        }

        var deletedexclist = OfferEligibileCustomerGroupCondition.ExcludeCondition.Where(p => !ExcludedGroup.Any(exc => exc.CustomerGroupID == p.CustomerGroupID));

        if (OfferEligibileCustomerGroupCondition.ConditionID != 0)
        {
            //if it is an existing eligibility condition and user attempt to remove group from excluded condition which is exist in regular excluded condition then ask user to delete remove the same from regualr condition as well
            var    mustExcludedList = deletedexclist.Where(p => ExcludedConditionGroup.Any(exc => exc.CustomerGroupID == p.CustomerGroupID)).Select(z => z.CustomerGroup);
            string strGroups        = String.Empty;
            foreach (CustomerGroup item in mustExcludedList)
            {
                if (strGroups != "")
                {
                    strGroups = strGroups + ",";
                }
                strGroups = strGroups + item.Name;
            }
            if (strGroups != String.Empty)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "RegulerConditionDelete", "ConfirmRegulerConditionDelete('" + String.Format(PhraseLib.Lookup("offer-eligibility-deconfirmation", LanguageID), strGroups) + "');", true);
            }
            else
            {
                Save();
            }
        }
        else
        {
            Save();
        }
    }