Beispiel #1
0
	protected void SetCustomerFlags()
	{
        try
        {
            tbl_Customer Member = new tbl_Customer(long.Parse(MemberId),false);
		    m_bolHasCustomerRecord = true;
            Username = Member.cusUserName;
            m_dasBillingInfo = DataLayerFactory.GetMarketPlace().AucGetBillingInfo(Username);
        }
        catch (Exception ex)
        {
		    m_bolHasCustomerRecord = false;
            return;
        }
	}
Beispiel #2
0
        public void Run()
        {
            try
            {
                List<HarperLINQ.Referral> referrals = Referral.GetNeedsReminderList();
                foreach (Referral referral in referrals)
                {
                    tbl_Customer member = new tbl_Customer(referral.memberid, false);
                    string cc = null;
                    if (referral.ccmember)
                    {
                        cc = member.cusEmail;
                    }

                    ReferralOffer offer = new ReferralOffer(referral.keycode, referral.pubcode);
                    string membername = string.Format("{0} {1}", member.cusFirstName, member.cusLastName);
                    string link = string.Format("{0}/Referral/Redeem.aspx?ReferralId={1}", ConfigurationManager.AppSettings["server"], System.Web.HttpUtility.UrlEncode(HarperCRYPTO.Cryptography.EncryptData(referral.id.ToString())));
                    string emailbody = offer.reminderemailcopy.Replace("[membername]", membername).Replace("[friendname]", referral.friendname).Replace("[link]", link);

                    SimpleMail reminder = new SimpleMail(offer.reminderemailsubject,
                                                        offer.reminderemailfromaddress,
                                                        referral.friendemail,
                        //"*****@*****.**",
                                                        string.Empty, //do not cc the reminders?
                                                        offer.reminderemailbcc,
                                                        emailbody,
                                                        offer.reminderemailishtml.HasValue ? offer.reminderemailishtml.Value : true,
                                                        offer.reminderemailsmtp);
                    reminder.Save();
                    referral.reminderemailid = reminder.id;
                    referral.Save();
                }
            }
            catch (Exception ex)
            {
                string SourceName = "ReferralReminder";
                if (!EventLog.SourceExists(SourceName))
                {
                    EventLog.CreateEventSource(SourceName, "Application");
                }

                EventLog eventLog = new EventLog();
                eventLog.Source = SourceName;
                string message = string.Format("Exception: {0} \n\nStack: {1}", ex.Message, ex.StackTrace);
                eventLog.WriteEntry(message, EventLogEntryType.Error);
            }
        }
        public void PASS_ReferralCreate()
        {
            try
            {
                HarperLINQ.tbl_Customer             mike   = new HarperLINQ.tbl_Customer("mcoupland", true);
                MembershipService.MembershipService client = new Tests.MembershipService.MembershipService();
                MembershipService.BaseResponse      actual = client.CreateReferral(HarperCRYPTO.Cryptography.EncryptData(mike.cusID.ToString()), "Michael Coupland",
                                                                                   "*****@*****.**", "POTRIAL", "PO", "Michellez Coupland", "*****@*****.**", true);

                int i = actual.Messages.Count();
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                Assert.AreEqual(true, true);//test passed
            }
        }
Beispiel #4
0
 //test: http://localhost:54094/HarperNET/Referral/Refer.aspx?MemberId=69835e4e4826be87769ab83335a6e5fa-7d4c1d49d123e8e13bc94d5e2561a170-MTM5OTMw&KeyCode=POTRIAL&PubCode=PO
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         btn_create_submit.Enabled = true;
         lblErrorMessage.Controls.Clear();
         memberId = Cryptography.DeHash(Request.Params["MemberId"],true);
         memberObject = new tbl_Customer(long.Parse(memberId), false);
         if (string.IsNullOrEmpty(memberObject.cusEmail)) { throw new Exception(string.Format("Unable to load Refer a friend refer.aspx, Member id {0}is invalid (no email).", memberId)); }
         memberName = string.Format("{0} {1}", new object[] { memberObject.cusFirstName, memberObject.cusLastName });
         if (!Page.IsPostBack)
         {
             donor_name.Text = memberName;
         }
         memberEmail = memberObject.cusEmail;
         try
         {
             keyCode = Request.Params["KeyCode"];
             pubCode = Request.Params["PubCode"];
             if (keyCode == null) { throw new Exception("Unable to load Refer a friend refer.aspx, Key code is null."); }
             if (pubCode == null) { throw new Exception("Unable to load Refer a friend refer.aspx, Pub code is null."); }
             if (keyCode != "POTRIAL") { throw new Exception("Unable to load Refer a friend refer.aspx, Key code is not POTRIAL."); }
             if (pubCode != "PO") { throw new Exception("Unable to load Refer a friend refer.aspx, Pub code is not PO."); }
         }
         catch
         {
             LiteralControl err = new LiteralControl();
             err.Text = "<p class=\"error-message\">An error has occurred.  Please contact the membership department at <a href=\"mailto:[email protected]\">[email protected]</a></p>";
             lblErrorMessage.Controls.Add(err);
             lblErrorMessage.Visible = true;
             btn_create_submit.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         LiteralControl err = new LiteralControl();
         err.Text = "<p class=\"error-message\">We are unable to locate your record. Please contact the membership department at <a href=\"mailto:[email protected]\">[email protected]</a></p>";            
         lblErrorMessage.Controls.Add(err);
         lblErrorMessage.Visible = true;
         btn_create_submit.Enabled = false;
     }        
 }
 public static object[] Login(string enc_username, string enc_password)
 {
     tbl_Customer customer = new tbl_Customer();
     tbl_AddressCustomer address = new tbl_AddressCustomer();
     tbl_NetMembership current_netmembership = new tbl_NetMembership();            
     CustomerResponseCode response_code = Authenticate(enc_username, enc_password);
     if (response_code == CustomerResponseCode.SUCCESS)
     {
         customer = new tbl_Customer(enc_username, true, true);
         address = new tbl_AddressCustomer(customer.addID);
         current_netmembership = tbl_NetMembership.GetCurrentNetMembership(customer.cusID);
         if (current_netmembership == null)
         {
             response_code = CustomerResponseCode.NO_SUB;
         }
     }
     return new object[] { response_code, customer, address, current_netmembership };
 }
 private void GetData(tbl_Customer customer)
 {
     customer.cusID = this.cusID;
     customer.cusCustNum = this.cusCustNum;
     customer.cusQuickFillCustNum = this.cusQuickFillCustNum;
     customer.cusSecNum = this.cusSecNum;
     customer.cusCustType = this.cusCustType;
     customer.cusFirstName = this.cusFirstName;
     customer.cusLastName = this.cusLastName;
     customer.cusPAFirstName = this.cusPAFirstName;
     customer.cusPALastName = this.cusPALastName;
     customer.cusPAPhone1 = this.cusPAPhone1;
     customer.cusPAPhone1Ext = this.cusPAPhone1Ext;
     customer.cusCompany = this.cusCompany;
     customer.addID = this.addID;
     customer.addSeasonID = this.addSeasonID;
     customer.cusSeasonStart = this.cusSeasonStart;
     customer.cusSeasonEnd = this.cusSeasonEnd;
     customer.addAltAdd1ID = this.addAltAdd1ID;
     customer.cusPrefix = this.cusPrefix;
     customer.cusSuffix = this.cusSuffix;
     customer.cusTitle = this.cusTitle;
     customer.cusDepartment = this.cusDepartment;
     customer.cusPhone1 = this.cusPhone1;
     customer.cusPhone1Ext = this.cusPhone1Ext;
     customer.cusPhone2 = this.cusPhone2Ext;
     customer.cusPhone2Ext = this.cusPhone2Ext;
     customer.cusMobile = this.cusMobile;
     customer.cusFax = this.cusFax;
     customer.cusEmail = this.cusEmail;
     customer.cusUserName = this.cusUserName;
     customer.cusIsCharterMem = this.cusIsCharterMem;
     customer.cusNextQClubCardDate = this.cusNextQClubCardDate;
     customer.cusSource = this.cusSource;
     customer.cusTempID = this.cusTempID;
     customer.cusSecQClubCardName = this.cusSecQClubCardName;
     customer.cusUserLastUpdated = this.cusUserLastUpdated;
     customer.cusDateCreated = this.cusDateCreated;
     customer.cusDateUpdated = this.cusDateUpdated;
     customer.cusIsDeleted = this.cusIsDeleted;
     customer.cusPriFirstName = this.cusPriFirstName;
     customer.cusPriLastName = this.cusPriLastName;
     customer.cusNickname = this.cusNickname;
     customer.cusSex = this.cusSex;
     customer.cusDOB = this.cusDOB;
     customer.cusDisplayName = this.cusDisplayName;
     customer.cusGUID = this.cusGUID;
     customer.cusHasDisplayName = this.cusHasDisplayName;
     customer.cusDisplayNameUpdated = this.cusDisplayNameUpdated;
     customer.cusAffiliation = this.cusAffiliation;
     customer.cusMemberSince = this.cusMemberSince;
     customer.cusAppStatus = this.cusAppStatus;
     customer.cusComplimentsOf = this.cusComplimentsOf;
     customer.cusTrialCardName = this.cusTrialCardName;
     customer.cusEncryptedPassword = this.cusEncryptedPassword;
     customer.cusPasswordSalt = this.cusPasswordSalt;
     customer.cusPassword = this.cusPassword;
     customer.SfgId = this.SfgId;
     customer.cusSecondEmail = this.cusSecondEmail;
     customer.cusKeyCode = this.cusKeyCode;
     customer.csoCode = this.csoCode;
 }        
Beispiel #7
0
    protected void SubmitClicked(object sender, EventArgs e)
    { 
        if (string.IsNullOrEmpty(email.Text))
        {
            SetError(new Exception("Email address is required."));
            pnlForm.Visible = true;
        }
        else
        {
            try
            {
                HarperSecureService.UpdatePasswordResponse updateResponse = new HarperSecureService.UpdatePasswordResponse();
                HarperLINQ.tbl_Customer user = new HarperLINQ.tbl_Customer(email.Text, false);
                if (user == null)
                {
                    SetError(new Exception("Unable to find a member with this address."));
                    lblMessage.Text = "Unable to find a member with this email address.";
                    pnlForm.Visible = true;
                }
                else
                {
                    if (string.IsNullOrEmpty(user.cusPassword))
                    {
                        SetError(new Exception("Error retrieving password - no password or blank password on file."));
                        lblMessage.Text = string.Format("{0}</br>{1}</br>", new object[] { Resources.GlobalStrings.Apology, Resources.GlobalStrings.ContactUs });
                        pnlForm.Visible = true;
                    }
                    else
                    {
                        string pwd = Cryptography.Decrypt256FromHEX(user.cusPassword);
                        if (!string.IsNullOrEmpty(user.cusUserName)
                            && !string.IsNullOrEmpty(pwd)
                            && !string.IsNullOrEmpty(email.Text))
                        {
                            SupportClasses.Mailer Emailer = new SupportClasses.Mailer();
                            Emailer.SendEmail(ConfigurationManager.AppSettings["mailserviceuser"],
                                ConfigurationManager.AppSettings["mailservicepwd"],
                                "Andrew Harper Password Reminder",
                                ConfigurationManager.AppSettings["MembershipEmailFrom"].ToString(),
                                user.cusEmail,
                                string.Empty, string.Empty,
                                getEmailBody(user.cusUserName, pwd), true,
                                ConfigurationManager.AppSettings["EmailServer"]);

                            lblConfirmation.Visible = true;
                            pnlForm.Visible = false;
                            lblMessage.Visible = false;
                            string s = "<p>As requested, a reminder of your username and password has been sent to " + user.cusEmail + ".  Please retrieve your credentials, and use them to log in to our website <a href=\"http://www.andrewharper.com/login\" target=\"_top\">here</a>.</p><p>As a reminder, all username and passwords are case-sensitive.</p><p>If you do not receive the email shortly, please check your spam or junk email folder.  If you continue to experience difficulties, please contact Membership at [email protected] or call (866) 831-4314 from the U.S or +1 (512) 904-7342 internationally.</p>";
                            lblConfirmation.Text = s;// string.Format("A reminder has been sent to {0}. If you do not receive the email within thirty minutes please check your spam or junk email folder.", email.Text);
                            lblConfirmation.Visible = true;

                            WriteLog(string.Format("Password for {0} was sent to {1}", new object[] { user.cusUserName, user.cusEmail }));
                        }
                        else
                        {
                            SetError(new Exception("Unable to send password reminder email."));
                            lblMessage.Text = "Unable to send password reminder email.";
                            pnlForm.Visible = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SetError(new Exception("Unable to send password reminder email, email address may be duplicate."));
                lblMessage.Text = "Unable to send password reminder email, email address may be duplicate.";
                pnlForm.Visible = true;
                WriteLog(ex);
            }
        }
    }
Beispiel #8
0
        public void PASS_ReferralCreate()
        {
            try
            {
                HarperLINQ.tbl_Customer mike = new HarperLINQ.tbl_Customer("mcoupland", true);
                MembershipService.MembershipService client = new Tests.MembershipService.MembershipService();
                MembershipService.BaseResponse actual = client.CreateReferral(HarperCRYPTO.Cryptography.EncryptData(mike.cusID.ToString()), "Michael Coupland", 
                    "*****@*****.**", "POTRIAL", "PO", "Michellez Coupland", "*****@*****.**", true);

                int i = actual.Messages.Count();
            }
            catch(Exception ex)
            {
                string s = ex.Message;
                Assert.AreEqual(true, true);//test passed 
            }
        }
        public BaseResponse CreateReferral(string cusid, string membername, string memberemail, string keycode,
             string pubcode, string friendname, string friendemailaddress, bool ccmember)
        {
            methodName = "CreateReferral";
            
            List<Message> errors = new List<Message>();
            Referral referral = new Referral();
            try
            {
                tbl_Customer member = new tbl_Customer(int.Parse(cusid), false);

                #region validate input
                if (member == null)
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralInputValidationException", BusinessLogicStrings.memberDoesNotExistError, cusid, "", null));
                }
                if (member.SfgId == null)
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralInputValidationException", BusinessLogicStrings.invalidMemberIdError, "", "", null));
                }
                if (string.IsNullOrEmpty(membername))
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralInputValidationException", BusinessLogicStrings.missingMemberNameError, "", "", null));
                }
                if (ccmember && string.IsNullOrEmpty(memberemail))
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralInputValidationException", BusinessLogicStrings.missingMemberEmailError, "", "", null));
                }
                if (string.IsNullOrEmpty(keycode))
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralInputValidationException", BusinessLogicStrings.missingKeycodeError, "", "", null));
                }
                if (string.IsNullOrEmpty(pubcode))
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralInputValidationException", BusinessLogicStrings.missingPubcodeError, "", "", null));
                }
                if (string.IsNullOrEmpty(friendname))
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralInputValidationException", BusinessLogicStrings.missingFriendNameError, "", "", null));
                }
                if (string.IsNullOrEmpty(friendemailaddress))
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralInputValidationException", BusinessLogicStrings.missingFriendEmailError, "", "", null));
                }
                #endregion

                #region enforce business rules
                tbl_Customer friend = new tbl_Customer(friendemailaddress, false);
                try
                {
                    Referral existing_referral = new Referral(friendemailaddress);

                    if (memberemail == friendemailaddress)
                    {
                        errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralBusinessRuleException", BusinessLogicStrings.cannotReferSelfError, "", "", null));
                    }
                    else if (friend.cusID > 0)
                    {
                        errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralBusinessRuleException", BusinessLogicStrings.existingMemberError, "", "", null));
                    }
                    else if (existing_referral.dateredeemed == null)
                    {
                        if (existing_referral.id > 0 && existing_referral.dateexpires.CompareTo(DateTime.Now) >= 0)
                        {
                            errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralBusinessRuleException", BusinessLogicStrings.existingReferralError, "", "", null));
                        }
                    }
                    if (errors.Count <= 0)
                    {
                        GetMemberResponse checkFriend = (GetMemberByUserName(friendemailaddress).TypedResponse as GetMemberResponse);
                        if (checkFriend != null && (checkFriend.MemberFound || checkFriend.WebAccountFound))
                        {
                            errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralBusinessRuleException", BusinessLogicStrings.freindEmailInUseSFGError, "", "", null));
                        }
                    }
                }
                catch (HarperLINQ.DataLoadException dle)
                {
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateReferralBusinessRuleException", BusinessLogicStrings.freindEmailInUseAHError, "", "", null));
                }
                if (errors.Count() > 0)
                {
                    string errstring = string.Empty;
                    foreach (Message msg in errors)
                    {
                        string sfgmessages = string.Empty;
                        if (msg.SfgMessages != null)
                        {
                            foreach (string sfgmsg in msg.SfgMessages)
                            {
                                sfgmessages += string.Format("SFGMessage: {0}", sfgmsg);
                            }
                        }
                        errstring += string.Format("AhMessage: {0}|| {1}", new object[] { msg.AhMessage, sfgmessages });
                    }
                    throw new Exception(string.Format("Error creating referral: [{0}]", errstring));
                }
                #endregion

                ReferralOffer offer = new ReferralOffer(keycode, pubcode);
                

                #region save referral
                referral = new Referral(int.Parse(cusid), membername, memberemail, keycode, pubcode, friendname, friendemailaddress, ccmember, offer.triallengthinmonths, offer.offerexpiresmonths);
                referral.Save();
                #endregion

                #region send email
                //create mailer and sent mail
                Mailer mailer = new Mailer();

                string ccEmail = memberemail; 

                if (!ccmember)
                {
                    ccEmail = string.Empty;
                }
                
                mailer.SendEmail(ConfigurationManager.AppSettings["mailserviceuser"], 
                    ConfigurationManager.AppSettings["mailservicepwd"],
                    string.Format("Membership Invitation from {0}", membername), 
                    ConfigurationManager.AppSettings["referemailfrom"],
                    friendemailaddress,
                    ccEmail, 
                    string.Empty, 
                    referral.GetReferralEmailBody(), 
                    true, 
                    ConfigurationManager.AppSettings["smtpserver"]);
                #endregion

            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }
            if (baseResponse != null && baseResponse.Messages != null)
            {
                foreach (Message error in errors)
                {
                    baseResponse.Messages.Add(error);
                }
            }
            if (baseResponse.Messages.Count() <= 0 && referral != null && referral.id >= 0)
            {
                #region create typed response
                baseResponse.TypedResponse = new ReferralResponse();
                baseResponse.TypedResponse.Success = true;
                (baseResponse.TypedResponse as ReferralResponse).referralid = referral.id;
                #endregion
            }
            else
            {
                baseResponse.TypedResponse = new ReferralResponse();
                baseResponse.TypedResponse.Success = false;
            }
            
            return baseResponse;
        }
 partial void Inserttbl_Customer(tbl_Customer instance);
 partial void Updatetbl_Customer(tbl_Customer instance);
Beispiel #12
0
        public void UnDeleteUser()
        {
            using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
            {
                bool   exists   = false;
                string errormsg = string.Empty;

                #region check email
                int existing = (from a in context.tbl_Customers
                                where a.cusIsDeleted == false &&
                                a.cusID != this.cusID &&
                                a.cusEmail == this.cusArchiveEmail
                                select a).Count();
                if (existing > 0)
                {
                    exists   = true;
                    errormsg = "Email in use.";
                }
                #endregion

                #region check user name
                existing = 0;
                existing = (from a in context.tbl_Customers
                            where a.cusIsDeleted == false &&
                            a.cusID != this.cusID &&
                            a.cusUserName == this.cusArchiveUsername
                            select a).Count();
                if (existing > 0)
                {
                    exists    = true;
                    errormsg += "User Name in use.";
                }
                #endregion

                #region check screen name
                existing = 0;
                existing = (from a in context.tbl_Customers
                            where a.cusIsDeleted == false &&
                            a.cusID != this.cusID &&
                            a.cusDisplayName == this.cusArchiveDisplayName
                            select a).Count();
                if (existing > 0)
                {
                    exists    = true;
                    errormsg += "Screen Name in use.";
                }
                #endregion

                if (exists)
                {
                    throw new Exception(string.Format("Unable to un-delete user, {0}", errormsg));
                }
                else
                {
                    tbl_Customer me = (from a in context.tbl_Customers
                                       where a.cusID == this.cusID
                                       select a).Single();
                    me.cusIsDeleted          = false;
                    me.cusEmail              = me.cusArchiveEmail;
                    me.cusUserName           = me.cusArchiveUsername;
                    me.cusDisplayName        = me.cusArchiveDisplayName;
                    me.cusArchiveEmail       = string.Empty;
                    me.cusArchiveUsername    = string.Empty;
                    me.cusArchiveDisplayName = string.Empty;
                    context.SubmitChanges();
                }
            }
        }
 partial void Deletetbl_Customer(tbl_Customer instance);
Beispiel #14
0
        public static object[] CreateCustomer(string address1, string address2, string address3,
                                              string city, string region, string country, string postal, string source,
                                              string password, string customertype, string salutation, string firstname,
                                              string middleinitial, string lastname, string suffix, string emailaddress,
                                              string username, string newmemberid, string pubcode, string expiredate,
                                              string startdate, string screenname, string mobilephone, string secondemail, string keycode)
        {
            CustomerResponseCode responsecode  = 0;
            tbl_Customer         Customer      = new tbl_Customer();
            tbl_NetMembership    NetMembership = new tbl_NetMembership();
            tbl_AddressCustomer  Address       = new tbl_AddressCustomer();

            #region convert string input to correct types
            DateTime dt_expiredate = new DateTime();
            DateTime dt_startdate  = new DateTime();

            if (!DateTime.TryParse(expiredate, out dt_expiredate))
            {
                responsecode = CustomerResponseCode.CANNOT_CONVERT_EXPIREDATE;
            }
            if (!DateTime.TryParse(startdate, out dt_startdate))
            {
                responsecode = CustomerResponseCode.CANNOT_CONVERT_STARTDATE;
            }
            #endregion

            if (responsecode == 0)
            {
                #region check user name availability
                switch (tbl_Customer.CheckUserName(username))
                {
                case 0:
                    responsecode = 0;
                    break;

                case 1:
                    responsecode = CustomerResponseCode.DUPLICATE_USER_NAME;
                    break;

                case 2:
                    responsecode = CustomerResponseCode.DUPLICATE_EMAIL_ADDRESS;
                    break;

                case 3:
                    responsecode = CustomerResponseCode.DUPLICATE_USER_NAME;
                    break;
                }
                #endregion
                if (responsecode == 0)
                {
                    using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                    {
                        #region get cuscustnum
                        long newcustnum = 0;
                        try
                        {
                            long lastcustomer = (from a in context.tbl_Customers select a.cusCustNum).Select(x => Convert.ToInt64(x)).Max();
                            newcustnum = lastcustomer + 1;
                        }
                        catch
                        {
                            responsecode = CustomerResponseCode.CANNOT_CREATE_CUSCUSTNUM;
                        }
                        #endregion

                        if (responsecode == 0)
                        {
                            #region address data at AH
                            Address                = new tbl_AddressCustomer();
                            Address.addAddress1    = address1;
                            Address.addAddress2    = address2;
                            Address.addAddress3    = address3;
                            Address.addCity        = city;
                            Address.addCountry     = country;
                            Address.addDateCreated = DateTime.Now;
                            Address.addDateUpdated = DateTime.Now;
                            Address.addPostalCode  = postal;
                            Address.addRegion      = string.IsNullOrEmpty(region) ? "" : region;
                            Address.addSource      = string.Empty;
                            context.tbl_AddressCustomers.InsertOnSubmit(Address);
                            context.SubmitChanges();
                            #endregion

                            #region customer data at AH
                            Customer.cusEncryptedPassword = HarperCRYPTO.Cryptography.EncryptData(password);
                            Customer.cusPassword          = HarperCRYPTO.Cryptography.Encrypt256(password);
                            Customer.cusPasswordSalt      = HarperCRYPTO.Cryptography.Salt;
                            Customer.addID             = Address.addID;
                            Customer.cusCustNum        = newcustnum.ToString();
                            Customer.cusCustType       = customertype;
                            Customer.cusFirstName      = firstname;
                            Customer.cusLastName       = lastname;
                            Customer.cusPriFirstName   = firstname;
                            Customer.cusPriLastName    = lastname;
                            Customer.cusEmail          = emailaddress;
                            Customer.cusUserName       = username;
                            Customer.cusIsCharterMem   = false;
                            Customer.cusDateCreated    = DateTime.Now;
                            Customer.cusDateUpdated    = DateTime.Now;
                            Customer.cusIsDeleted      = false;
                            Customer.cusSex            = 'U';
                            Customer.cusGUID           = Guid.NewGuid();
                            Customer.cusDisplayName    = screenname;
                            Customer.cusMobile         = mobilephone;
                            Customer.cusHasDisplayName = true;
                            Customer.cusSecondEmail    = secondemail;
                            Customer.cusMemberSince    = DateTime.Now;
                            Customer.cusSource         = source;
                            Customer.cusKeyCode        = keycode;
                            Customer.csoCode           = source;
                            long.TryParse(newmemberid, out Customer.SfgId);
                            context.tbl_Customers.InsertOnSubmit(Customer);
                            context.SubmitChanges();
                            #endregion

                            #region sfg customer number data at AH
                            HarperLINQ.SFG_CustomerNumber SfgData = new HarperLINQ.SFG_CustomerNumber();
                            SfgData.cusID      = Customer.cusID;
                            SfgData.SFGCustNum = newmemberid;
                            context.SFG_CustomerNumbers.InsertOnSubmit(SfgData);
                            context.SubmitChanges();
                            #endregion

                            #region net membership data at AH
                            NetMembership                = new tbl_NetMembership();
                            NetMembership.cusID          = Customer.cusID;
                            NetMembership.mtyCode        = HarperLINQ.SFG_ProdCode.GetFromExtCode(pubcode).IntCode;
                            NetMembership.nmbDateCreated = DateTime.Now;
                            NetMembership.nmbDateEnd     = dt_expiredate;
                            NetMembership.nmbDateStart   = dt_startdate;
                            context.tbl_NetMemberships.InsertOnSubmit(NetMembership);
                            context.SubmitChanges();
                            #endregion
                        }
                    }
                }
            }
            return(new object[] { responsecode, Customer, Address, NetMembership });
        }
Beispiel #15
0
        public static CustomerResponseCode Authenticate(string enc_username, string enc_password)
        {
            bool result = true;
            CustomerResponseCode response_code = CustomerResponseCode.SUCCESS;

            #region decrypt input
            string u = string.Empty;
            string p = string.Empty;
            try
            {
                u = HarperCRYPTO.Cryptography.Decrypt256FromHEX(enc_username);
                p = HarperCRYPTO.Cryptography.Decrypt256FromHEX(enc_password);
            }
            catch
            {
                result        = false;
                response_code = CustomerResponseCode.CANNOT_DECRYPT_INPUT;
            }
            #endregion

            if (result)
            {
                using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                {
                    #region get customer by username
                    tbl_Customer customer = new tbl_Customer();
                    try
                    {
                        customer = (from a in context.tbl_Customers
                                    where a.cusUserName == u &&
                                    a.cusIsDeleted == false
                                    select a).SingleOrDefault();

                        if (customer == null)
                        {
                            result        = false;
                            response_code = CustomerResponseCode.NO_SUCH_USER_NAME;
                        }
                    }
                    catch
                    {
                        result        = false;
                        response_code = CustomerResponseCode.DUPLICATE_USER_NAME;
                    }
                    #endregion

                    if (result)
                    {
                        #region decrypt password
                        string storedpwd = string.Empty;
                        try
                        {
                            storedpwd = HarperCRYPTO.Cryptography.Decrypt256FromHEX(customer.cusPassword);
                        }
                        catch
                        {
                            result        = false;
                            response_code = CustomerResponseCode.CANNOT_DECRYPT_STORED_PWD;
                        }
                        #endregion

                        if (result)
                        {
                            #region compare passwords
                            if (storedpwd != p)
                            {
                                result        = false;
                                response_code = CustomerResponseCode.INVALID_PASSWORD;
                            }
                            #endregion
                        }
                    }
                }
            }
            return(response_code);
        }
Beispiel #16
0
 private void GetData(tbl_Customer customer)
 {
     customer.cusID                 = this.cusID;
     customer.cusCustNum            = this.cusCustNum;
     customer.cusQuickFillCustNum   = this.cusQuickFillCustNum;
     customer.cusSecNum             = this.cusSecNum;
     customer.cusCustType           = this.cusCustType;
     customer.cusFirstName          = this.cusFirstName;
     customer.cusLastName           = this.cusLastName;
     customer.cusPAFirstName        = this.cusPAFirstName;
     customer.cusPALastName         = this.cusPALastName;
     customer.cusPAPhone1           = this.cusPAPhone1;
     customer.cusPAPhone1Ext        = this.cusPAPhone1Ext;
     customer.cusCompany            = this.cusCompany;
     customer.addID                 = this.addID;
     customer.addSeasonID           = this.addSeasonID;
     customer.cusSeasonStart        = this.cusSeasonStart;
     customer.cusSeasonEnd          = this.cusSeasonEnd;
     customer.addAltAdd1ID          = this.addAltAdd1ID;
     customer.cusPrefix             = this.cusPrefix;
     customer.cusSuffix             = this.cusSuffix;
     customer.cusTitle              = this.cusTitle;
     customer.cusDepartment         = this.cusDepartment;
     customer.cusPhone1             = this.cusPhone1;
     customer.cusPhone1Ext          = this.cusPhone1Ext;
     customer.cusPhone2             = this.cusPhone2Ext;
     customer.cusPhone2Ext          = this.cusPhone2Ext;
     customer.cusMobile             = this.cusMobile;
     customer.cusFax                = this.cusFax;
     customer.cusEmail              = this.cusEmail;
     customer.cusUserName           = this.cusUserName;
     customer.cusIsCharterMem       = this.cusIsCharterMem;
     customer.cusNextQClubCardDate  = this.cusNextQClubCardDate;
     customer.cusSource             = this.cusSource;
     customer.cusTempID             = this.cusTempID;
     customer.cusSecQClubCardName   = this.cusSecQClubCardName;
     customer.cusUserLastUpdated    = this.cusUserLastUpdated;
     customer.cusDateCreated        = this.cusDateCreated;
     customer.cusDateUpdated        = this.cusDateUpdated;
     customer.cusIsDeleted          = this.cusIsDeleted;
     customer.cusPriFirstName       = this.cusPriFirstName;
     customer.cusPriLastName        = this.cusPriLastName;
     customer.cusNickname           = this.cusNickname;
     customer.cusSex                = this.cusSex;
     customer.cusDOB                = this.cusDOB;
     customer.cusDisplayName        = this.cusDisplayName;
     customer.cusGUID               = this.cusGUID;
     customer.cusHasDisplayName     = this.cusHasDisplayName;
     customer.cusDisplayNameUpdated = this.cusDisplayNameUpdated;
     customer.cusAffiliation        = this.cusAffiliation;
     customer.cusMemberSince        = this.cusMemberSince;
     customer.cusAppStatus          = this.cusAppStatus;
     customer.cusComplimentsOf      = this.cusComplimentsOf;
     customer.cusTrialCardName      = this.cusTrialCardName;
     customer.cusEncryptedPassword  = this.cusEncryptedPassword;
     customer.cusPasswordSalt       = this.cusPasswordSalt;
     customer.cusPassword           = this.cusPassword;
     customer.SfgId                 = this.SfgId;
     customer.cusSecondEmail        = this.cusSecondEmail;
     customer.cusKeyCode            = this.cusKeyCode;
     customer.csoCode               = this.csoCode;
 }
Beispiel #17
0
        public static CustomerResponseCode Authenticate(string enc_username, string enc_password)
        {
            bool result = true;
            CustomerResponseCode response_code = CustomerResponseCode.SUCCESS;

            #region decrypt input
            string u = string.Empty;
            string p = string.Empty;
            try
            {
                u = HarperCRYPTO.Cryptography.Decrypt256FromHEX(enc_username);
                p = HarperCRYPTO.Cryptography.Decrypt256FromHEX(enc_password);
            }
            catch
            {
                result = false;
                response_code = CustomerResponseCode.CANNOT_DECRYPT_INPUT;
            }
            #endregion

            if (result)
            {
                using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                {
                    #region get customer by username
                    tbl_Customer customer = new tbl_Customer();
                    try
                    {
                        customer = (from a in context.tbl_Customers
                                    where a.cusUserName == u
                                    && a.cusIsDeleted == false
                                    select a).SingleOrDefault();

                        if (customer == null)
                        {
                            result = false;
                            response_code = CustomerResponseCode.NO_SUCH_USER_NAME;
                        }
                    }
                    catch
                    {
                        result = false;
                        response_code = CustomerResponseCode.DUPLICATE_USER_NAME;
                    }
                    #endregion

                    if (result)
                    {
                        #region decrypt password
                        string storedpwd = string.Empty;
                        try
                        {
                            storedpwd = HarperCRYPTO.Cryptography.Decrypt256FromHEX(customer.cusPassword);
                        }
                        catch
                        {
                            result = false;
                            response_code = CustomerResponseCode.CANNOT_DECRYPT_STORED_PWD;
                        }
                        #endregion

                        if (result)
                        {
                            #region compare passwords
                            if (storedpwd != p)
                            {
                                result = false;
                                response_code = CustomerResponseCode.INVALID_PASSWORD;
                            }
                            #endregion
                        }
                    }
                }
            }
            return response_code;
        }
Beispiel #18
0
 public Member(int cusid)
 {
     try
     {
         tbl_Customer member = new tbl_Customer(cusid, false);
         this.CusId = member.cusID.ToString();
         this.OptIn = false;
         this.CusCustNum = member.cusCustNum;
         this.ScreenName = member.cusDisplayName;
         this.UserName = member.cusUserName;
         this.MemberId = member.SfgId.ToString();
         this.FirstName = member.cusFirstName;
         this.LastName = member.cusLastName;
         this.Address = new Address(member.addID);
     }
     catch { }
 }
Beispiel #19
0
        public static object[] CreateCustomer(string address1, string address2, string address3, 
            string city, string region, string country, string postal, string source, 
            string password, string customertype, string salutation, string firstname, 
            string middleinitial, string lastname, string suffix, string emailaddress, 
            string username, string newmemberid, string pubcode, string expiredate, 
            string startdate, string screenname, string mobilephone, string secondemail, string keycode)
        {
            CustomerResponseCode responsecode = 0;
            tbl_Customer Customer = new tbl_Customer();
            tbl_NetMembership NetMembership = new tbl_NetMembership();
            tbl_AddressCustomer Address = new tbl_AddressCustomer();

            #region convert string input to correct types
            DateTime dt_expiredate = new DateTime();
            DateTime dt_startdate = new DateTime();

            if (!DateTime.TryParse(expiredate, out dt_expiredate))
            {
                responsecode = CustomerResponseCode.CANNOT_CONVERT_EXPIREDATE;
            }
            if (!DateTime.TryParse(startdate, out dt_startdate))
            {
                responsecode = CustomerResponseCode.CANNOT_CONVERT_STARTDATE;
            }             
            #endregion

            if (responsecode == 0)
            {
                #region check user name availability
                switch (tbl_Customer.CheckUserName(username))
                {
                    case 0:
                        responsecode = 0;
                        break;
                    case 1:
                        responsecode = CustomerResponseCode.DUPLICATE_USER_NAME;
                        break;
                    case 2:
                        responsecode = CustomerResponseCode.DUPLICATE_EMAIL_ADDRESS;
                        break;
                    case 3:
                        responsecode = CustomerResponseCode.DUPLICATE_USER_NAME;
                        break;
                }
                #endregion
                if (responsecode == 0)
                {
                    using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                    {
                        #region get cuscustnum
                        long newcustnum = 0;
                        try
                        {
                            long lastcustomer = (from a in context.tbl_Customers select a.cusCustNum).Select(x => Convert.ToInt64(x)).Max();
                            newcustnum = lastcustomer + 1;
                        }
                        catch
                        {
                            responsecode = CustomerResponseCode.CANNOT_CREATE_CUSCUSTNUM;
                        }
                        #endregion

                        if (responsecode == 0)
                        {
                            #region address data at AH
                            Address = new tbl_AddressCustomer();
                            Address.addAddress1 = address1;
                            Address.addAddress2 = address2;
                            Address.addAddress3 = address3;
                            Address.addCity = city;
                            Address.addCountry = country;
                            Address.addDateCreated = DateTime.Now;
                            Address.addDateUpdated = DateTime.Now;
                            Address.addPostalCode = postal;
                            Address.addRegion = string.IsNullOrEmpty(region) ? "" : region;
                            Address.addSource = string.Empty;
                            context.tbl_AddressCustomers.InsertOnSubmit(Address);
                            context.SubmitChanges();
                            #endregion

                            #region customer data at AH
                            Customer.cusEncryptedPassword = HarperCRYPTO.Cryptography.EncryptData(password);
                            Customer.cusPassword = HarperCRYPTO.Cryptography.Encrypt256(password);
                            Customer.cusPasswordSalt = HarperCRYPTO.Cryptography.Salt;
                            Customer.addID = Address.addID;
                            Customer.cusCustNum = newcustnum.ToString();
                            Customer.cusCustType = customertype;
                            Customer.cusFirstName = firstname;
                            Customer.cusLastName = lastname;
                            Customer.cusPriFirstName = firstname;
                            Customer.cusPriLastName = lastname;
                            Customer.cusEmail = emailaddress;
                            Customer.cusUserName = username;
                            Customer.cusIsCharterMem = false;
                            Customer.cusDateCreated = DateTime.Now;
                            Customer.cusDateUpdated = DateTime.Now;
                            Customer.cusIsDeleted = false;
                            Customer.cusSex = 'U';
                            Customer.cusGUID = Guid.NewGuid();
                            Customer.cusDisplayName = screenname;
                            Customer.cusMobile = mobilephone;
                            Customer.cusHasDisplayName = true;
                            Customer.cusSecondEmail = secondemail;
                            Customer.cusMemberSince = DateTime.Now;
                            Customer.cusSource = source;
                            Customer.cusKeyCode = keycode;
                            Customer.csoCode = source;
                            long.TryParse(newmemberid, out Customer.SfgId);
                            context.tbl_Customers.InsertOnSubmit(Customer);
                            context.SubmitChanges();
                            #endregion

                            #region sfg customer number data at AH
                            HarperLINQ.SFG_CustomerNumber SfgData = new HarperLINQ.SFG_CustomerNumber();
                            SfgData.cusID = Customer.cusID;
                            SfgData.SFGCustNum = newmemberid;
                            context.SFG_CustomerNumbers.InsertOnSubmit(SfgData);
                            context.SubmitChanges();
                            #endregion

                            #region net membership data at AH
                            NetMembership = new tbl_NetMembership();
                            NetMembership.cusID = Customer.cusID;
                            NetMembership.mtyCode = HarperLINQ.SFG_ProdCode.GetFromExtCode(pubcode).IntCode;
                            NetMembership.nmbDateCreated = DateTime.Now;
                            NetMembership.nmbDateEnd = dt_expiredate;
                            NetMembership.nmbDateStart = dt_startdate;
                            context.tbl_NetMemberships.InsertOnSubmit(NetMembership);
                            context.SubmitChanges();
                            #endregion

                        }
                    }
                }
            }
            return new object[] { responsecode, Customer, Address, NetMembership };
        }
 private bool CreateNewUser()
 {
     tbl_Customer Customer = new tbl_Customer();
     try
     {
         HarperMembershipService.GetMemberResponse user = (HarperMembershipService.GetMemberResponse)Session["MemberResponse"];
         object[] response = tbl_Customer.CreateCustomer(user.MemberData.Address.Address1,
                 user.MemberData.Address.Address2,
                 user.MemberData.Address.Address3,
                 user.MemberData.Address.City,
                 user.MemberData.Address.State,
                 user.MemberData.Address.Country,
                 user.MemberData.Address.PostalCode,
                 null,  
                 txtPassword.Text.Trim(), "UNKNOWN",
                 user.MemberData.Salutation,
                 user.MemberData.FirstName,
                 user.MemberData.MiddleInitial,
                 user.MemberData.LastName,
                 user.MemberData.Suffix,
                 user.MemberData.Email,
                 txtUserName.Text.Trim(),
                 CustomerID,
                 user.MemberData.Subscriptions[0].PublicationCode,
                 user.MemberData.Subscriptions[0].ExpireDate,
                 user.MemberData.Subscriptions[0].DateEntered,
                 txtUserName.Text.Trim(),
                 string.Empty);
         if (response != null && response[0] != null && ((int)response[0]) == 0 && response[1] != null)
         {
             Customer = (tbl_Customer)response[1];
         }
     }
     catch 
     {
         return false; 
     }
     return true;
 }
 private bool SyncMembership(string enc_username)
 {
     tbl_Customer customer = new tbl_Customer(Cryptography.Decrypt256FromHEX(enc_username), true);
     GetMemberByMemberIdRequest req = new GetMemberByMemberIdRequest(customer.SfgId.ToString(), false);
     BaseResponse res = Gatekeeper.GetMemberByMemberId(req);
     if (res.Messages.Count() <= 0 && res.TypedResponse != null)
     {
         GetMemberResponse tres = (GetMemberResponse)res.TypedResponse;
         if (tres.MemberData != null
             && tres.MemberData.Subscriptions != null
             && tres.MemberData.Subscriptions.Count() > 0)
         {
             Subscription current = null;
             foreach (Subscription sub in tres.MemberData.Subscriptions)
             {
                 if (current == null)
                 {
                     current = sub;
                 }
                 else if ((sub.StatusFlag == "P" || sub.StatusFlag == "O") && !sub.IsDonor)
                 {
                     try
                     {
                         if (DateTime.Parse(sub.ExpireDate).CompareTo(DateTime.Parse(current.ExpireDate)) > 0)
                         {
                             current = sub;
                         }
                     }
                     catch { }
                 }
             }
             //update netmembership, with latest from sfg
             tbl_NetMembership currentmembership = tbl_NetMembership.GetCurrentNetMembership(customer.cusID);
             if (currentmembership == null) { currentmembership = new tbl_NetMembership(); }
             currentmembership.cusID = customer.cusID;
             currentmembership.mtyCode = HarperLINQ.SFG_ProdCode.GetFromExtCode(current.PublicationCode).IntCode;
             currentmembership.nmbDateCreated = DateTime.Now;
             currentmembership.nmbDateEnd = DateTime.Parse(current.ExpireDate);
             currentmembership.nmbDateStart = DateTime.Parse(current.DateEntered);
             currentmembership.Save();
             return true;
         }
     }
     return false;
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (CustomerID == "10001636220")//the check on customer id (mcoupland) was put in so Agatha could step through the process and style the pages
            {
                Success();
            }
            else
            {
                tbl_Customer existing = new tbl_Customer(txtUserName.Text, true);
                if (existing.cusID > 0)
                {
                    throw new Exception("Username in use");
                }
                existing = new tbl_Customer(txtEmail.Text, false);
                if (existing.cusID > 0)
                {
                    throw new Exception("Email in use");
                }
                long memberid = 0;
                if (long.TryParse(CustomerID, out memberid))
                {
                    existing = new tbl_Customer(memberid, true);
                    if (existing.cusID > 0)
                    {
                        throw new Exception("Member Number in use");
                    }
                }
                else
                {
                    throw new Exception("Invalid Member Number");
                }

                if (CreateNewUser())
                {
                    Success();
                }
                else
                {
                    throw new Exception("Error saving user data");
                }
            }
        }
        catch(Exception ex)
        {
            SetError(ex);
        }
    }
Beispiel #23
0
    protected void btnSumbit_click(object sender, EventArgs e)
    {
        try
        {
            #region Unable to decode referral id, try finding original referral based on email address
            if (badReferralId)
            {
                try
                {
                    Referral badRef = new Referral(email_address.Text);
                    if (badRef.id > 0)
                    {
                        referralid = badRef.id;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                catch (Exception ex)
                {
                    logService.LogAppEvent("", @"HarperNET", "Referral", "Unable to link email to referral id (id could not be decoded and email not on file). Using default referrer. Referral id in url: " + Request["ReferralId"] + ", email address entered: " + email_address.Text, ex.Message, ex.StackTrace, "", "Page_Load");
                    
                    Referral defaultReferral = new Referral();
                    defaultReferral.keycode = "POTRIAL";
                    defaultReferral.pubcode = "PO";
                    ReferralOffer offer = new ReferralOffer(defaultReferral.keycode, defaultReferral.pubcode);
                    
                    defaultReferral.ccmember = false;
                    defaultReferral.datecreated = DateTime.Now;
                    defaultReferral.dateexpires = defaultReferral.datecreated.AddMonths(offer.offerexpiresmonths);
                    defaultReferral.friendemail = email_address.Text;
                    defaultReferral.friendname = first_name.Text + " " + last_name.Text;

                    HarperLINQ.tbl_Customer defaultReferrer = new tbl_Customer(ConfigurationManager.AppSettings["default_referrer_username"], true);
                    defaultReferral.memberid = defaultReferrer.cusID;
                    defaultReferral.subscriptionlength = offer.triallengthinmonths;

                    defaultReferral.Save();
                    referralid = defaultReferral.id;
                }
            }
            #endregion

            HarperMembershipService.BaseResponse response = new HarperMembershipService.BaseResponse();
            HarperMembershipService.MembershipService webservice = new HarperMembershipService.MembershipService();

            #region Get selected region
            country = ddlCountries.SelectedValue;
            ISO3166 iso = new ISO3166(country, IdentifierType.Country_Code_Alpha2);
            string sfgcountrycode = iso.SFGCode;

            if (txtRegion.Text != "" && txtRegion.Text != null)
            {
                region = txtRegion.Text;
            }
            else if (txtRegionNotListed.Text != "" && txtRegionNotListed.Text != null)
            {
                region = txtRegionNotListed.Text;
            }
            else
            {
                region = ddlRegion.SelectedValue;
            }
            #endregion

            string erefid = Cryptography.EncryptData(referralid.ToString());
            string epwd = Cryptography.EncryptData(txtPassword.Text);

            #region Redeem the referral
            response = webservice.RedeemReferral(erefid, first_name.Text, last_name.Text, email_address.Text,
                sfgcountrycode, address_line_1.Text, address_line_2.Text, city.Text, region, postal.Text, true, 
                txtUserName.Text, epwd);
            #endregion

            #region Check for errors
            if (response == null)
            {
                throw new Exception(string.Format("Error redeeming referral id {0}, response from SFG was null.", referralid));
            }
            if (response.Messages != null && response.Messages.Count() > 0)
            {
                throw new Exception(response.Messages[0].AhMessage);
            }
            #endregion

            Response.Redirect("~/Referral/RedemptionConfirmation.aspx", false);
        }
        catch (Exception ex)
        {
            logService.LogAppEvent("", @"HarperNET", "Referral", "Error in btnSumbit_click", ex.Message, ex.StackTrace, "", "btnSubmit_click");
            LiteralControl err = new LiteralControl();
            err.Text = "<p class=\"error-message\">An error has occurred.  Please contact the membership department at <a href=\"mailto:[email protected]\">[email protected]</a></p>";
            lblErrorMessage.Controls.Add(err);
            lblErrorMessage.Visible = true;
        }
    }
Beispiel #24
0
    protected void SubmitClicked(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(email.Text))
        {
            SetError(new Exception("Email address is required."));
            pnlForm.Visible = true;
        }
        else
        {
            try
            {
                HarperSecureService.UpdatePasswordResponse updateResponse = new HarperSecureService.UpdatePasswordResponse();
                HarperLINQ.tbl_Customer user = new HarperLINQ.tbl_Customer(email.Text, false);
                if (user == null)
                {
                    SetError(new Exception("Unable to find a member with this address."));
                    lblMessage.Text = "Unable to find a member with this email address.";
                    pnlForm.Visible = true;
                }
                else
                {
                    if (string.IsNullOrEmpty(user.cusPassword))
                    {
                        SetError(new Exception("Error retrieving password - no password or blank password on file."));
                        lblMessage.Text = string.Format("{0}</br>{1}</br>", new object[] { Resources.GlobalStrings.Apology, Resources.GlobalStrings.ContactUs });
                        pnlForm.Visible = true;
                    }
                    else
                    {
                        string pwd = Cryptography.Decrypt256FromHEX(user.cusPassword);
                        if (!string.IsNullOrEmpty(user.cusUserName) &&
                            !string.IsNullOrEmpty(pwd) &&
                            !string.IsNullOrEmpty(email.Text))
                        {
                            SupportClasses.Mailer Emailer = new SupportClasses.Mailer();
                            Emailer.SendEmail(ConfigurationManager.AppSettings["mailserviceuser"],
                                              ConfigurationManager.AppSettings["mailservicepwd"],
                                              "Andrew Harper Password Reminder",
                                              ConfigurationManager.AppSettings["MembershipEmailFrom"].ToString(),
                                              user.cusEmail,
                                              string.Empty, string.Empty,
                                              getEmailBody(user.cusUserName, pwd), true,
                                              ConfigurationManager.AppSettings["EmailServer"]);

                            lblConfirmation.Visible = true;
                            pnlForm.Visible         = false;
                            lblMessage.Visible      = false;
                            string s = "<p>As requested, a reminder of your username and password has been sent to " + user.cusEmail + ".  Please retrieve your credentials, and use them to log in to our website <a href=\"http://www.andrewharper.com/login\" target=\"_top\">here</a>.</p><p>As a reminder, all username and passwords are case-sensitive.</p><p>If you do not receive the email shortly, please check your spam or junk email folder.  If you continue to experience difficulties, please contact Membership at [email protected] or call (866) 831-4314 from the U.S or +1 (512) 904-7342 internationally.</p>";
                            lblConfirmation.Text    = s;// string.Format("A reminder has been sent to {0}. If you do not receive the email within thirty minutes please check your spam or junk email folder.", email.Text);
                            lblConfirmation.Visible = true;

                            WriteLog(string.Format("Password for {0} was sent to {1}", new object[] { user.cusUserName, user.cusEmail }));
                        }
                        else
                        {
                            SetError(new Exception("Unable to send password reminder email."));
                            lblMessage.Text = "Unable to send password reminder email.";
                            pnlForm.Visible = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SetError(new Exception("Unable to send password reminder email, email address may be duplicate."));
                lblMessage.Text = "Unable to send password reminder email, email address may be duplicate.";
                pnlForm.Visible = true;
                WriteLog(ex);
            }
        }
    }