| | 2 | |
| | 3 | Во продолжение се дадени изворните кодови на страниците за регистрација, логирање, внесување лични информации, внесување активности и преглед на биографијата. |
| | 4 | |
| | 5 | |
| | 6 | '''За регистрација на корисници''' |
| | 7 | {{{ |
| | 8 | #!c# |
| | 9 | Register.aspx.cs |
| | 10 | |
| | 11 | using System; |
| | 12 | using System.Collections.Generic; |
| | 13 | using System.Linq; |
| | 14 | using System.Web; |
| | 15 | using System.Web.Security; |
| | 16 | using System.Web.UI; |
| | 17 | using System.Web.UI.WebControls; |
| | 18 | using Microsoft.AspNet.Membership.OpenAuth; |
| | 19 | |
| | 20 | |
| | 21 | namespace CoDBIS.Account |
| | 22 | { |
| | 23 | public partial class Register : System.Web.UI.Page |
| | 24 | { |
| | 25 | protected void Page_Load(object sender, EventArgs e) |
| | 26 | { |
| | 27 | RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; |
| | 28 | |
| | 29 | |
| | 30 | } |
| | 31 | |
| | 32 | protected void RegisterUser_CreatedUser(object sender, EventArgs e) |
| | 33 | { |
| | 34 | FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false); |
| | 35 | |
| | 36 | string continueUrl = RegisterUser.ContinueDestinationPageUrl; |
| | 37 | if (!OpenAuth.IsLocalUrl(continueUrl)) |
| | 38 | { |
| | 39 | continueUrl = "AddInfo.aspx"; |
| | 40 | } |
| | 41 | Response.Redirect(continueUrl); |
| | 42 | |
| | 43 | } |
| | 44 | } |
| | 45 | } |
| | 46 | |
| | 47 | Register.aspx |
| | 48 | |
| | 49 | <%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="CoDBIS.Account.Register" %> |
| | 50 | |
| | 51 | <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> |
| | 52 | <hgroup class="title"> |
| | 53 | <h1>Регистрирај се.</h1> |
| | 54 | <h2>Искористете ја формата подолу за да креирате нова корисничка сметка.</h2> |
| | 55 | </hgroup> |
| | 56 | |
| | 57 | <asp:CreateUserWizard runat="server" ID="RegisterUser" ViewStateMode="Disabled" OnCreatedUser="RegisterUser_CreatedUser" |
| | 58 | CompleteSuccessText="Вашата корисничка сметка е успешно креирана." |
| | 59 | DuplicateEmailErrorMessage="Е-маил адресата што ја внесовте е веќе во употреба. Ве молиме внесете друга е-меил адреса." |
| | 60 | DuplicateUserNameErrorMessage="Ве молиме внесете друго корисничко име." |
| | 61 | InvalidAnswerErrorMessage="Ве молиме внесете друг сигурносен одговор." |
| | 62 | InvalidEmailErrorMessage="Ве молиме внесете валидна е-меил адреса." |
| | 63 | InvalidPasswordErrorMessage="Должината на лозинката мора да е минимум: {0}. Потребни се алфа-нумерички карактери: {1}." |
| | 64 | InvalidQuestionErrorMessage="Ве молиме внесете друго сигурносно прашање." |
| | 65 | UnknownErrorMessage="Вашата корисничка сметка не е креирана. Ве молиме обидете се повторно."> |
| | 66 | <LayoutTemplate> |
| | 67 | <asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" /> |
| | 68 | <asp:PlaceHolder runat="server" ID="navigationPlaceholder" /> |
| | 69 | </LayoutTemplate> |
| | 70 | <WizardSteps> |
| | 71 | <asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep"> |
| | 72 | <ContentTemplate> |
| | 73 | <p class="message-info"> |
| | 74 | Лозинката мора да има повеќе од <%: Membership.MinRequiredPasswordLength %> карактери. |
| | 75 | </p> |
| | 76 | |
| | 77 | <p class="validation-summary-errors"> |
| | 78 | <asp:Literal runat="server" ID="ErrorMessage" /> |
| | 79 | </p> |
| | 80 | |
| | 81 | <fieldset> |
| | 82 | <legend>Registration Form</legend> |
| | 83 | <ol> |
| | 84 | <li> |
| | 85 | <asp:Label runat="server" AssociatedControlID="UserName">Корисничко име</asp:Label> |
| | 86 | <asp:TextBox runat="server" ID="UserName" /> |
| | 87 | <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName" |
| | 88 | CssClass="field-validation-error" ErrorMessage="Полето за корисничко име е задолжително." /> |
| | 89 | </li> |
| | 90 | <li> |
| | 91 | <asp:Label runat="server" AssociatedControlID="Email">Електронска адреса</asp:Label> |
| | 92 | <asp:TextBox runat="server" ID="Email" TextMode="Email" /> |
| | 93 | <asp:RequiredFieldValidator runat="server" ControlToValidate="Email" |
| | 94 | CssClass="field-validation-error" ErrorMessage="Полето за електронска адреса е задолжително." /> |
| | 95 | </li> |
| | 96 | <li> |
| | 97 | <asp:Label runat="server" AssociatedControlID="Password">Лозинка</asp:Label> |
| | 98 | <asp:TextBox runat="server" ID="Password" TextMode="Password" /> |
| | 99 | <asp:RequiredFieldValidator runat="server" ControlToValidate="Password" |
| | 100 | CssClass="field-validation-error" ErrorMessage="Полето за лозинка е задолжително." /> |
| | 101 | </li> |
| | 102 | <li> |
| | 103 | <asp:Label runat="server" AssociatedControlID="ConfirmPassword">Потврди ја лозинката</asp:Label> |
| | 104 | <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" /> |
| | 105 | <asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword" |
| | 106 | CssClass="field-validation-error" Display="Dynamic" ErrorMessage="Полето за потврда на електронската адреса е задолжително." /> |
| | 107 | <asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" |
| | 108 | CssClass="field-validation-error" Display="Dynamic" ErrorMessage="Лозинките не се совпаѓаат." /> |
| | 109 | </li> |
| | 110 | </ol> |
| | 111 | <asp:Button runat="server" CommandName="MoveNext" Text="Регистрирај се" /> |
| | 112 | </fieldset> |
| | 113 | </ContentTemplate> |
| | 114 | <CustomNavigationTemplate /> |
| | 115 | </asp:CreateUserWizardStep> |
| | 116 | </WizardSteps> |
| | 117 | </asp:CreateUserWizard> |
| | 118 | </asp:Content> |
| | 119 | }}} |
| | 120 | |
| | 121 | '''За логирање на корисници''' |
| | 122 | {{{ |
| | 123 | #!c# |
| | 124 | Login.aspx.cs |
| | 125 | |
| | 126 | using System; |
| | 127 | using System.Collections.Generic; |
| | 128 | using System.Linq; |
| | 129 | using System.Web; |
| | 130 | using System.Web.UI; |
| | 131 | using System.Web.UI.WebControls; |
| | 132 | using Microsoft.AspNet.Membership.OpenAuth; |
| | 133 | using System.Web.Security; |
| | 134 | |
| | 135 | namespace CoDBIS.Account |
| | 136 | { |
| | 137 | public partial class Login : System.Web.UI.Page |
| | 138 | { |
| | 139 | protected void Page_Load(object sender, EventArgs e) |
| | 140 | { |
| | 141 | |
| | 142 | RegisterHyperLink.NavigateUrl = "Register.aspx"; |
| | 143 | var returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); |
| | 144 | if (!String.IsNullOrEmpty(returnUrl)) |
| | 145 | { |
| | 146 | |
| | 147 | RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl; |
| | 148 | |
| | 149 | } |
| | 150 | } |
| | 151 | } |
| | 152 | } |
| | 153 | |
| | 154 | Login.aspx |
| | 155 | |
| | 156 | <%@ Page Title="Login" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="CoDBIS.Account.Login" %> |
| | 157 | <%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %> |
| | 158 | |
| | 159 | <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> |
| | 160 | <hgroup class="title"> |
| | 161 | <h1>Најавете се.</h1> |
| | 162 | </hgroup> |
| | 163 | <section id="loginForm"> |
| | 164 | <h2>Искористете ги вашето корисничко име и лозинката за да се најавите на апликацијата.</h2> |
| | 165 | <asp:Login runat="server" DestinationPageUrl="~/Account/MyBiography.aspx" |
| | 166 | ViewStateMode="Disabled" RenderOuterTable="false" |
| | 167 | FailureText="Вашиот обид за најава е неуспешен. Ве молиме обидете се повторно." |
| | 168 | PasswordRequiredErrorMessage="Лозинката е задолжителна." |
| | 169 | UserNameRequiredErrorMessage="Корисничкото име е задолжително." |
| | 170 | RememberMeText="Запомни ме следниот пат." LoginButtonText="Најави се"> |
| | 171 | |
| | 172 | <LayoutTemplate> |
| | 173 | <p class="validation-summary-errors"> |
| | 174 | <asp:Literal runat="server" ID="FailureText" /> |
| | 175 | </p> |
| | 176 | <fieldset> |
| | 177 | |
| | 178 | <legend>Log in Form</legend> |
| | 179 | <ol> |
| | 180 | <li> |
| | 181 | <asp:Label runat="server" AssociatedControlID="UserName">Корисничко име</asp:Label> |
| | 182 | <asp:TextBox runat="server" ID="UserName"/> |
| | 183 | <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName" CssClass="field-validation-error" ErrorMessage="Полето за корисничко име е задолжително." /> |
| | 184 | </li> |
| | 185 | <li> |
| | 186 | <asp:Label runat="server" AssociatedControlID="Password">Лозинка</asp:Label> |
| | 187 | <asp:TextBox runat="server" ID="Password" TextMode="Password"/> |
| | 188 | <asp:RequiredFieldValidator runat="server" ControlToValidate="Password" CssClass="field-validation-error" ErrorMessage="Полето за лозинка е задолжително." /> |
| | 189 | </li> |
| | 190 | <li> |
| | 191 | <asp:CheckBox runat="server" ID="RememberMe" /> |
| | 192 | <asp:Label runat="server" AssociatedControlID="RememberMe" CssClass="checkbox">Запомни ме?</asp:Label> |
| | 193 | </li> |
| | 194 | </ol> |
| | 195 | <asp:Button ID="btnLogin" runat="server" CommandName="Login" Text="Најави се"/> |
| | 196 | </fieldset> |
| | 197 | </LayoutTemplate> |
| | 198 | </asp:Login> |
| | 199 | <p> |
| | 200 | Ако немате корисничка сметка |
| | 201 | <asp:HyperLink runat="server" ID="RegisterHyperLink" ViewStateMode="Disabled">Регистрирајте се</asp:HyperLink> |
| | 202 | .</p> |
| | 203 | </section> |
| | 204 | |
| | 205 | </asp:Content> |
| | 206 | }}} |
| | 207 | |
| | 208 | |
| | 209 | '''Додавање лични податоци за корисникот''' |
| | 210 | {{{ |
| | 211 | #!c# |
| | 212 | Addinfo.aspx.cs |
| | 213 | |
| | 214 | using System; |
| | 215 | using System.Collections.Generic; |
| | 216 | using System.Configuration; |
| | 217 | using System.Data; |
| | 218 | using System.Data.SqlClient; |
| | 219 | using System.Linq; |
| | 220 | using System.Web; |
| | 221 | using System.Web.UI; |
| | 222 | using System.Web.UI.WebControls; |
| | 223 | |
| | 224 | namespace CoDBIS.Account |
| | 225 | { |
| | 226 | public partial class AddInfo : System.Web.UI.Page |
| | 227 | { |
| | 228 | |
| | 229 | protected void Page_Load(object sender, EventArgs e) |
| | 230 | { |
| | 231 | string korisnik = User.Identity.Name; |
| | 232 | lblUserName.Text = korisnik; |
| | 233 | } |
| | 234 | |
| | 235 | protected void btnAdd_Click(object sender, EventArgs e) |
| | 236 | { |
| | 237 | |
| | 238 | string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; |
| | 239 | |
| | 240 | SqlConnection conn = new SqlConnection(connString); |
| | 241 | |
| | 242 | conn.Open(); |
| | 243 | |
| | 244 | string updateCommand = "UPDATE [Users] SET [PlaceOfBirth]=@PlaceOfBirth, [Gender]=@Gender, [DateOfBirth]=@DateOfBirth, [Position]=@Position, [FirstNameLastName]=@FirstNameLastName, [Employer]=@Employer, [EducationLevel]=@EducationLevel, [EducationInstitution]=@EducationInstitution WHERE ([UserName]=@UserName)"; |
| | 245 | |
| | 246 | SqlCommand cmd = new SqlCommand(updateCommand, conn); |
| | 247 | |
| | 248 | cmd.Parameters.AddWithValue("@PlaceOfBirth", txtMesto.Text); |
| | 249 | |
| | 250 | cmd.Parameters.AddWithValue("@Gender", rblPol.SelectedValue.ToString()); |
| | 251 | cmd.Parameters.AddWithValue("@DateOfBirth", Convert.ToDateTime( txtDatum.Text)); |
| | 252 | |
| | 253 | cmd.Parameters.AddWithValue("@Position", txtPozicija.Text); |
| | 254 | cmd.Parameters.AddWithValue("@FirstNameLastName", txtImePrezime.Text); |
| | 255 | cmd.Parameters.AddWithValue("@Employer", txtVrabotenVo.Text); |
| | 256 | cmd.Parameters.AddWithValue("@EducationLevel", txtObrazovanie.Text); |
| | 257 | cmd.Parameters.AddWithValue("@EducationInstitution", txtInstitucija.Text); |
| | 258 | |
| | 259 | cmd.Parameters.AddWithValue("@UserName", lblUserName.Text); |
| | 260 | |
| | 261 | cmd.ExecuteNonQuery(); |
| | 262 | conn.Close(); |
| | 263 | |
| | 264 | lblMessage.Text = "Вашите податоци се успешно зачувани."; |
| | 265 | txtImePrezime.Text = ""; |
| | 266 | txtMesto.Text = ""; |
| | 267 | txtDatum.Text = ""; |
| | 268 | txtObrazovanie.Text = ""; |
| | 269 | txtInstitucija.Text = ""; |
| | 270 | txtVrabotenVo.Text = ""; |
| | 271 | txtPozicija.Text = ""; |
| | 272 | |
| | 273 | |
| | 274 | } |
| | 275 | |
| | 276 | protected void BirthCalendar_SelectionChanged(object sender, EventArgs e) |
| | 277 | { |
| | 278 | txtDatum.Text = BirthCalendar.SelectedDate.ToString("dd/MM/yyyy"); |
| | 279 | } |
| | 280 | |
| | 281 | |
| | 282 | } |
| | 283 | } |
| | 284 | |
| | 285 | Addinfo.aspx |
| | 286 | |
| | 287 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AddInfo.aspx.cs" Inherits="CoDBIS.Account.AddInfo" %> |
| | 288 | <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> |
| | 289 | <style type="text/css"> |
| | 290 | .auto-style1 { |
| | 291 | width: 100%; |
| | 292 | } |
| | 293 | .auto-style2 { |
| | 294 | width: 350px; |
| | 295 | } |
| | 296 | .auto-style3 { |
| | 297 | width: 150px; |
| | 298 | } |
| | 299 | </style> |
| | 300 | </asp:Content> |
| | 301 | <asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server"> |
| | 302 | </asp:Content> |
| | 303 | <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> |
| | 304 | |
| | 305 | |
| | 306 | <h3>Дополнете ги следниве податоци за да ги комплетирате/ажурирате Вашите кориснички податоци или кликнете на копчето Продолжи ако сакате подоцна да ги внесете овие податоци:</h3> |
| | 307 | <asp:Label ID="lblUserName" runat="server" Text="" Visible="false"></asp:Label> |
| | 308 | <br /> |
| | 309 | <h3 class="message-success"> <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label></h3> |
| | 310 | <table class="auto-style1"> |
| | 311 | <tr> |
| | 312 | <td class="auto-style2"> |
| | 313 | |
| | 314 | <asp:Label ID="lblImePrezime" runat="server" Text="Име и презиме: "></asp:Label></td> |
| | 315 | <td class="auto-style3"> |
| | 316 | <asp:TextBox ID="txtImePrezime" runat="server"></asp:TextBox></td> |
| | 317 | </tr> |
| | 318 | |
| | 319 | <tr> |
| | 320 | <td class="auto-style2"> |
| | 321 | |
| | 322 | </td> |
| | 323 | <td class="auto-style3"> |
| | 324 | </td> |
| | 325 | </tr> |
| | 326 | |
| | 327 | <tr> |
| | 328 | <td class="auto-style2"> |
| | 329 | |
| | 330 | <asp:Label ID="lblPol" runat="server" Text="Пол: "></asp:Label> |
| | 331 | </td> |
| | 332 | <td class="auto-style3"> |
| | 333 | <asp:RadioButtonList ID="rblPol" runat="server" Height="50px" Width="139px"> |
| | 334 | <asp:ListItem Value="M" Selected="True">Машки</asp:ListItem> |
| | 335 | <asp:ListItem Value="F">Женски</asp:ListItem> |
| | 336 | </asp:RadioButtonList></td> |
| | 337 | </tr> |
| | 338 | |
| | 339 | <tr> |
| | 340 | <td class="auto-style2"> |
| | 341 | |
| | 342 | </td> |
| | 343 | <td class="auto-style3"> |
| | 344 | </td> |
| | 345 | </tr> |
| | 346 | |
| | 347 | <tr> |
| | 348 | <td class="auto-style2"> |
| | 349 | |
| | 350 | <asp:Label ID="lblMesto" runat="server" Text="Место на раѓање: "></asp:Label></td> |
| | 351 | <td class="auto-style3"> |
| | 352 | <asp:TextBox ID="txtMesto" runat="server"></asp:TextBox></td> |
| | 353 | </tr> |
| | 354 | |
| | 355 | <tr> |
| | 356 | <td class="auto-style2"> |
| | 357 | |
| | 358 | </td> |
| | 359 | <td class="auto-style3"> |
| | 360 | </td> |
| | 361 | </tr> |
| | 362 | <tr> |
| | 363 | <td class="auto-style2"> |
| | 364 | |
| | 365 | <asp:Label ID="lblDatum" runat="server" Text="Датум на раѓање: "></asp:Label></td> |
| | 366 | <td class="auto-style3"> |
| | 367 | <asp:TextBox ID="txtDatum" runat="server"></asp:TextBox> |
| | 368 | </td> |
| | 369 | <td> |
| | 370 | <asp:Calendar ID="BirthCalendar" runat="server" OnSelectionChanged="BirthCalendar_SelectionChanged"></asp:Calendar> |
| | 371 | </td> |
| | 372 | </tr> |
| | 373 | <tr> |
| | 374 | <td class="auto-style2"> |
| | 375 | |
| | 376 | </td> |
| | 377 | <td class="auto-style3"> |
| | 378 | </td> |
| | 379 | <td> |
| | 380 | </td> |
| | 381 | </tr> |
| | 382 | <tr> |
| | 383 | <td class="auto-style2"> |
| | 384 | |
| | 385 | <asp:Label ID="lblObrazovanie" runat="server" Text="Ниво на образование: "></asp:Label></td> |
| | 386 | <td class="auto-style3"> |
| | 387 | <asp:TextBox ID="txtObrazovanie" runat="server"></asp:TextBox></td> |
| | 388 | </tr> |
| | 389 | <tr> |
| | 390 | <td class="auto-style2"> |
| | 391 | |
| | 392 | </td> |
| | 393 | <td class="auto-style3"> |
| | 394 | </td> |
| | 395 | </tr> |
| | 396 | <tr> |
| | 397 | <td class="auto-style2"> |
| | 398 | |
| | 399 | <asp:Label ID="lblInstitucija" runat="server" Text="Име на образовната институција: "></asp:Label></td> |
| | 400 | <td class="auto-style3"> |
| | 401 | <asp:TextBox ID="txtInstitucija" runat="server"></asp:TextBox></td> |
| | 402 | </tr> |
| | 403 | <tr> |
| | 404 | <td class="auto-style2"> |
| | 405 | |
| | 406 | </td> |
| | 407 | <td class="auto-style3"> |
| | 408 | </td> |
| | 409 | </tr> |
| | 410 | <tr> |
| | 411 | <td class="auto-style2"> |
| | 412 | |
| | 413 | <asp:Label ID="lblVrabotenVo" runat="server" Text="Вработен во: "></asp:Label></td> |
| | 414 | <td class="auto-style3"> |
| | 415 | <asp:TextBox ID="txtVrabotenVo" runat="server"></asp:TextBox></td> |
| | 416 | </tr> |
| | 417 | <tr> |
| | 418 | <td class="auto-style2"> |
| | 419 | |
| | 420 | </td> |
| | 421 | <td class="auto-style3"> |
| | 422 | </td> |
| | 423 | </tr> |
| | 424 | <tr> |
| | 425 | <td class="auto-style2"> |
| | 426 | |
| | 427 | <asp:Label ID="lblPozicija" runat="server" Text="Работна позиција: "></asp:Label></td> |
| | 428 | <td class="auto-style3"> |
| | 429 | <asp:TextBox ID="txtPozicija" runat="server"></asp:TextBox></td> |
| | 430 | </tr> |
| | 431 | <tr> |
| | 432 | <td class="auto-style2"> </td> |
| | 433 | <td class="auto-style3"> </td> |
| | 434 | </tr> |
| | 435 | <tr> |
| | 436 | <td class="auto-style2"> </td> |
| | 437 | <td class="auto-style3"> |
| | 438 | <asp:Button ID="btnAdd" runat="server" Text="Зачувај" OnClick="btnAdd_Click" /> |
| | 439 | </td> |
| | 440 | </tr> |
| | 441 | <tr> |
| | 442 | <td class="auto-style2"> </td> |
| | 443 | <td class="auto-style3"></td> |
| | 444 | </tr> |
| | 445 | <tr> |
| | 446 | <td class="auto-style2"> </td> |
| | 447 | <td class="auto-style3"> |
| | 448 | <asp:Button ID="Button2" runat="server" PostBackUrl="~/Account/MyBiography.aspx" Text="Продолжи" /> |
| | 449 | </td> |
| | 450 | </tr> |
| | 451 | </table> |
| | 452 | <br /> |
| | 453 | <br /> |
| | 454 | |
| | 455 | |
| | 456 | |
| | 457 | |
| | 458 | </asp:Content> |
| | 459 | }}} |
| | 460 | |
| | 461 | '''Inserting.aspx.cs-внес на нова активност за логираниот корисник и додавање на корисник кон веќе постоечка активност''' |
| | 462 | {{{ |
| | 463 | #!c# |
| | 464 | using System; |
| | 465 | using System.Collections.Generic; |
| | 466 | using System.Configuration; |
| | 467 | using System.Data; |
| | 468 | using System.Data.SqlClient; |
| | 469 | using System.Linq; |
| | 470 | using System.Web; |
| | 471 | using System.Web.Security; |
| | 472 | using System.Web.UI; |
| | 473 | using System.Web.UI.WebControls; |
| | 474 | |
| | 475 | namespace CoDBIS.Account |
| | 476 | { |
| | 477 | public partial class Inserting : System.Web.UI.Page |
| | 478 | |
| | 479 | { |
| | 480 | string identity; |
| | 481 | |
| | 482 | protected void Page_Load(object sender, EventArgs e) |
| | 483 | |
| | 484 | { |
| | 485 | string korisnik = User.Identity.Name; |
| | 486 | lblUsername.Text = korisnik; |
| | 487 | |
| | 488 | string userId = Membership.GetUser().ProviderUserKey.ToString(); |
| | 489 | lblUserID.Text = userId; |
| | 490 | |
| | 491 | } |
| | 492 | |
| | 493 | |
| | 494 | protected void btnInsert_Click(object sender, EventArgs e) |
| | 495 | |
| | 496 | { |
| | 497 | |
| | 498 | string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; |
| | 499 | |
| | 500 | SqlConnection conn = new SqlConnection(connString); |
| | 501 | |
| | 502 | conn.Open(); |
| | 503 | |
| | 504 | string insertCommand1 = "insert into [Activities] (Name, Category, Place, Date) values (@Name, @Category, @Place, @Date)"; |
| | 505 | insertCommand1 += "; SELECT SCOPE_IDENTITY() ; "; |
| | 506 | |
| | 507 | SqlCommand cmd1 = new SqlCommand(insertCommand1, conn); |
| | 508 | |
| | 509 | cmd1.Parameters.AddWithValue("@Name", txtName.Text); |
| | 510 | cmd1.Parameters.AddWithValue("@Category", txtCategory.Text); |
| | 511 | cmd1.Parameters.AddWithValue("@Place", txtPlace.Text); |
| | 512 | cmd1.Parameters.AddWithValue("@Date", Convert.ToDateTime(txtDate.Text)); |
| | 513 | |
| | 514 | identity = cmd1.ExecuteScalar().ToString(); |
| | 515 | lblActivityID.Text = identity; |
| | 516 | |
| | 517 | |
| | 518 | string insertCommand2 = "insert into [UsersOnActivities] (NameOfRole, UserID, ActivityID) values (@NameOfRole, @UserID, @ActivityID)"; |
| | 519 | |
| | 520 | SqlCommand cmd2 = new SqlCommand(insertCommand2, conn); |
| | 521 | |
| | 522 | cmd2.Parameters.AddWithValue("@NameOfRole", txtRole.Text); |
| | 523 | cmd2.Parameters.AddWithValue("@UserID", lblUserID.Text); |
| | 524 | cmd2.Parameters.AddWithValue("@ActivityID", lblActivityID.Text); |
| | 525 | cmd2.ExecuteNonQuery(); |
| | 526 | |
| | 527 | conn.Close(); |
| | 528 | |
| | 529 | lblMessage.Text = "Активноста е успешно внесена во Вашата биографија."; |
| | 530 | txtName.Text = ""; |
| | 531 | txtCategory.Text = ""; |
| | 532 | txtPlace.Text = ""; |
| | 533 | txtDate.Text = ""; |
| | 534 | txtRole.Text = ""; |
| | 535 | |
| | 536 | } |
| | 537 | |
| | 538 | |
| | 539 | protected void btnShow_Click(object sender, EventArgs e) |
| | 540 | |
| | 541 | { |
| | 542 | |
| | 543 | gvMe.Visible = true; |
| | 544 | } |
| | 545 | |
| | 546 | |
| | 547 | |
| | 548 | protected void btnAddMe_Click(object sender, EventArgs e) |
| | 549 | { |
| | 550 | foreach (GridViewRow row in gvMe.Rows) |
| | 551 | { |
| | 552 | if (((CheckBox)row.FindControl("CheckBox1")).Checked) |
| | 553 | { |
| | 554 | |
| | 555 | int ActivityID = Convert.ToInt32(gvMe.DataKeys[row.RowIndex].Value); |
| | 556 | lblExistingActivity.Text = ActivityID.ToString(); |
| | 557 | |
| | 558 | |
| | 559 | string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; |
| | 560 | |
| | 561 | SqlConnection conn = new SqlConnection(connString); |
| | 562 | |
| | 563 | conn.Open(); |
| | 564 | string insertCommand3 = "insert into [UsersOnActivities] (NameOfRole, UserID, ActivityID) values (@NameOfRole, @UserID, @ActivityID)"; |
| | 565 | |
| | 566 | SqlCommand cmd3 = new SqlCommand(insertCommand3, conn); |
| | 567 | |
| | 568 | cmd3.Parameters.AddWithValue("@NameOfRole", txtRoleOnExisting.Text); |
| | 569 | cmd3.Parameters.AddWithValue("@UserID", lblUserID.Text); |
| | 570 | cmd3.Parameters.AddWithValue("@ActivityID", lblExistingActivity.Text); |
| | 571 | cmd3.ExecuteNonQuery(); |
| | 572 | |
| | 573 | conn.Close(); |
| | 574 | lblMessage.Text = "Успешно сте додадени на активноста."; |
| | 575 | } |
| | 576 | } |
| | 577 | |
| | 578 | |
| | 579 | } |
| | 580 | |
| | 581 | } |
| | 582 | } |
| | 583 | }}} |
| | 584 | |
| | 585 | '''Inserting.aspx.cs-внес на нова активност за логираниот корисник и додавање на корисник кон веќе постоечка активност''' |