Advertisement
Guest User

ZADNA

a guest
Apr 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.48 KB | None | 0 0
  1. Imports System.Data
  2. Imports System.Data.SqlClient
  3. Imports System.Configuration
  4. Public Class MasterPage
  5. Inherits System.Web.UI.MasterPage
  6.  
  7.  
  8. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  9. SearchBox.Attributes.Add("onkeypress", "return clickButton(event,'" + btnSearch.ClientID + "')")
  10.  
  11. If Not Me.IsPostBack Then
  12.  
  13. End If
  14. If Session("Login") Is Nothing And Session("Login1") Is Nothing Then
  15. Logout.Visible = False
  16. MyAcc.Visible = False
  17. SignUpKopche.Visible = True
  18. SignIn.Visible = True
  19. Else
  20. If Session("Login") IsNot Nothing Then
  21. If Session("Login").ToString().Equals("Logiran") Then
  22. Logout.Visible = True
  23. MyAcc.Visible = True
  24. NajavaObichenKorisnik.Visible = False
  25. SignUpKopche.Visible = False
  26. SignIn.Visible = False
  27. Else
  28. Logout.Visible = False
  29. MyAcc.Visible = False
  30. NajavaObichenKorisnik.Visible = True
  31. SignUpKopche.Visible = True
  32. SignIn.Visible = True
  33.  
  34. End If
  35. ElseIf Session("Login1") IsNot Nothing Then
  36.  
  37. If Session("Login1").ToString().Equals("Logiran") Then
  38. Logout.Visible = True
  39. MyAcc.Visible = True
  40. NajavaObichenKorisnik.Visible = False
  41. SignUpKopche.Visible = False
  42. SignIn.Visible = False
  43. Else
  44. Logout.Visible = False
  45. MyAcc.Visible = False
  46. NajavaObichenKorisnik.Visible = True
  47. SignUpKopche.Visible = True
  48. SignIn.Visible = True
  49.  
  50. End If
  51.  
  52. End If
  53. End If
  54.  
  55.  
  56. Dim strKonekcija As String = ConfigurationManager.ConnectionStrings("SyCMSConn").ConnectionString
  57. Using con As New SqlConnection(strKonekcija)
  58. Using cmd As New SqlCommand("select Ag_ID,Ag_Ime from AG")
  59. Using sda As New SqlDataAdapter()
  60. cmd.Connection = con
  61. sda.SelectCommand = cmd
  62. Using dt As New DataTable()
  63. sda.Fill(dt)
  64.  
  65. For Each c As DataRow In dt.Rows
  66. Pills.Controls.Add(New LiteralControl("<li runat='server'>"))
  67.  
  68. 'Dim s As New HtmlGenericControl("span")
  69. ' s.Attributes.Add("class", "glyphicon glyphicon-tag")
  70. ' myDiv.Controls.Add(s)
  71.  
  72.  
  73.  
  74. Dim l As New LinkButton()
  75. l.CommandName = c.Item(0)
  76. l.Text = c.Item(1)
  77. l.CssClass = "KatKlasa"
  78. l.Height = 35
  79. AddHandler l.Click, AddressOf l_Click
  80. Pills.Controls.Add(l)
  81.  
  82. Using con1 As New SqlConnection(strKonekcija)
  83. Using cmd1 As New SqlCommand("select distinct Apg_Ime,Apg_ID from APG,AG where Apg_Grupa =" + c.Item(0).ToString())
  84. Using sda1 As New SqlDataAdapter()
  85. cmd1.Connection = con1
  86. sda1.SelectCommand = cmd1
  87. Using dt1 As New DataTable()
  88. sda1.Fill(dt1)
  89. If dt1.Rows.Count > 0 Then
  90. Pills.Controls.Add(New LiteralControl("<div class='mega' style='line-height:20px;margin-top:-15px;'><aside class='container' style=' width:550px;'>"))
  91. End If
  92. For Each b As DataRow In dt1.Rows
  93. Pills.Controls.Add(New LiteralControl("<div class='col-lg-4 col-md-4 col-sm-4'><nobr><h2 style='cursor:pointer;text-decoration:none;'>"))
  94. Dim linkLevel1 As New HtmlAnchor
  95. linkLevel1.Name = b.Item(1)
  96. linkLevel1.InnerText = b.Item(0)
  97. linkLevel1.Style.Add("font-size", "18px")
  98. linkLevel1.Style.Add("text-decoration", "none")
  99.  
  100. AddHandler linkLevel1.ServerClick, AddressOf l1_Click
  101. Pills.Controls.Add(linkLevel1)
  102. Pills.Controls.Add(New LiteralControl("</h2></nobr>"))
  103.  
  104. Using con2 As New SqlConnection(strKonekcija)
  105. Using cmd2 As New SqlCommand("select distinct Appg_Ime,Appg_ID from APPG, APG where Appg_PodGrupa =" + b.Item(1).ToString())
  106. Using sda2 As New SqlDataAdapter()
  107. cmd2.Connection = con2
  108. sda2.SelectCommand = cmd2
  109. Using dt2 As New DataTable()
  110. sda2.Fill(dt2)
  111.  
  112. If dt2.Rows.Count > 0 Then
  113. Pills.Controls.Add(New LiteralControl("<ul class='list-group' style='list-style:none;'>"))
  114. End If
  115.  
  116. For Each a As DataRow In dt2.Rows
  117. Pills.Controls.Add(New LiteralControl("<li>"))
  118. Dim linkLevel2 As New HtmlAnchor
  119. linkLevel2.Name = a.Item(1)
  120. linkLevel2.InnerText = a.Item(0)
  121. AddHandler linkLevel2.ServerClick, AddressOf l1_Click
  122. Pills.Controls.Add(linkLevel2)
  123.  
  124. Pills.Controls.Add(New LiteralControl("</li>"))
  125. Next
  126.  
  127. If dt2.Rows.Count > 0 Then
  128. Pills.Controls.Add(New LiteralControl("</ul></div>"))
  129. End If
  130.  
  131. End Using
  132. End Using
  133. End Using
  134. End Using
  135.  
  136.  
  137.  
  138. Next
  139. If dt1.Rows.Count > 0 Then
  140. Pills.Controls.Add(New LiteralControl("</aside></div>"))
  141. End If
  142. End Using
  143. End Using
  144. End Using
  145. End Using
  146.  
  147.  
  148.  
  149. Pills.Controls.Add(New LiteralControl("</li>"))
  150.  
  151. l = Nothing
  152. Next
  153. End Using
  154. End Using
  155. End Using
  156. End Using
  157.  
  158.  
  159.  
  160. End Sub
  161. Protected Sub LogOutClick(sender As Object, e As EventArgs)
  162. Session("Login") = "Nelogiran"
  163.  
  164. Response.Redirect("Home.aspx", True)
  165.  
  166. End Sub
  167.  
  168.  
  169. Protected Sub BrzaNajavaClick(sender As Object, e As EventArgs)
  170. Dim strKonekcija As String = ConfigurationManager.ConnectionStrings("SyCMSConn").ConnectionString
  171. Using con As New SqlConnection(strKonekcija)
  172.  
  173. Using cmd As New SqlCommand("select Kom_Ime from Komintenti where Kom_WebPristap = 1 and Kom_WebSifra = '" + PassbrzaNajava.Value.ToString() + "' and Kom_WebIme = '" + UsernameBrzaNajava.Value.ToString() + "' ")
  174. Using sda As New SqlDataAdapter()
  175. cmd.Connection = con
  176. sda.SelectCommand = cmd
  177. Using dt As New DataTable()
  178. sda.Fill(dt)
  179. If dt.Rows.Count = 1 Then
  180. alert.Visible = False
  181. PassbrzaNajava.Value = " "
  182. UsernameBrzaNajava.Value = " "
  183. Session("Login") = "Logiran"
  184. Response.Redirect("Home.aspx", True)
  185.  
  186. Else
  187. PassbrzaNajava.Value = ""
  188. UsernameBrzaNajava.Value = ""
  189. alert.Visible = True
  190. End If
  191.  
  192. End Using
  193. End Using
  194. End Using
  195. End Using
  196.  
  197. End Sub
  198.  
  199. Protected Sub BrzaNajavaClick1(sender As Object, e As EventArgs)
  200. Dim strKonekcija As String = ConfigurationManager.ConnectionStrings("SyCMSConn").ConnectionString
  201. Using con As New SqlConnection(strKonekcija)
  202.  
  203. Using cmd As New SqlCommand("select Kor_ID from WebKorisnici where Kor_KorisnikSifra = '" + PassBrzaNajavaObichen.Value.ToString() + "' and Kor_KorisnikIme = '" + UsernameBrzaNajavaObichen.Value.ToString() + "' ")
  204. Using sda As New SqlDataAdapter()
  205. cmd.Connection = con
  206. sda.SelectCommand = cmd
  207. Using dt As New DataTable()
  208. sda.Fill(dt)
  209. If dt.Rows.Count = 1 Then
  210. alert1.Visible = False
  211. PassBrzaNajavaObichen.Value = " "
  212. UsernameBrzaNajavaObichen.Value = " "
  213. Session("Login") = "Logiran"
  214. Response.Redirect("Home.aspx", True)
  215.  
  216. Else
  217. PassBrzaNajavaObichen.Value = ""
  218. UsernameBrzaNajavaObichen.Value = ""
  219. alert1.Visible = True
  220. End If
  221.  
  222. End Using
  223. End Using
  224. End Using
  225. End Using
  226.  
  227. End Sub
  228.  
  229. Protected Sub MyAccClick(sender As Object, e As EventArgs)
  230. Server.Transfer("ProductsPerCategory.aspx", True)
  231. End Sub
  232. Protected Sub Link_Click(sender As Object, e As EventArgs)
  233. Server.Transfer("ProductsPerCategory.aspx", True)
  234. End Sub
  235. Protected Sub SignUp(sender As Object, e As EventArgs)
  236. Response.Redirect("SignUp.aspx", True)
  237. End Sub
  238. Protected Sub HomeClick(sender As Object, e As EventArgs)
  239. Response.Redirect("Home.aspx", True)
  240. End Sub
  241. Protected Sub SignUpClick(sender As Object, e As EventArgs)
  242. Response.Redirect("SignUp.aspx", True)
  243. End Sub
  244.  
  245. Protected Sub KosnickaClick(sender As Object, e As EventArgs)
  246. Response.Redirect("Shopping-Cart.aspx", True)
  247. End Sub
  248. Protected Sub ZaNasClick(sender As Object, e As EventArgs)
  249. Response.Redirect("ZaNas.aspx", True)
  250. End Sub
  251.  
  252. Protected Sub UslugiClick(sender As Object, e As EventArgs)
  253. Response.Redirect("Uslugi.aspx", True)
  254. End Sub
  255.  
  256. Protected Sub PrivatnostClick(sender As Object, e As EventArgs)
  257. Response.Redirect("Privatnost.aspx", True)
  258. End Sub
  259.  
  260. Protected Sub KontaktClick(sender As Object, e As EventArgs)
  261. Response.Redirect("Kontakt.aspx", True)
  262. End Sub
  263. Public Shared Function toHTML_Table(dt As DataTable) As String
  264. If dt.Rows.Count = 0 Then
  265. Return ""
  266. End If
  267. ' enter code here
  268. Dim builder As New StringBuilder()
  269.  
  270. For Each c As DataRow In dt.Rows
  271. builder.Append("<li class='ovaa' runat='server' id='")
  272. builder.Append(c.Item(0))
  273. builder.Append("'><asp:LinkButton runat='server' Text='Link' OnClick='Link_Click()' ID='2' CssClass='kopche'><span runat='server' class='glyphicon glyphicon-tag'></span>")
  274. builder.Append(c.Item(1))
  275. builder.Append("<span class='glyphicon glyphicon-menu-right' style='float:right;font-size:11px;'></span></a>")
  276. If c.Item(3) IsNot Nothing Then
  277. If c.Item(0).Equals(c.Item(3)) Then
  278. builder.Append(" <div class='mega'><aside style='margin-left:7px;'><h5 style='text-transformuppercase;'>")
  279. builder.Append(c.Item(2))
  280. builder.Append("</h5><ul class='list-group' style='list-style:none;'><li><a href='http://totoprayogo.com' target='_blank'>Sony</a></li><li><a href='http://totoprayogo.com' target='_blank'>Canon</a></li><li><a href='http://totoprayogo.com' target='_blank'>Kodak</a></li></ul></aside><div class='featured'><img alt='featured-cameras' src='http://cdn.mos.cms.futurecdn.net/c01d303202bc3da34fd86a913ca9cbb6-650-80.jpg'/></div><br clear='all'/></div></li>")
  281. Else
  282. builder.Append("</li>")
  283. End If
  284. Else
  285. builder.Append("</li>")
  286. End If
  287.  
  288. Next
  289.  
  290.  
  291. Return builder.ToString()
  292. End Function
  293.  
  294.  
  295.  
  296. Protected Sub l_Click(sender As Object, e As EventArgs)
  297.  
  298. Dim selektirano = sender.CommandName
  299. Session("Data") = selektirano
  300. Response.Redirect("ProductsPerCategory.aspx", True)
  301.  
  302. End Sub
  303. Protected Sub l1_Click(sender As Object, e As EventArgs)
  304.  
  305. Dim selektirano = sender.ID
  306. Session("Data") = selektirano
  307. Response.Redirect("ProductsPerCategory.aspx", True)
  308.  
  309. End Sub
  310. Protected Sub l_Click1(sender As Object, e As EventArgs)
  311.  
  312.  
  313. End Sub
  314.  
  315. Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
  316. Response.Redirect("SearchResults.aspx", True)
  317.  
  318.  
  319.  
  320.  
  321. End Sub
  322.  
  323. Protected Sub SearchBox_TextChanged(sender As Object, e As EventArgs)
  324. Session("klucenzbor") = SearchBox.Text.ToString()
  325. Dim strKonekcija As String = ConfigurationManager.ConnectionStrings("SyCMSConn").ConnectionString
  326.  
  327. If SearchBox.Text.Trim().Count >= 3 Then
  328.  
  329.  
  330. Dim searchzbor As String = "'%" + SearchBox.Text + "%'"
  331.  
  332. Using con As New SqlConnection(strKonekcija)
  333. Using cmd As New SqlCommand("Select top 20 Art_Ime as ime,Art_ID as id from Artikli where Art_Ime Like " + searchzbor + " Or Art_Proizvoditel Like " + searchzbor)
  334.  
  335.  
  336.  
  337. cmd.CommandType = CommandType.Text
  338. cmd.Connection = con
  339. con.Open()
  340.  
  341. 'If cmd.ExecuteReader.HasRows Then
  342. ' ArtikliDDL.Visible = True
  343. 'End If
  344. ArtikliDDL.DataSource = cmd.ExecuteReader()
  345. ArtikliDDL.DataTextField = "ime"
  346. ArtikliDDL.DataValueField = "id"
  347. ArtikliDDL.DataBind()
  348. con.Close()
  349.  
  350.  
  351. End Using
  352. End Using
  353.  
  354. If ArtikliDDL.Items.Count > 0 Then
  355. ArtikliDDL.Visible = True
  356. Else
  357. ArtikliDDL.Visible = False
  358. End If
  359.  
  360.  
  361. 'Dim izbrano As String
  362. 'izbrano = "Изберете бренд: "
  363. 'IzberiBrend.SelectedItem.Text = izbrano
  364. 'IzberiBrend.SelectedItem.Value = izbrano
  365. Else
  366. ArtikliDDL.Visible = False
  367.  
  368. End If
  369.  
  370.  
  371.  
  372.  
  373. End Sub
  374.  
  375. Private Sub ArtikliDDL_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ArtikliDDL.SelectedIndexChanged
  376. Session("ProductName") = ArtikliDDL.SelectedValue
  377. Response.Redirect("Product-Details.aspx", True)
  378.  
  379.  
  380. End Sub
  381.  
  382. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement