Manually adding order from admin needs "Create User&quo
Manually adding order from admin needs "Create User&quo
When using the Add Order button to create a new customer order from the Admin side, the user record is not created so order history cannot be maintained for the customer.
A "Create User record" checkbox with a password field would be immensely helpful. Right now I have to make the user record first, then create the order and assign the order to the user before saving the order.
A "Create User record" checkbox with a password field would be immensely helpful. Right now I have to make the user record first, then create the order and assign the order to the user before saving the order.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
edit Admin/Orders/Default.aspx
and find
and put this line
below it. Now add a new row with the following code just below the current row in which you placed the checkbox.
Now edit the Admin/Orders/Default.ascx.cs and following functions
and now modify the
protected void PlaceOrderButton_Click(object sender, EventArgs e)
to look like
and find
Code: Select all
<asp:Button ID="PlaceOrderButton" runat="server" Text="New Order" OnClick="PlaceOrderButton_Click" CausesValidation="true" />
Code: Select all
<asp:CheckBox ID="CreateUser" runat="server" Text="Create User" OnCheckedChanged="CreateUser_CheckedChanged"
AutoPostBack="True" />
Code: Select all
<tr>
<td colspan="6" style="width: 100%;">
<asp:Panel ID="CreateUserPanel" runat="server" Visible="false">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email" Text="Email:"
ToolTip="Email address of the user to add."></asp:Label>
<asp:TextBox ID="Email" runat="server" Columns="30"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequiredFieldValidator" runat="server" ControlToValidate="Email"
Text="*" ErrorMessage="Valid Email Required" />
<asp:RegularExpressionValidator ID="EmailValidator" runat="server" Display="Static"
ControlToValidate="Email" ValidationExpression="\S+@\S+\.\S+" ErrorMessage="The email address is not properly formatted."
Text="*"></asp:RegularExpressionValidator>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" Text="Password:"
ToolTip="New password for the user to add."></asp:Label>
<asp:TextBox ID="Password" runat="server" TextMode="Password" Columns="20"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequiredFieldValidator" runat="server" ControlToValidate="Password"
Text="*" ErrorMessage="Password Required" />
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="Password"
ValidationGroup="AddUser" OnServerValidate="UserValidation" Text="*" ErrorMessage="Password does not match the Password Policy."></asp:CustomValidator>
<asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword"
Text="Retype:" ToolTip="Retype the new password of the user to add."></asp:Label>
<asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password" Columns="20"></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmRequiredFieldValidator" runat="server" ControlToValidate="ConfirmPassword"
Text="*" ErrorMessage="Password Required" />
<asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
ControlToValidate="ConfirmPassword" Display="Static" ErrorMessage="You did not retype the password correctly."
Text="*" ValidationGroup="AddUser"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="validation" align="center">
<asp:Label ID="ErrorMessage" runat="server" SkinID="ErrorCondition" EnableViewState="false"
Visible="false"></asp:Label>
<asp:Label ID="AddedMessage" runat="server" SkinID="GoodCondition" EnableViewState="false"
Visible="false"></asp:Label>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="AddUser" />
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
Code: Select all
protected void UserValidation(object source, ServerValidateEventArgs args)
{
int groupId = 0;
CommerceBuilder.Users.Group group = GroupDataSource.Load(groupId);
PasswordPolicy policy;
string password = args.Value.ToString();
args.IsValid = true;
CustomValidator1.ErrorMessage = "";
policy = new CustomerPasswordPolicy();
if (password.Length < policy.MinLength)
{
AddPwdValidationError("Password length must be at least " + policy.MinLength.ToString() + " characters.");
args.IsValid = false;
}
if ((policy.RequireUpper) && (!Regex.IsMatch(password, "[A-Z]")))
{
AddPwdValidationError("At least one character should be in upper case. ");
args.IsValid = false;
}
if ((policy.RequireLower) && (!Regex.IsMatch(password, "[a-z]")))
{
AddPwdValidationError("At least one character should be in lower case. ");
args.IsValid = false;
}
if ((policy.RequireNumber) && (!Regex.IsMatch(password, "[0-9]")))
{
AddPwdValidationError("At least one digit is required in the password. ");
args.IsValid = false;
}
if ((policy.RequireSymbol) && (!Regex.IsMatch(password, "[^0-9a-zA-Z]")))
{
AddPwdValidationError("At least one symbol is required in the password. ");
args.IsValid = false;
}
if ((policy.RequireNonAlpha) && (!Regex.IsMatch(password, "[^a-zA-Z]")))
{
AddPwdValidationError("At least one non-alphabet character is required in password. ");
args.IsValid = false;
}
}
private void AddPwdValidationError(string message)
{
if (CustomValidator1.ErrorMessage.Length > 0)
{
CustomValidator1.ErrorMessage = CustomValidator1.ErrorMessage + "<li> " + message + "</li>";
}
else
{
CustomValidator1.ErrorMessage = message;
}
}
protected int CreateNewUser()
{
int userId = 0;
MembershipCreateStatus status;
User newUser = UserDataSource.CreateUser(Email.Text, Password.Text, string.Empty, string.Empty, true, 0, out status);
if (status == MembershipCreateStatus.Success)
{
// GET GROUP FOR NEW USER
int groupId = 0;
CommerceBuilder.Users.Group group = GroupDataSource.Load(groupId);
if (group != null) newUser.UserGroups.Add(new UserGroup(newUser.UserId, groupId));
// SAVE USER AND DISPLAY CONFIRMATION
newUser.Save();
userId = newUser.UserId;
}
else
{
switch (status)
{
case MembershipCreateStatus.DuplicateEmail:
case MembershipCreateStatus.DuplicateUserName:
ErrorMessage.Text = "The email address is already registered.";
ErrorMessage.Visible = true;
break;
case MembershipCreateStatus.InvalidEmail:
case MembershipCreateStatus.InvalidUserName:
ErrorMessage.Text = "The email address provided is invalid.";
ErrorMessage.Visible = true;
break;
case MembershipCreateStatus.InvalidPassword:
ErrorMessage.Text = "The password provided is invalid.";
ErrorMessage.Visible = true;
break;
default:
ErrorMessage.Text = "Unexpected error: " + status.ToString();
ErrorMessage.Visible = true;
break;
}
}
return userId;
}
protected void CreateUser_CheckedChanged(object sender, EventArgs e)
{
CreateUserPanel.Visible = CreateUser.Checked;
}
protected void PlaceOrderButton_Click(object sender, EventArgs e)
to look like
Code: Select all
protected void PlaceOrderButton_Click(object sender, EventArgs e)
{
Session.Remove("PlaceOrderUserId");
if (CreateUser.Checked)
{
int userId = CreateNewUser();
if (userId > 0)
{
Response.Redirect(String.Format("PlaceOrder1.aspx?UserId={0}", userId));
}
else
return;
}
else
Response.Redirect("PlaceOrder1.aspx");
}
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Manually adding order from admin needs "Create User&quo
Should there be a change in this code for RC3? I'm getting the following error when I try to implement it:
Line 616: {
Line 617: int groupId = 0;
Line 618: CommerceBuilder.Users.Group group = GroupDataSource.Load(groupId);
Line 619:
Line 620: PasswordPolicy policy;
I've tried twice, but I could still be doing something wrong.
Line 616: {
Line 617: int groupId = 0;
Line 618: CommerceBuilder.Users.Group group = GroupDataSource.Load(groupId);
Line 619:
Line 620: PasswordPolicy policy;
I've tried twice, but I could still be doing something wrong.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
Re: Manually adding order from admin needs "Create User&quo
sorry i missed some information in the post.
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
Re: Manually adding order from admin needs "Create User&quo
This problem is because i forgot to include the name spaces
Edit the file Admin/Orders/Default.aspx.cs and in the top section of page where you will find the using statements add the following statements as well
Edit the file Admin/Orders/Default.aspx.cs and in the top section of page where you will find the using statements add the following statements as well
Code: Select all
using CommerceBuilder.Users;
using System.Text.RegularExpressions;
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Manually adding order from admin needs "Create User&quo
Thanks, that fixed it.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx