Beispiel #1
0
    /// <summary>
    /// Submit Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ZNode.Libraries.Admin.AccountAdmin _UserAccountAdmin = new ZNode.Libraries.Admin.AccountAdmin();
        ZNode.Libraries.DataAccess.Entities.Account _UserAccount = new Account();

        if (AccountID > 0)
        {
            _UserAccount = _UserAccountAdmin.GetByAccountID(AccountID);
        }

        if (AccountID == 0)
        {
            _UserAccount.CreateDte = System.DateTime.Now;
        }

        if (lstReferral.SelectedIndex != -1)
        {
            _UserAccount.ReferralCommissionTypeID = Convert.ToInt32(lstReferral.SelectedValue);
        }
        if (Discount.Text != "")
        {
            _UserAccount.ReferralCommission = Convert.ToDecimal(Discount.Text);
            discountAmount = Convert.ToDecimal(Discount.Text);
        }
        _UserAccount.TaxID = txtTaxId.Text;

        bool Check = false;

        if(AccountID >0)
        {
            //set update date
            _UserAccount.UpdateDte = System.DateTime.Now;

            Check = _UserAccountAdmin.Update(_UserAccount);
        }
        else
        {
            Check = _UserAccountAdmin.Insert(_UserAccount);

        }
        //Check Boolean Value
        if (Check)
        {
            Response.Redirect("~/admin/secure/sales/Affiliates/View.aspx");
        }
        else
        {
            lblErrorMsg.Text = "";
        }
    }
Beispiel #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ZNode.Libraries.Admin.AccountAdmin _UserAccountAdmin = new ZNode.Libraries.Admin.AccountAdmin();
        ZNode.Libraries.DataAccess.Entities.Account _UserAccount = new Account();

        //Set values
        _UserAccount.BillingFirstName = txtBillingFirstName.Text;
        _UserAccount.BillingLastName = txtBillingLastName.Text;
        _UserAccount.BillingPhoneNumber = txtBillingPhoneNumber.Text;
        _UserAccount.BillingEmailID = txtBillingEmail.Text;

        //Set to empty values to other billing address properties
        _UserAccount.BillingCompanyName = "";
        _UserAccount.BillingStreet = "";
        _UserAccount.BillingStreet1 = "";
        _UserAccount.BillingCity = "";
        _UserAccount.BillingStateCode = "";
        _UserAccount.BillingPostalCode = "";
        _UserAccount.BillingCountryCode = "";

        //Set to empty values to other shipping address properties
        _UserAccount.ShipFirstName = "";
        _UserAccount.ShipLastName = "";
        _UserAccount.ShipCompanyName = "";
        _UserAccount.ShipStreet = "";
        _UserAccount.ShipStreet1 = "";
        _UserAccount.ShipPhoneNumber = "";
        _UserAccount.ShipPostalCode = "";
        _UserAccount.ShipStateCode = "";
        _UserAccount.ShipEmailID = "";
        _UserAccount.ShipCity = "";
        _UserAccount.ShipCountryCode = "";

        if (ListProfileType.SelectedIndex != -1)
        {
            _UserAccount.ProfileID = int.Parse(ListProfileType.SelectedValue);
        }

        //pre-set properties
        _UserAccount.UserID = null;
        _UserAccount.PortalID = int.Parse(ZNodeConfigManager.SiteConfig.PortalID.ToString());
        _UserAccount.ActiveInd = true;
        _UserAccount.ParentAccountID = null;
        _UserAccount.AccountTypeID = 0;
        _UserAccount.CreateDte = System.DateTime.Now;
        _UserAccount.UpdateDte = System.DateTime.Now;
        _UserAccount.CreateUser = HttpContext.Current.User.Identity.Name;

        //Add New Contact
        bool Check = _UserAccountAdmin.Add(_UserAccount);

        //Check Boolean Value
        if (Check)
        {
            Response.Redirect("~/admin/secure/sales/customers/list.aspx");
        }
        else
        {
            ErrorMessage.Text = "Could not create new contact. Please contact customer support.";
            return;
        }
    }
Beispiel #3
0
    /// <summary>
    /// Submit Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ZNode.Libraries.Admin.AccountAdmin _UserAccountAdmin = new ZNode.Libraries.Admin.AccountAdmin();
        ZNode.Libraries.DataAccess.Entities.Account _UserAccount = new Account();

        if (AccountID > 0)
        {

              _UserAccount = _UserAccountAdmin.GetByAccountID(AccountID);
        }

        if (AccountID == 0)
        {
            _UserAccount.CreateDte = System.DateTime.Now;
        }

        //Set user's address

        _UserAccount.BillingFirstName = txtBillingFirstName.Text;
        _UserAccount.BillingLastName = txtBillingLastName.Text;
        _UserAccount.BillingCompanyName = txtBillingCompanyName.Text;
        _UserAccount.BillingStreet = txtBillingStreet1.Text;
        _UserAccount.BillingStreet1 = txtBillingStreet2.Text;
        _UserAccount.BillingCity = txtBillingCity.Text;
        _UserAccount.BillingStateCode = txtBillingState.Text;
        _UserAccount.BillingPostalCode = txtBillingPostalCode.Text;
        _UserAccount.BillingPhoneNumber = txtBillingPhoneNumber.Text;
        _UserAccount.BillingEmailID = txtBillingEmail.Text;
        _UserAccount.EmailOptIn = chkOptIn.Checked;

        if (lstBillingCountryCode.SelectedIndex != -1)
        {
            _UserAccount.BillingCountryCode = lstBillingCountryCode.SelectedValue;
        }

        // Get Shipping field values
        _UserAccount.ShipFirstName = txtShippingFirstName.Text;
        _UserAccount.ShipLastName = txtShippingLastName.Text;
        _UserAccount.ShipCompanyName = txtShippingCompanyName.Text;
        _UserAccount.ShipStreet = txtShippingStreet1.Text;
        _UserAccount.ShipStreet1 = txtShippingStreet2.Text;
        _UserAccount.ShipCity = txtShippingCity.Text;
        _UserAccount.ShipStateCode = txtShippingState.Text;
        _UserAccount.ShipPostalCode = txtShippingPostalCode.Text;

        if (lstShippingCountryCode.SelectedIndex != -1)
        {
            _UserAccount.ShipCountryCode = lstShippingCountryCode.SelectedValue;
        }

        _UserAccount.ShipPhoneNumber = txtShippingPhoneNumber.Text;
        _UserAccount.ShipEmailID = txtShippingEmail.Text;

        //Set Account Details
        _UserAccount.ExternalAccountNo = txtExternalAccNumber.Text.Trim();
        _UserAccount.Description = txtDescription.Text;
        _UserAccount.CompanyName = txtCompanyName.Text;
        _UserAccount.Website = txtWebSite.Text.Trim();
        _UserAccount.Source = txtSource.Text.Trim();

        // Referral Detail
        if (lstReferral.SelectedIndex != -1)
        {
            _UserAccount.ReferralCommissionTypeID = Convert.ToInt32(lstReferral.SelectedValue);
        }
        if (Discount.Text != "" && Convert.ToDecimal(Discount.Text)>0)
        {
            _UserAccount.ReferralCommission = Convert.ToDecimal(Discount.Text);
            discountAmount = Convert.ToDecimal(Discount.Text);
        }
        ToggleDiscountValidator();
        _UserAccount.TaxID = txtTaxId.Text;

        if (lstReferralStatus.SelectedValue == "I")
        {
            _UserAccount.ReferralStatus = "I";
        }
        else if (lstReferralStatus.SelectedValue == "A")
        {
            _UserAccount.ReferralStatus = "A";
        }
        else if (lstReferralStatus.SelectedValue == "N")
        {
            _UserAccount.ReferralStatus = "N";
        }
        else
        {
            _UserAccount.ReferralStatus = "";
        }

        if (ListProfileType.SelectedIndex != -1)
        {
            _UserAccount.ProfileID = int.Parse(ListProfileType.SelectedValue);
        }

        _UserAccount.AccountProfileCode = DBNull.Value.ToString();
        _UserAccount.UpdateUser = System.Web.HttpContext.Current.User.Identity.Name;
        _UserAccount.UpdateDte = System.DateTime.Now;

        _UserAccount.UserID = _UserAccount.UserID;
        _UserAccount.AccountID = AccountID;
        _UserAccount.PortalID = int.Parse(ZNodeConfigManager.SiteConfig.PortalID.ToString());

        //Custom Information Section
        _UserAccount.Custom1 = txtCustom1.Text.Trim();
        _UserAccount.Custom2 = txtCustom2.Text.Trim();
        _UserAccount.Custom3 = txtCustom3.Text.Trim();

        try
        {
            if (_UserAccount.UserID.HasValue)
            {

                //get the User associated with the specified Unique identifier
                MembershipUser user = Membership.Providers["ZNodeAdminMembershipProvider"].GetUser(_UserAccount.UserID.Value, false);

                user.Email = txtBillingEmail.Text.Trim();
                //Update the database with the Email Id for the specified user
                Membership.UpdateUser(user);

                if (Password.Text.Length > 0)
                {
                    string passwordAnswer = Answer.Text.Trim();

                    if (passwordAnswer.Length == 0)
                    {
                        //Display error message
                        lblAnswerErrorMsg.Text = " * Enter security answer";
                        lblErrorMsg.Text = " * Enter security answer";
                        return;
                    }

                    //Update new password
                    user.ChangePassword(user.ResetPassword(), Password.Text.Trim());

                    //Log password for further debugging
                    ZNodeUserAccount.LogPassword((Guid)user.ProviderUserKey, Password.Text.Trim());

                    //change password question and answer
                    user.ChangePasswordQuestionAndAnswer(Password.Text.Trim(), ddlSecretQuestions.SelectedItem.Text, Answer.Text.Trim());
                }

                //retrieve roles associated with this user
                string[] roles = Roles.GetRolesForUser(user.UserName);

                //Loop through the roles
                foreach (string Role in roles)
                {
                    //Unassign this user from that role
                    Roles.RemoveUserFromRole(user.UserName, Role);
                }

                //Loop thorugh the roles checkbox list
                foreach (ListItem li in RolesCheckboxList.Items)
                {
                    if (li.Selected)
                    {
                        //Associate the User with the selected role
                        Roles.AddUserToRole(user.UserName, li.Text);
                    }
                }
            }
            else
            {
                if (UserID.Text.Trim().Length > 0)
                {
                    string errorMessage = "";

                    //Check password field
                    if (Password.Text.Trim().Length == 0)
                    {
                        errorMessage = " * Enter password <br />";
                        lblPwdErrorMsg.Text = " * Enter password";
                    }

                    //check security answer field
                    if (Answer.Text.Trim().Length == 0)
                    {
                        errorMessage += " * Enter security answer";
                        lblAnswerErrorMsg.Text = " * Enter security answer";
                    }

                    //Show error message
                    if (errorMessage.Length > 0)
                    {
                        lblErrorMsg.Text = errorMessage;
                        return;
                    }

                    MembershipUser user = Membership.GetUser(UserID.Text.Trim());

                    if (user == null) //online account DOES NOT exist
                    {
                        ZNodeLogging log = new ZNodeLogging();
                        MembershipCreateStatus status = MembershipCreateStatus.ProviderError;
                        log.LogActivityTimerStart();
                        MembershipUser newUser = Membership.CreateUser(UserID.Text.Trim(), Password.Text.Trim(), txtBillingEmail.Text.Trim(), ddlSecretQuestions.SelectedItem.Text, Answer.Text.Trim(), true, out status);

                        if (status == MembershipCreateStatus.Success)
                        {
                            log.LogActivityTimerEnd((int)ZNodeLogging.ErrorNum.LoginCreateSuccess, UserID.Text.Trim());

                            //Log password for further debugging
                            ZNodeUserAccount.LogPassword((Guid)newUser.ProviderUserKey, Password.Text.Trim());

                            //Update provider user key
                            _UserAccount.UserID = new Guid(newUser.ProviderUserKey.ToString());

                            //Associate this user with the selected role
                            foreach (ListItem li in RolesCheckboxList.Items)
                            {
                                if (li.Selected)
                                {
                                    //Associate the User with the selected role
                                    Roles.AddUserToRole(newUser.UserName, li.Text);
                                }
                            }
                        }
                        else
                        {
                            log.LogActivityTimerEnd((int)ZNodeLogging.ErrorNum.LoginCreateFailed, UserID.Text.Trim());
                            lblErrorMsg.Text = "Unable to create online account. Please try again.";
                            return;
                        }
                    }
                    else
                    {
                        lblErrorMsg.Text = "User Id already exists. Please use differnet user id.";
                        return;
                    }
                }
            }
        }
        catch (Exception exception)
        {
            lblErrorMsg.Text = exception.Message;
            return;
        }

        bool Check = false;

        if(AccountID >0)
        {
            //set update date
            _UserAccount.UpdateDte = System.DateTime.Now;

            Check = _UserAccountAdmin.Update(_UserAccount);
        }
        else
        {
            Check = _UserAccountAdmin.Insert(_UserAccount);

        }
        //Check Boolean Value
        if (Check)
        {
            Response.Redirect("~/admin/secure/sales/customers/list.aspx");
        }
        else
        {
            lblErrorMsg.Text = "";
        }
    }
Beispiel #4
0
    /// <summary>
    /// Bind Account Details
    /// </summary>
    private void BindData()
    {
        ZNode.Libraries.Admin.AccountAdmin _UserAccountAdmin = new ZNode.Libraries.Admin.AccountAdmin();
        ZNode.Libraries.DataAccess.Entities.Account _UserAccount = _UserAccountAdmin.GetByAccountID(AccountID);

        if (_UserAccount != null)
        {
            if (_UserAccount.ReferralCommissionTypeID != null)
            {
                lstReferral.SelectedValue = Convert.ToString(_UserAccount.ReferralCommissionTypeID);
            }
            if(_UserAccount.ReferralCommission != null)
            {
                Discount.Text = _UserAccount.ReferralCommission.Value.ToString("N");
                discountAmount = Convert.ToDecimal(_UserAccount.ReferralCommission);
            }
            ToggleDiscountValidator();
            txtTaxId.Text = _UserAccount.TaxID;
            txtAccountID.Text = _UserAccount.AccountID.ToString();
            txtFisrtName.Text = _UserAccount.BillingFirstName;
            txtLastName.Text = _UserAccount.BillingLastName;
            txtCompanyName.Text = _UserAccount.CompanyName;
            txtEmailID.Text = _UserAccount.BillingEmailID;
            txtPhoneNumber.Text = _UserAccount.BillingPhoneNumber;
        }
    }
Beispiel #5
0
    /// <summary>
    /// Bind Account Details
    /// </summary>
    private void BindData()
    {
        ZNode.Libraries.Admin.AccountAdmin _UserAccountAdmin = new ZNode.Libraries.Admin.AccountAdmin();
        ZNode.Libraries.DataAccess.Entities.Account _UserAccount = _UserAccountAdmin.GetByAccountID(AccountID);//new Account();

        if (_UserAccount != null)
        {
            //General Information
            txtExternalAccNumber.Text = _UserAccount.ExternalAccountNo;
            txtCompanyName.Text = _UserAccount.CompanyName;
            if (ListProfileType.SelectedIndex != -1)
            {
                ListProfileType.SelectedValue = _UserAccount.ProfileID.ToString();
            }

            txtWebSite.Text = _UserAccount.Website;
            txtSource.Text = _UserAccount.Source;

            //Description
            txtDescription.Text = _UserAccount.Description;

            //Login Info
            if (_UserAccount.UserID.HasValue)
            {
                UserID.Enabled = false;

                MembershipUser _user = Membership.GetUser(_UserAccount.UserID.Value);
                UserID.Text = _user.UserName;
                ddlSecretQuestions.Text = _user.PasswordQuestion;

                string roleList = "";
                //Get roles for this User account
                string[] roles = Roles.GetRolesForUser(_user.UserName);

                foreach (string Role in roles)
                {
                    roleList += Role + "<br>";
                    //Loop through the roles list
                    foreach (ListItem li in RolesCheckboxList.Items)
                    {
                        if (li.Text == Role)
                        {
                            li.Selected = true;
                        }

                        //Admin User should not remove the Admin role from their own account.
                        if (HttpContext.Current.User.Identity.Name.Equals(_user.UserName.ToLower()) && li.Text == "ADMIN")
                        {
                            li.Enabled = false;
                        }
                    }
                }

                string rolename = roleList;

                //Hide the Submit button if a NonAdmin user has entered this page
                if (!Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, "ADMIN"))
                {
                    if (Roles.IsUserInRole(_user.UserName, "ADMIN"))
                    {
                        btnSubmitTop.Visible = false;
                        Submit.Visible = false;
                    }
                    else if (Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, "CUSTOMER SERVICE REP"))
                    {
                        if (rolename == Convert.ToString("USER<br>") || rolename == Convert.ToString(""))
                        {
                            btnSubmitTop.Visible = true;
                            Submit.Visible = true;
                        }
                        else
                        {
                            btnSubmitTop.Visible = false;
                            Submit.Visible = false;
                        }
                    }
                }
            }

            //Billing Address

            //set field values
            txtBillingFirstName.Text = _UserAccount.BillingFirstName;
            txtBillingLastName.Text = _UserAccount.BillingLastName;
            txtBillingCompanyName.Text = _UserAccount.BillingCompanyName;
            txtBillingStreet1.Text = _UserAccount.BillingStreet;
            txtBillingStreet2.Text = _UserAccount.BillingStreet1;
            txtBillingCity.Text = _UserAccount.BillingCity;
            txtBillingState.Text = _UserAccount.BillingStateCode;
            txtBillingPostalCode.Text = _UserAccount.BillingPostalCode;

            if (_UserAccount.BillingCountryCode.Length > 0)
            {
                lstBillingCountryCode.SelectedValue = _UserAccount.BillingCountryCode;
            }

            txtBillingPhoneNumber.Text = _UserAccount.BillingPhoneNumber;
            txtBillingEmail.Text = _UserAccount.BillingEmailID;
            chkOptIn.Checked = _UserAccount.EmailOptIn;

            //Shipping Address

            //set field values
            txtShippingFirstName.Text = _UserAccount.ShipFirstName;
            txtShippingLastName.Text = _UserAccount.ShipLastName;
            txtShippingCompanyName.Text = _UserAccount.ShipCompanyName;
            txtShippingStreet1.Text = _UserAccount.ShipStreet;
            txtShippingStreet2.Text = _UserAccount.ShipStreet1;
            txtShippingCity.Text = _UserAccount.ShipCity;
            txtShippingState.Text = _UserAccount.ShipStateCode;
            txtShippingPostalCode.Text = _UserAccount.ShipPostalCode;

            //Referral Details
            if (_UserAccount.ReferralCommissionTypeID != null)
            {
                lstReferral.SelectedValue = _UserAccount.ReferralCommissionTypeID.ToString();
            }
            if (_UserAccount.ReferralCommission != null)
            {
                Discount.Text = _UserAccount.ReferralCommission.Value.ToString("N");
                discountAmount = Convert.ToDecimal(_UserAccount.ReferralCommission);
            }
            if (_UserAccount.ReferralStatus != null)
                lstReferralStatus.SelectedValue = _UserAccount.ReferralStatus;
            else
                lstReferralStatus.SelectedValue = _UserAccount.ReferralStatus;

            if (_UserAccount.ReferralStatus == "A")
            {
                string affiliateLink = "http://" + ZNodeConfigManager.SiteConfig.DomainName + "/default.aspx?affiliate_id=" + _UserAccount.AccountID;
                hlAffiliateLink.Text = affiliateLink;
                hlAffiliateLink.NavigateUrl = affiliateLink;
            }
            else
            {
                hlAffiliateLink.Text = "NA";
            }
            ToggleDiscountValidator();
            txtTaxId.Text = _UserAccount.TaxID;

            AccountHelper helperAccess = new AccountHelper();
            DataSet MyDataSet = helperAccess.GetCommisionAmount(ZNodeConfigManager.SiteConfig.PortalID, AccountID.ToString());

            lblAmountOwed.Text ="$" +  MyDataSet.Tables[0].Rows[0]["CommissionOwed"].ToString();

            if (_UserAccount.ShipCountryCode.Length > 0)
            {
                lstShippingCountryCode.SelectedValue = _UserAccount.ShipCountryCode;
            }

            txtShippingPhoneNumber.Text = _UserAccount.ShipPhoneNumber;
            txtShippingEmail.Text = _UserAccount.ShipEmailID;

            //Custom properties
            txtCustom1.Text = _UserAccount.Custom1;
            txtCustom2.Text = _UserAccount.Custom2;
            txtCustom3.Text = _UserAccount.Custom3;

        }
    }