Esempio n. 1
0
        private void SetAttributes()
        {
            cboFromShop.AutoCompleteMode  = AutoCompleteMode.Append;
            cboToShop.AutoCompleteMode    = AutoCompleteMode.Append;
            cboFromGrade.AutoCompleteMode = AutoCompleteMode.Append;
            cboToGrade.AutoCompleteMode   = AutoCompleteMode.Append;

            string[] orderBy      = new string[] { "Priority" };
            var      smartTagList = SmartTag4MemberEx.GetListOrderBy(orderBy, true);

            SmartTagHelper oTag = new SmartTagHelper(this.gbxOptions);

            oTag.MemberSmartTagList = smartTagList;
            oTag.SetSmartTags();

            #region 設定 clickable saluation label
            lblSmartTag1.AutoSize = true;                      // 減少 whitespace,有字嘅位置先可以 click
            lblSmartTag1.Cursor   = Cursors.Hand;              // cursor over 顯示 hand cursor
            lblSmartTag1.Click   += (s, e) =>                  // 彈出 wizard
            {
                var id     = SmartTag4MemberEx.GetIdByPriority(1);
                var dialog = new SmartTag4Member_OptionsWizard();
                dialog.SmartTagId  = id;
                dialog.FormClosed += (sender, eventArgs) =>     // 關閉後 refresh 個 combo box items
                {
                    FillGrade();
                };
                dialog.ShowDialog();
            };
            #endregion
        }
Esempio n. 2
0
        private void FillComboBox_Nature()
        {
            var id         = SmartTag4MemberEx.GetIdByPriority(99); // member nature
            var textFields = new string[] { "OptionCode", "OptionName" };
            var pattern    = "{0} - {1}";

            var where = string.Format("TagId = '{0}'", id.ToString());
            var orderBy = new string[] { "OptionCode" };

            SmartTag4Member_OptionsEx.LoadCombo(ref cboNature, textFields, pattern, true, true, "", where, orderBy);
        }
Esempio n. 3
0
        private void smartLabel_OnClick(object sender, EventArgs e)
        {
            var label    = (Label)sender;
            var priority = (int)label.Tag;
            var id       = SmartTag4MemberEx.GetIdByPriority(priority);

            var dialog = new SmartTag4Member_OptionsWizard();

            dialog.FormClosed += smartDialog_Closed;
            dialog.SmartTagId  = id;
            dialog.ShowDialog();
        }
Esempio n. 4
0
 private void SetAttributes()
 {
     #region 設定 clickable Nature label
     lblNature.AutoSize = true;                     // 減少 whitespace,有字嘅位置先可以 click
     lblNature.Cursor   = Cursors.Hand;             // cursor over 顯示 hand cursor
     lblNature.Click   += (s, e) =>                 // 彈出 wizard
     {
         var dialog = new SmartTag4Member_OptionsWizard();
         dialog.SmartTagId  = SmartTag4MemberEx.GetIdByPriority(99);
         dialog.FormClosed += (sender, eventArgs) =>     // 關閉後 refresh 個 combo box items
         {
             FillComboBox_Nature();
         };
         dialog.ShowDialog();
     };
     #endregion
 }
Esempio n. 5
0
        private void SetAttributes()
        {
            txtLargestVipNumber.BackColor  = SystemInfoHelper.ControlBackColor.DisabledBox;
            cboNature.BackColor            = SystemInfoHelper.ControlBackColor.RequiredBox;
            cboNature.SelectedIndex        = 0;
            cboLineOfOperation.BackColor   = SystemInfoHelper.ControlBackColor.RequiredBox;
            txtNormalDiscount.BackColor    = SystemInfoHelper.ControlBackColor.RequiredBox;
            txtPromotionDiscount.BackColor = SystemInfoHelper.ControlBackColor.RequiredBox;

            #region 設定 clickable Nature label
            lblNature.AutoSize = true;                     // 減少 whitespace,有字嘅位置先可以 click
            lblNature.Cursor   = Cursors.Hand;             // cursor over 顯示 hand cursor
            lblNature.Click   += (s, e) =>                 // 彈出 wizard
            {
                var dialog = new SmartTag4Member_OptionsWizard();
                dialog.SmartTagId  = SmartTag4MemberEx.GetIdByPriority(99);
                dialog.FormClosed += (sender, eventArgs) =>     // 關閉後 refresh 個 combo box items
                {
                    FillComboBox_Nature();
                };
                dialog.ShowDialog();
            };
            #endregion

            #region 設定 clickable line-of-operation label
            lblLineOfOperation.AutoSize = true;                     // 減少 whitespace,有字嘅位置先可以 click
            lblLineOfOperation.Cursor   = Cursors.Hand;             // cursor over 顯示 hand cursor
            lblLineOfOperation.Click   += (s, e) =>                 // 彈出 wizard
            {
                var dialog = new Settings.LineOfOperationWizard();
                dialog.FormClosed += (sender, eventArgs) =>         // 關閉後 refresh 個 combo box items
                {
                    FillLineOfOperationList();
                };
                dialog.ShowDialog();
            };
            #endregion
        }
Esempio n. 6
0
        private void InitialSmartTags()
        {
            string[] orderBy      = new string[] { "Priority" };
            var      smartTagList = SmartTag4MemberEx.GetListOrderBy(orderBy, true);

            SmartTagHelper oTag = new SmartTagHelper(this);

            oTag.MemberSmartTagList = smartTagList;
            oTag.SetSmartTags();

            #region 設定 clickable smart tag labels
            lblSmartTag1.AutoSize = true;                // 減少 whitespace,有字嘅位置先可以 click
            lblSmartTag1.Cursor   = Cursors.Hand;        // cursor over 顯示 hand cursor
            lblSmartTag1.Tag      = 1;                   // Tag = Priority
            lblSmartTag1.Click   += smartLabel_OnClick;  // 綁定 click event

            lblSmartTag2.AutoSize = true;                // 減少 whitespace,有字嘅位置先可以 click
            lblSmartTag2.Cursor   = Cursors.Hand;        // cursor over 顯示 hand cursor
            lblSmartTag2.Tag      = 2;                   // Tag = Priority
            lblSmartTag2.Click   += smartLabel_OnClick;  // 綁定 click event

            lblSmartTag3.AutoSize = true;                // 減少 whitespace,有字嘅位置先可以 click
            lblSmartTag3.Cursor   = Cursors.Hand;        // cursor over 顯示 hand cursor
            lblSmartTag3.Tag      = 3;                   // Tag = Priority
            lblSmartTag3.Click   += smartLabel_OnClick;  // 綁定 click event

            lblSmartTag4.AutoSize = true;                // 減少 whitespace,有字嘅位置先可以 click
            lblSmartTag4.Cursor   = Cursors.Hand;        // cursor over 顯示 hand cursor
            lblSmartTag4.Tag      = 4;                   // Tag = Priority
            lblSmartTag4.Click   += smartLabel_OnClick;  // 綁定 click event

            lblSmartTag11.AutoSize = true;               // 減少 whitespace,有字嘅位置先可以 click
            lblSmartTag11.Cursor   = Cursors.Hand;       // cursor over 顯示 hand cursor
            lblSmartTag11.Tag      = 11;                 // Tag = Priority
            lblSmartTag11.Click   += smartLabel_OnClick; // 綁定 click event
            #endregion
        }
        private bool IsValid()
        {
            bool result = true;

            #region Tag Code 唔可以吉
            errorProvider.SetError(txtTagCode, string.Empty);
            if (txtTagCode.Text.Length == 0)
            {
                errorProvider.SetError(txtTagCode, "Cannot be blank!");
                return(false);
            }
            #endregion

            #region 新增,要 check Tag Code 係咪 in use
            errorProvider.SetError(txtTagCode, string.Empty);
            if (_SmartTagId == Guid.Empty && SmartTag4MemberEx.IsTagCodeInUse(txtTagCode.Text.Trim()))
            {
                errorProvider.SetError(txtTagCode, "Tag Code in use");
                return(false);
            }
            #endregion

            return(result);
        }
Esempio n. 8
0
        private void smartDialog_Closed(object sender, FormClosedEventArgs e)
        {
            var dialog   = (SmartTag4Member_OptionsWizard)sender;
            var smartTag = SmartTag4MemberEx.Get(dialog.SmartTagId);

            switch (smartTag.Priority)
            {
            case 1:
                SmartTag4Member_OptionsEx.FillSmartTagComboBox(ref cboSmartTag1, 1);
                break;

            case 2:
                SmartTag4Member_OptionsEx.FillSmartTagComboBox(ref cboSmartTag2, 2);
                break;

            case 3:
                SmartTag4Member_OptionsEx.FillSmartTagComboBox(ref cboSmartTag3, 3);
                break;

            case 4:
                SmartTag4Member_OptionsEx.FillSmartTagComboBox(ref cboSmartTag4, 4);
                break;
            }
        }
        private void Delete()
        {
            var result = SmartTag4MemberEx.DeleteOptionsToo(_SmartTagId);

            MessageBox.Show(result ? "Record Removed" : "Can't Delete Record...", "Delete Result");
        }
Esempio n. 10
0
        private bool DoPromote()
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                using (var scope = ctx.Database.BeginTransaction())
                {
                    try
                    {
                        foreach (var item in dsMemberList)
                        {
                            var id = Guid.Empty;

                            #region Save Member Core Data
                            var member = ctx.Member.Where(x => x.MemberNumber == item.VIPNO).FirstOrDefault();
                            if (member == null)
                            {
                                #region add new Member
                                member              = new EF6.Member();
                                member.MemberId     = Guid.NewGuid();
                                member.MemberNumber = item.VIPNO;

                                member.Status    = (int)EnumHelper.Status.Active;
                                member.CreatedBy = ConfigHelper.CurrentUserId;
                                member.CreatedOn = DateTime.Now;
                                member.Retired   = false;

                                ctx.Member.Add(member);
                                #endregion
                            }

                            #region Check the temp vip DLFLAG
                            if (item.DLFLAG.Trim().Length > 0)
                            {
                                switch (item.DLFLAG.Trim().ToUpper())
                                {
                                case "A":
                                case "":
                                default:
                                    member.Status = (int)EnumHelper.Status.Active;
                                    break;

                                case "M":
                                    member.Status = (int)EnumHelper.Status.Modified;
                                    break;

                                case "D":
                                    member.Status = (int)EnumHelper.Status.Deleted;
                                    break;

                                case "I":
                                    member.Status = (int)EnumHelper.Status.Inactive;
                                    break;
                                }
                            }
                            else
                            {
                                member.Status = ctx.Entry(member).State == EntityState.Added ?
                                                (int)EnumHelper.Status.Active : (int)EnumHelper.Status.Modified;
                            }
                            #endregion

                            #region Option 2. Migrate Temporary VIP to Permanent VIP With Delete
                            //if (canDelete)
                            //{
                            //    member.Status = (int)EnumHelper.Status.Deleted;
                            //}
                            #endregion

                            #region update Member core data
                            member.WorkplaceId    = Guid.Empty;
                            member.ClassId        = MemberHelper.GetClassId(item.PHONEBOOK); //Class
                            member.GroupId        = MemberHelper.GetGroupId(item.GROUP);
                            member.MemberInitial  = item.NNAME;                              // Nick Name
                            member.SalutationId   = MemberHelper.GetSaluteId(item.SALUTE);
                            member.FirstName      = item.FNAME;                              // First Name
                            member.LastName       = item.LNAME;                              // Last Name
                            member.FullName       = item.FNAME + "," + item.LNAME;           // Full Name
                            member.FullName_Chs   = item.CNAME;                              // Chinese Name (S)
                            member.FullName_Cht   = item.CNAME;                              // Chinese Name (T)
                            member.JobTitleId     = JobTitleEx.GetJobTitleIdByName(item.TITLE);
                            member.AssignedTo     = Guid.Empty;
                            member.Remarks        = item.REMARKS;
                            member.NormalDiscount = (decimal)item.NRDISC;
                            member.DownloadToPOS  = true;
                            member.ModifiedBy     = ConfigHelper.CurrentUserId;
                            member.ModifiedOn     = DateTime.Now;

                            if (member.Status == (int)EnumHelper.Status.Deleted || member.Status == (int)EnumHelper.Status.Inactive)
                            {
                                member.Retired   = false;
                                member.RetiredBy = Guid.Empty;
                                member.RetiredOn = new DateTime(1900, 1, 1);
                            }
                            #endregion

                            ctx.SaveChanges();
                            id = member.MemberId;
                            #endregion

                            #region SaveMemberAddresses(memberId, item);
                            #region English Address
                            var    enAddressTypeId = MemberAddressTypeEx.GetIdByCode("ADDR_EN");
                            string enAddress       = item.ADDRESS1 + Environment.NewLine + item.ADDRESS2 + Environment.NewLine + item.ADDRESS3 + Environment.NewLine + item.ADDRESS4;

                            var addressEn = ctx.MemberAddress.Where(x => x.MemberId == id && x.AddressTypeId == enAddressTypeId).FirstOrDefault();
                            if (addressEn == null)
                            {
                                addressEn               = new EF6.MemberAddress();
                                addressEn.AddressId     = Guid.NewGuid();
                                addressEn.AddressTypeId = enAddressTypeId;
                                addressEn.MemberId      = id;

                                ctx.MemberAddress.Add(addressEn);
                            }

                            addressEn.Address        = enAddress;
                            addressEn.PostalCode     = string.Empty;
                            addressEn.CountryId      = Guid.Empty;
                            addressEn.ProvinceId     = Guid.Empty;
                            addressEn.CityId         = Guid.Empty;
                            addressEn.District       = string.Empty;
                            addressEn.Mailing        = false;
                            addressEn.PhoneTag1      = PhoneTagEx.GetPhoneTagIdByPriority(1);
                            addressEn.PhoneTag1Value = item.TELW;
                            addressEn.PhoneTag2      = PhoneTagEx.GetPhoneTagIdByPriority(2);
                            addressEn.PhoneTag2Value = item.TELH;
                            addressEn.PhoneTag3      = PhoneTagEx.GetPhoneTagIdByPriority(3);
                            addressEn.PhoneTag3Value = item.FAX;
                            addressEn.PhoneTag4      = PhoneTagEx.GetPhoneTagIdByPriority(4);
                            addressEn.PhoneTag4Value = item.TELOTHER;
                            addressEn.PhoneTag5      = PhoneTagEx.GetPhoneTagIdByPriority(5);
                            addressEn.PhoneTag5Value = item.TELP;

                            ctx.SaveChanges();
                            #endregion

                            #region Chinese Address
                            var    cnAddressTypeId = MemberAddressTypeEx.GetIdByCode("ADDR_CN");
                            string cnAddress       = item.ADDRESS1C + Environment.NewLine + item.ADDRESS2C + Environment.NewLine + item.ADDRESS3C + Environment.NewLine + item.ADDRESS4C;

                            var addressCn = ctx.MemberAddress.Where(x => x.MemberId == id && x.AddressTypeId == cnAddressTypeId).FirstOrDefault();
                            if (addressCn == null)
                            {
                                addressCn               = new EF6.MemberAddress();
                                addressCn.AddressId     = Guid.NewGuid();
                                addressCn.AddressTypeId = cnAddressTypeId;
                                addressCn.MemberId      = id;

                                ctx.MemberAddress.Add(addressCn);
                            }

                            addressCn.Address        = cnAddress;
                            addressCn.PostalCode     = string.Empty;
                            addressCn.CountryId      = Guid.Empty;
                            addressCn.ProvinceId     = Guid.Empty;
                            addressCn.CityId         = Guid.Empty;
                            addressCn.District       = string.Empty;
                            addressCn.Mailing        = false;
                            addressCn.PhoneTag1      = PhoneTagEx.GetPhoneTagIdByPriority(1);
                            addressCn.PhoneTag1Value = item.TELW;
                            addressCn.PhoneTag2      = PhoneTagEx.GetPhoneTagIdByPriority(2);
                            addressCn.PhoneTag2Value = item.TELH;
                            addressCn.PhoneTag3      = PhoneTagEx.GetPhoneTagIdByPriority(3);
                            addressCn.PhoneTag3Value = item.FAX;
                            addressCn.PhoneTag4      = PhoneTagEx.GetPhoneTagIdByPriority(4);
                            addressCn.PhoneTag4Value = item.TELOTHER;
                            addressCn.PhoneTag5      = PhoneTagEx.GetPhoneTagIdByPriority(5);
                            addressCn.PhoneTag5Value = item.TELP;

                            ctx.SaveChanges();
                            #endregion
                            #endregion

                            #region SaveMemberSmartTags(memberId, item); HACK: 呢部份係 hard coded,如果 dbo.SmartTag4Member 唔一樣就會出事

                            #region 1.Grade
                            //SaveMemberSmartTag(memberId, GetSmartTagId("Grade", 1), objTempVip.GRADE);
                            // 2021.01.28 paulus: 由 GetIdByTagCodeAndPriority 改為 GetIdByPriority,咁樣日後個 TagCode 改咗都照 update 倒
                            var tagId = SmartTag4MemberEx.GetIdByPriority(1);
                            if (tagId != Guid.Empty)
                            {
                                var oTag1 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag1 == null)
                                {
                                    oTag1            = new EF6.MemberSmartTag();
                                    oTag1.SmartTagId = Guid.NewGuid();
                                    oTag1.MemberId   = id;
                                    oTag1.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag1);
                                }

                                oTag1.SmartTagValue = item.GRADE;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 2.Sex
                            //SaveMemberSmartTag(memberId, GetSmartTagId("Sex", 2), objTempVip.SEX);
                            tagId = SmartTag4MemberEx.GetIdByPriority(2);
                            if (tagId != Guid.Empty)
                            {
                                var oTag2 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag2 == null)
                                {
                                    oTag2            = new EF6.MemberSmartTag();
                                    oTag2.SmartTagId = Guid.NewGuid();
                                    oTag2.MemberId   = id;
                                    oTag2.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag2);
                                }

                                oTag2.SmartTagValue = item.SEX;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 3.Race
                            //SaveMemberSmartTag(memberId, GetSmartTagId("Race", 3), objTempVip.RACE);
                            tagId = SmartTag4MemberEx.GetIdByPriority(3);
                            if (tagId != Guid.Empty)
                            {
                                var oTag3 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag3 == null)
                                {
                                    oTag3            = new EF6.MemberSmartTag();
                                    oTag3.SmartTagId = Guid.NewGuid();
                                    oTag3.MemberId   = id;
                                    oTag3.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag3);
                                }

                                oTag3.SmartTagValue = item.RACE;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 4.Age Group
                            //SaveMemberSmartTag(memberId, GetSmartTagId("Age Group", 4), objTempVip.AGE_GROUP);
                            tagId = SmartTag4MemberEx.GetIdByPriority(4);
                            if (tagId != Guid.Empty)
                            {
                                var oTag4 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag4 == null)
                                {
                                    oTag4            = new EF6.MemberSmartTag();
                                    oTag4.SmartTagId = Guid.NewGuid();
                                    oTag4.MemberId   = id;
                                    oTag4.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag4);
                                }

                                oTag4.SmartTagValue = item.AGE_GROUP;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 5.CodeNumber
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("CodeNumber", 5), objTempVip.CODENUM);
                            tagId = SmartTag4MemberEx.GetIdByPriority(5);
                            if (tagId != Guid.Empty)
                            {
                                var oTag5 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag5 == null)
                                {
                                    oTag5            = new EF6.MemberSmartTag();
                                    oTag5.SmartTagId = Guid.NewGuid();
                                    oTag5.MemberId   = id;
                                    oTag5.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag5);
                                }

                                oTag5.SmartTagValue = item.CODENUM;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 6.LoyaltyNum
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("LoyaltyNum", 6), objTempVip.LOYALTYNUM);
                            tagId = SmartTag4MemberEx.GetIdByPriority(6);
                            if (tagId != Guid.Empty)
                            {
                                var oTag6 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag6 == null)
                                {
                                    oTag6            = new EF6.MemberSmartTag();
                                    oTag6.SmartTagId = Guid.NewGuid();
                                    oTag6.MemberId   = id;
                                    oTag6.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag6);
                                }

                                oTag6.SmartTagValue = item.LOYALTYNUM;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 7.Profile
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("Profile", 7), objTempVip.PROFILE);
                            tagId = SmartTag4MemberEx.GetIdByPriority(7);
                            if (tagId != Guid.Empty)
                            {
                                var oTag7 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag7 == null)
                                {
                                    oTag7            = new EF6.MemberSmartTag();
                                    oTag7.SmartTagId = Guid.NewGuid();
                                    oTag7.MemberId   = id;
                                    oTag7.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag7);
                                }

                                oTag7.SmartTagValue = item.PROFILE;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 8.DOB
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("DOB", 8), objTempVip.DATE_BIRTH.Value.ToString("yyyy-MM-dd"));
                            tagId = SmartTag4MemberEx.GetIdByPriority(8);
                            if (tagId != Guid.Empty)
                            {
                                var oTag8 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag8 == null)
                                {
                                    oTag8            = new EF6.MemberSmartTag();
                                    oTag8.SmartTagId = Guid.NewGuid();
                                    oTag8.MemberId   = id;
                                    oTag8.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag8);
                                }

                                oTag8.SmartTagValue = item.DATE_BIRTH.HasValue ? item.DATE_BIRTH.Value.ToString("yyyy-MM-dd") : "";
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 9.DOR
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("DOR", 9), objTempVip.DATE_REGIS.Value.ToString("yyyy-MM-dd"));
                            tagId = SmartTag4MemberEx.GetIdByPriority(9);
                            if (tagId != Guid.Empty)
                            {
                                var oTag9 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag9 == null)
                                {
                                    oTag9            = new EF6.MemberSmartTag();
                                    oTag9.SmartTagId = Guid.NewGuid();
                                    oTag9.MemberId   = id;
                                    oTag9.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag9);
                                }

                                oTag9.SmartTagValue = item.DATE_REGIS.HasValue ? item.DATE_REGIS.Value.ToString("yyyy-MM-dd") : "";
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 10.HKID
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("HKID", 10), objTempVip.ID_NO);
                            tagId = SmartTag4MemberEx.GetIdByPriority(10);
                            if (tagId != Guid.Empty)
                            {
                                var oTag10 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag10 == null)
                                {
                                    oTag10            = new EF6.MemberSmartTag();
                                    oTag10.SmartTagId = Guid.NewGuid();
                                    oTag10.MemberId   = id;
                                    oTag10.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag10);
                                }

                                oTag10.SmartTagValue = item.ID_NO;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 11.Nationalit
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("Nationalit", 11), objTempVip.NATION);
                            tagId = SmartTag4MemberEx.GetIdByPriority(11);
                            if (tagId != Guid.Empty)
                            {
                                var oTag11 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag11 == null)
                                {
                                    oTag11            = new EF6.MemberSmartTag();
                                    oTag11.SmartTagId = Guid.NewGuid();
                                    oTag11.MemberId   = id;
                                    oTag11.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag11);
                                }

                                oTag11.SmartTagValue = item.NATION;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 12.Email
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("Email", 12), objTempVip.EMAIL);
                            tagId = SmartTag4MemberEx.GetIdByPriority(12);
                            if (tagId != Guid.Empty)
                            {
                                var oTag12 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag12 == null)
                                {
                                    oTag12            = new EF6.MemberSmartTag();
                                    oTag12.SmartTagId = Guid.NewGuid();
                                    oTag12.MemberId   = id;
                                    oTag12.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag12);
                                }

                                oTag12.SmartTagValue = item.EMAIL;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 13.ComName EN
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("ComName EN", 13), objTempVip.COMPNAME);
                            tagId = SmartTag4MemberEx.GetIdByPriority(13);
                            if (tagId != Guid.Empty)
                            {
                                var oTag13 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag13 == null)
                                {
                                    oTag13            = new EF6.MemberSmartTag();
                                    oTag13.SmartTagId = Guid.NewGuid();
                                    oTag13.MemberId   = id;
                                    oTag13.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag13);
                                }

                                oTag13.SmartTagValue = item.COMPNAME;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #region 14.ComName CN
                            //this.SaveMemberSmartTag(memberId, GetSmartTagId("ComName CN", 14), objTempVip.COMPNAMEC);
                            tagId = SmartTag4MemberEx.GetIdByPriority(14);
                            if (tagId != Guid.Empty)
                            {
                                var oTag14 = ctx.MemberSmartTag.Where(x => x.MemberId == id && x.TagId == tagId).FirstOrDefault();
                                if (oTag14 == null)
                                {
                                    oTag14            = new EF6.MemberSmartTag();
                                    oTag14.SmartTagId = Guid.NewGuid();
                                    oTag14.MemberId   = id;
                                    oTag14.TagId      = tagId;

                                    ctx.MemberSmartTag.Add(oTag14);
                                }

                                oTag14.SmartTagValue = item.COMPNAMEC;
                                ctx.SaveChanges();
                            }
                            #endregion

                            #endregion

                            #region SaveMemberVip(memberId, item);
                            var oVip = ctx.MemberVipData.Where(x => x.MemberId == id).FirstOrDefault();
                            if (oVip == null)
                            {
                                oVip             = new EF6.MemberVipData();
                                oVip.MemberVipId = Guid.NewGuid();
                                oVip.MemberId    = id;
                                oVip.VipNumber   = item.VIPNO;

                                ctx.MemberVipData.Add(oVip);
                            }

                            oVip.CARD_ISSUE       = item.CARD_ISSUE;
                            oVip.CARD_EXPIRE      = item.CARD_EXPIRE;
                            oVip.CARD_NAME        = item.CARD_NAME;
                            oVip.CARD_RECEIVE     = item.CARD_RECEIVE.Value;
                            oVip.CARD_ACTIVE      = item.CARD_ACTIVE.Value;
                            oVip.FORMER_PPNO      = item.FORMER_PPNO;
                            oVip.MigrationDate    = item.DATE_MIGRATE;
                            oVip.CommencementDate = item.DATE_COMM;
                            oVip.CreditLimit      = item.ACREDIT;
                            oVip.CreditTerms      = item.TERMS;
                            oVip.PaymentDiscount  = (decimal)item.PYDISC;
                            oVip.AddOnDiscount    = item.BADDONDISC == "Y" ? true : false;
                            oVip.StaffQuota       = item.STAFF_QUOTA;

                            ctx.SaveChanges();
                            var memberVipId = oVip.MemberVipId;

                            #region this.UpdateLoo(oVip.MemberVipId, item);
                            var oVipLoo = ctx.MemberVipLineOfOperation.Where(x => x.MemberVipId == memberVipId).FirstOrDefault();
                            if (oVipLoo == null)
                            {
                                oVipLoo                   = new EF6.MemberVipLineOfOperation();
                                oVipLoo.VipLooId          = Guid.NewGuid();
                                oVipLoo.VipLooId          = System.Guid.NewGuid();
                                oVipLoo.MemberVipId       = memberVipId;
                                oVipLoo.LineOfOperationId = LineOfOperationEx.GetLineOfOperationIdByName(item.LOOID);

                                ctx.MemberVipLineOfOperation.Add(oVipLoo);
                            }
                            oVipLoo.NormalDiscount    = (decimal)item.NRDISC;
                            oVipLoo.PromotionDiscount = (decimal)item.PRO_DISC;
                            ctx.SaveChanges();
                            #endregion

                            #region this.UpdateSupplement(oVip.MemberVipId, item);
                            var oSupplement = ctx.MemberVipSupplement.Where(x => x.MemberVipId == memberVipId).FirstOrDefault();
                            if (oSupplement == null)
                            {
                                oSupplement = new EF6.MemberVipSupplement();
                                oSupplement.VipSupplementId = Guid.NewGuid();
                                oSupplement.VipSupplementId = System.Guid.NewGuid();
                                oSupplement.MemberVipId     = memberVipId;
                                oSupplement.CustomerNumber  = item.CUSTNUM;
                                oSupplement.BRANCH          = item.BRANCH;

                                ctx.MemberVipSupplement.Add(oSupplement);
                            }

                            oSupplement.Remarks1             = item.R1;
                            oSupplement.Remarks2             = item.R2;
                            oSupplement.Remarks3             = item.R3;
                            oSupplement.Nature               = item.NATURE;
                            oSupplement.Memo                 = item.MEMO;
                            oSupplement.Photo                = item.PHOTO;
                            oSupplement.MostVisitedMalls1    = item.MALL1;
                            oSupplement.MostVisitedMalls2    = item.MALL2;
                            oSupplement.MostVisitedMalls3    = item.MALL3;
                            oSupplement.MostBoughtBrands1    = item.BRAND1;
                            oSupplement.MostBoughtBrands2    = item.BRAND2;
                            oSupplement.MostBoughtBrands3    = item.BRAND3;
                            oSupplement.MostReadMagazine1    = item.MAGAZINE1;
                            oSupplement.MostReadMagazine2    = item.MAGAZINE2;
                            oSupplement.MostReadMagazine3    = item.MAGAZINE3;
                            oSupplement.MostUsedCreditCards1 = item.CARD1;
                            oSupplement.MostUsedCreditCards2 = item.CARD2;
                            oSupplement.MostUsedCreditCards3 = item.CARD3;
                            ctx.SaveChanges();
                            #endregion                            #endregion

                            #endregion

                            ctx.MemberApply4TempVip.Remove(item);
                            ctx.SaveChanges();
                        }

                        scope.Commit();
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        scope.Rollback();
                    }
                }
            }

            return(result);
        }
Esempio n. 11
0
 /// <summary>
 /// Gets the smart tag id.
 /// </summary>
 /// <param name="tagCode">The tag code.</param>
 /// <param name="priority">The priority.</param>
 /// <returns></returns>
 private Guid GetSmartTagId(string tagCode, int priority)
 {
     return(SmartTag4MemberEx.GetIdByTagCodeAndPriority(tagCode, priority));
 }
Esempio n. 12
0
 private Guid GetSmartTagId(string priority)
 {
     return(SmartTag4MemberEx.GetIdByPriority(int.Parse(priority)));
 }