Inserting Value Into Database

  • Thread starter Thread starter Computergyrl
  • Start date Start date
C

Computergyrl

Guest
Hello,

I have a customizable solution that I need a little help with. On my CreateAccount page I allow my users to list under four categories: Peach, Pear, Orange, and Apple. I want to set my roleid for Orange to 3 automatically when the person creates their account. I know I have to use the btn_register_Click event but I am a little confused from there.

Here are my tables that are involved.

[The roldid value I want to use it 3. The category id value is 55]

Table 1 ((categories) with categoryid, categoryname, and roleid.

Table 2 (user_roles) with roleid, name

Here are the pages involved.

under creataaccount.aspx

<div class="item
<div class="field_item_left
<%= Resources.vsk.accounttype%>:

<div class="field_item_right
<asp:DropDownList ID="drp_accounttype" AppendDataBoundItems="true" runat="server" BackColor="Aqua
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" SetFocusOnError="true"
Display="Dynamic" ValidationGroup="val_registration" ToolTip="required." ErrorMessage="required."
ControlToValidate="drp_accounttype </asp:RequiredFieldValidator>



under createaccount.aspx.vb under button click event

Dim userrole_id As Integer = Site_Settings.Default_UserRoleID
assign user default role at time of register
encrypt password
int BCRYPT_WORK_FACTOR = 10;
Dim encrypted_password As String = BCrypt.Net.BCrypt.HashPassword(Password.Text)
members.Add(Integer.Parse(drp_accounttype.SelectedValue.ToString()), UserName.Text, encrypted_password, Email.Text, drp_country.SelectedValue.ToString(), isenabled, _
gender, birth_day, val_key, type, credits, remained_video, _
remained_audio, remained_gallery, remained_photos, remained_blogs, space_video, space_audio, _
space_photos, userrole_id)


under createaccount.aspx.vb page load event

load parent / child categories
Dim category_type As Integer = 2
represent member channels
CategoriesBLL.BindCategories(drp_accounttype, 0, category_type, " " & Resources.vsk.selectcategory & " ", " ", True)
Load Days / Months / Years
Load_Days()

Load_Year()


under CategoriesBLL

#Region "CategorySection"
Private Shared Indicator As String = ""
set child level indicator start with empty "", "-", "--", "---", etc
Public Shared Sub BindCategories(cat As ListControl, ParentId As Integer, type As Integer, defaulttxt As String, defaultvalue As String, iscategoryid As Boolean)
cat.Items.Clear()
Dim _list As New ListItem()
_list.Text = " " & Resources.vsk.selectcategory & " ";
_list.Text = defaulttxt
_list.Value = " ";
_list.Value = defaultvalue
cat.Items.Add(_list)
Recursion Starts //
Process_Category_Items(cat, 0, type, iscategoryid)
End Sub


under sitesettings class


Public Shared ReadOnly Property Default_UserRoleID() As Integer
Get
Return Convert.ToInt32(ConfigurationBLL.Return_Value(193))
End Get
End Property


under ConfigurationBLL

Public Class ConfigurationBLL
Supported VSK 5.7 and later

Public Sub New()
End Sub

Public Shared Sub Update_Value(id As Integer, value As String)


SqlHelper.ExecuteNonQuery(Config.ConnectionString, CommandType.Text, "UPDATE configurations set value=@value where id=" & id, New SqlParameter("@value", value))
Refresh Application Stat Value
HttpContext.Current.Application["config_" & id] = value;
Dim cache_key As String = "config_" & id
HttpContext.Current.Cache(cache_key) = value
End Sub

Public Shared Function Return_Value(id As Integer) As String
Implement Cache Approach To Store Configuration Values
Dim cache_key As String = "config_" & id
If HttpContext.Current.Cache(cache_key) Is Nothing Then
HttpContext.Current.Cache.Add(cache_key, Return_NoCache_Value(id), Nothing, DateTime.Now.AddHours(6), TimeSpan.Zero, CacheItemPriority.High, _
Nothing)
End If

Return HttpContext.Current.Cache(cache_key.ToString()).ToString()
Implement Application State Approach To Store Configuration Values
if (HttpContext.Current.Application["config_" & id] == null)
HttpContext.Current.Application["config_" & id]= SqlHelper.ExecuteScalar(Config.ConnectionString, CommandType.Text, "SELECT value from configurations where id=" & id & "").ToString();

return HttpContext.Current.Application["config_" & id].ToString();
End Function

Public Shared Function Return_NoCache_Value(id As Integer) As String
Return SqlHelper.ExecuteScalar(Config.ConnectionString, CommandType.Text, "SELECT value from configurations where id=" & id & "").ToString()
End Function
End Class


Please Help!

Sincerely,

Computergyrl

Continue reading...
 
Back
Top