22 | | namespace CoDBIS.Account |
23 | | { |
24 | | public partial class Register : System.Web.UI.Page |
25 | | { |
26 | | protected void Page_Load(object sender, EventArgs e) |
27 | | { |
28 | | RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; |
29 | | |
30 | | |
31 | | } |
32 | | |
33 | | protected void RegisterUser_CreatedUser(object sender, EventArgs e) |
34 | | { |
35 | | FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false); |
36 | | |
37 | | string continueUrl = RegisterUser.ContinueDestinationPageUrl; |
38 | | if (!OpenAuth.IsLocalUrl(continueUrl)) |
39 | | { |
40 | | continueUrl = "AddInfo.aspx"; |
41 | | } |
42 | | Response.Redirect(continueUrl); |
43 | | |
44 | | } |
45 | | } |
46 | | } |
47 | | |
48 | | Register.aspx |
49 | | |
50 | | <%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="CoDBIS.Account.Register" %> |
51 | | |
52 | | <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> |
53 | | <hgroup class="title"> |
54 | | <h1>Регистрирај се.</h1> |
55 | | <h2>Искористете ја формата подолу за да креирате нова корисничка сметка.</h2> |
56 | | </hgroup> |
57 | | |
58 | | <asp:CreateUserWizard runat="server" ID="RegisterUser" ViewStateMode="Disabled" OnCreatedUser="RegisterUser_CreatedUser" |
59 | | CompleteSuccessText="Вашата корисничка сметка е успешно креирана." |
60 | | DuplicateEmailErrorMessage="Е-маил адресата што ја внесовте е веќе во употреба. Ве молиме внесете друга е-меил адреса." |
61 | | DuplicateUserNameErrorMessage="Ве молиме внесете друго корисничко име." |
62 | | InvalidAnswerErrorMessage="Ве молиме внесете друг сигурносен одговор." |
63 | | InvalidEmailErrorMessage="Ве молиме внесете валидна е-меил адреса." |
64 | | InvalidPasswordErrorMessage="Должината на лозинката мора да е минимум: {0}. Потребни се алфа-нумерички карактери: {1}." |
65 | | InvalidQuestionErrorMessage="Ве молиме внесете друго сигурносно прашање." |
66 | | UnknownErrorMessage="Вашата корисничка сметка не е креирана. Ве молиме обидете се повторно."> |
67 | | <LayoutTemplate> |
68 | | <asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" /> |
69 | | <asp:PlaceHolder runat="server" ID="navigationPlaceholder" /> |
70 | | </LayoutTemplate> |
71 | | <WizardSteps> |
72 | | <asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep"> |
73 | | <ContentTemplate> |
74 | | <p class="message-info"> |
75 | | Лозинката мора да има повеќе од <%: Membership.MinRequiredPasswordLength %> карактери. |
76 | | </p> |
77 | | |
78 | | <p class="validation-summary-errors"> |
79 | | <asp:Literal runat="server" ID="ErrorMessage" /> |
80 | | </p> |
81 | | |
82 | | <fieldset> |
83 | | <legend>Registration Form</legend> |
84 | | <ol> |
85 | | <li> |
86 | | <asp:Label runat="server" AssociatedControlID="UserName">Корисничко име</asp:Label> |
87 | | <asp:TextBox runat="server" ID="UserName" /> |
88 | | <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName" |
89 | | CssClass="field-validation-error" ErrorMessage="Полето за корисничко име е задолжително." /> |
90 | | </li> |
91 | | <li> |
92 | | <asp:Label runat="server" AssociatedControlID="Email">Електронска адреса</asp:Label> |
93 | | <asp:TextBox runat="server" ID="Email" TextMode="Email" /> |
94 | | <asp:RequiredFieldValidator runat="server" ControlToValidate="Email" |
95 | | CssClass="field-validation-error" ErrorMessage="Полето за електронска адреса е задолжително." /> |
96 | | </li> |
97 | | <li> |
98 | | <asp:Label runat="server" AssociatedControlID="Password">Лозинка</asp:Label> |
99 | | <asp:TextBox runat="server" ID="Password" TextMode="Password" /> |
100 | | <asp:RequiredFieldValidator runat="server" ControlToValidate="Password" |
101 | | CssClass="field-validation-error" ErrorMessage="Полето за лозинка е задолжително." /> |
102 | | </li> |
103 | | <li> |
104 | | <asp:Label runat="server" AssociatedControlID="ConfirmPassword">Потврди ја лозинката</asp:Label> |
105 | | <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" /> |
106 | | <asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword" |
107 | | CssClass="field-validation-error" Display="Dynamic" ErrorMessage="Полето за потврда на електронската адреса е задолжително." /> |
108 | | <asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" |
109 | | CssClass="field-validation-error" Display="Dynamic" ErrorMessage="Лозинките не се совпаѓаат." /> |
110 | | </li> |
111 | | </ol> |
112 | | <asp:Button runat="server" CommandName="MoveNext" Text="Регистрирај се" /> |
113 | | </fieldset> |
114 | | </ContentTemplate> |
115 | | <CustomNavigationTemplate /> |
116 | | </asp:CreateUserWizardStep> |
117 | | </WizardSteps> |
118 | | </asp:CreateUserWizard> |
119 | | </asp:Content> |
120 | | }}} |
121 | | |
122 | | '''За логирање на корисници''' |
123 | | {{{ |
124 | | #!c# |
125 | | Login.aspx.cs |
126 | | |
127 | | using System; |
128 | | using System.Collections.Generic; |
129 | | using System.Linq; |
130 | | using System.Web; |
131 | | using System.Web.UI; |
132 | | using System.Web.UI.WebControls; |
133 | | using Microsoft.AspNet.Membership.OpenAuth; |
134 | | using System.Web.Security; |
135 | | |
136 | | namespace CoDBIS.Account |
137 | | { |
138 | | public partial class Login : System.Web.UI.Page |
139 | | { |
140 | | protected void Page_Load(object sender, EventArgs e) |
141 | | { |
142 | | |
143 | | RegisterHyperLink.NavigateUrl = "Register.aspx"; |
144 | | var returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); |
145 | | if (!String.IsNullOrEmpty(returnUrl)) |
146 | | { |
147 | | |
148 | | RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl; |
149 | | |
150 | | } |
151 | | } |
152 | | } |
153 | | } |
154 | | |
155 | | Login.aspx |
156 | | |
157 | | <%@ Page Title="Login" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="CoDBIS.Account.Login" %> |
158 | | <%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %> |
159 | | |
160 | | <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> |
161 | | <hgroup class="title"> |
162 | | <h1>Најавете се.</h1> |
163 | | </hgroup> |
164 | | <section id="loginForm"> |
165 | | <h2>Искористете ги вашето корисничко име и лозинката за да се најавите на апликацијата.</h2> |
166 | | <asp:Login runat="server" DestinationPageUrl="~/Account/MyBiography.aspx" |
167 | | ViewStateMode="Disabled" RenderOuterTable="false" |
168 | | FailureText="Вашиот обид за најава е неуспешен. Ве молиме обидете се повторно." |
169 | | PasswordRequiredErrorMessage="Лозинката е задолжителна." |
170 | | UserNameRequiredErrorMessage="Корисничкото име е задолжително." |
171 | | RememberMeText="Запомни ме следниот пат." LoginButtonText="Најави се"> |
172 | | |
173 | | <LayoutTemplate> |
174 | | <p class="validation-summary-errors"> |
175 | | <asp:Literal runat="server" ID="FailureText" /> |
176 | | </p> |
177 | | <fieldset> |
178 | | |
179 | | <legend>Log in Form</legend> |
180 | | <ol> |
181 | | <li> |
182 | | <asp:Label runat="server" AssociatedControlID="UserName">Корисничко име</asp:Label> |
183 | | <asp:TextBox runat="server" ID="UserName"/> |
184 | | <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName" CssClass="field-validation-error" ErrorMessage="Полето за корисничко име е задолжително." /> |
185 | | </li> |
186 | | <li> |
187 | | <asp:Label runat="server" AssociatedControlID="Password">Лозинка</asp:Label> |
188 | | <asp:TextBox runat="server" ID="Password" TextMode="Password"/> |
189 | | <asp:RequiredFieldValidator runat="server" ControlToValidate="Password" CssClass="field-validation-error" ErrorMessage="Полето за лозинка е задолжително." /> |
190 | | </li> |
191 | | <li> |
192 | | <asp:CheckBox runat="server" ID="RememberMe" /> |
193 | | <asp:Label runat="server" AssociatedControlID="RememberMe" CssClass="checkbox">Запомни ме?</asp:Label> |
194 | | </li> |
195 | | </ol> |
196 | | <asp:Button ID="btnLogin" runat="server" CommandName="Login" Text="Најави се"/> |
197 | | </fieldset> |
198 | | </LayoutTemplate> |
199 | | </asp:Login> |
200 | | <p> |
201 | | Ако немате корисничка сметка |
202 | | <asp:HyperLink runat="server" ID="RegisterHyperLink" ViewStateMode="Disabled">Регистрирајте се</asp:HyperLink> |
203 | | .</p> |
204 | | </section> |
205 | | |
206 | | </asp:Content> |
207 | | }}} |
208 | | |
209 | | |
210 | | '''Додавање лични податоци за корисникот''' |
211 | | {{{ |
212 | | #!c# |
213 | | Addinfo.aspx.cs |
214 | | |
215 | | using System; |
216 | | using System.Collections.Generic; |
217 | | using System.Configuration; |
218 | | using System.Data; |
219 | | using System.Data.SqlClient; |
220 | | using System.Linq; |
221 | | using System.Web; |
222 | | using System.Web.UI; |
223 | | using System.Web.UI.WebControls; |
224 | | |
225 | | namespace CoDBIS.Account |
226 | | { |
227 | | public partial class AddInfo : System.Web.UI.Page |
228 | | { |
229 | | |
230 | | protected void Page_Load(object sender, EventArgs e) |
231 | | { |
232 | | string korisnik = User.Identity.Name; |
233 | | lblUserName.Text = korisnik; |
234 | | } |
235 | | |
236 | | protected void btnAdd_Click(object sender, EventArgs e) |
237 | | { |
238 | | |
239 | | string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; |
240 | | |
241 | | SqlConnection conn = new SqlConnection(connString); |
242 | | |
243 | | conn.Open(); |
244 | | |
245 | | string updateCommand = "UPDATE [Users] SET [PlaceOfBirth]=@PlaceOfBirth, [Gender]=@Gender, [DateOfBirth]=@DateOfBirth, [Position]=@Position, [FirstNameLastName]=@FirstNameLastName, [Employer]=@Employer, [EducationLevel]=@EducationLevel, [EducationInstitution]=@EducationInstitution WHERE ([UserName]=@UserName)"; |
246 | | |
247 | | SqlCommand cmd = new SqlCommand(updateCommand, conn); |
248 | | |
249 | | cmd.Parameters.AddWithValue("@PlaceOfBirth", txtMesto.Text); |
250 | | |
251 | | cmd.Parameters.AddWithValue("@Gender", rblPol.SelectedValue.ToString()); |
252 | | cmd.Parameters.AddWithValue("@DateOfBirth", Convert.ToDateTime( txtDatum.Text)); |
253 | | |
254 | | cmd.Parameters.AddWithValue("@Position", txtPozicija.Text); |
255 | | cmd.Parameters.AddWithValue("@FirstNameLastName", txtImePrezime.Text); |
256 | | cmd.Parameters.AddWithValue("@Employer", txtVrabotenVo.Text); |
257 | | cmd.Parameters.AddWithValue("@EducationLevel", txtObrazovanie.Text); |
258 | | cmd.Parameters.AddWithValue("@EducationInstitution", txtInstitucija.Text); |
259 | | |
260 | | cmd.Parameters.AddWithValue("@UserName", lblUserName.Text); |
261 | | |
262 | | cmd.ExecuteNonQuery(); |
263 | | conn.Close(); |
264 | | |
265 | | lblMessage.Text = "Вашите податоци се успешно зачувани."; |
266 | | txtImePrezime.Text = ""; |
267 | | txtMesto.Text = ""; |
268 | | txtDatum.Text = ""; |
269 | | txtObrazovanie.Text = ""; |
270 | | txtInstitucija.Text = ""; |
271 | | txtVrabotenVo.Text = ""; |
272 | | txtPozicija.Text = ""; |
273 | | |
274 | | |
275 | | } |
276 | | |
277 | | protected void BirthCalendar_SelectionChanged(object sender, EventArgs e) |
278 | | { |
279 | | txtDatum.Text = BirthCalendar.SelectedDate.ToString("dd/MM/yyyy"); |
280 | | } |
281 | | |
282 | | |
283 | | } |
284 | | } |
285 | | |
286 | | Addinfo.aspx |
287 | | |
288 | | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AddInfo.aspx.cs" Inherits="CoDBIS.Account.AddInfo" %> |
289 | | <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> |
290 | | <style type="text/css"> |
291 | | .auto-style1 { |
292 | | width: 100%; |
293 | | } |
294 | | .auto-style2 { |
295 | | width: 350px; |
296 | | } |
297 | | .auto-style3 { |
298 | | width: 150px; |
299 | | } |
300 | | </style> |
301 | | </asp:Content> |
302 | | <asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server"> |
303 | | </asp:Content> |
304 | | <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> |
305 | | |
306 | | |
307 | | <h3>Дополнете ги следниве податоци за да ги комплетирате/ажурирате Вашите кориснички податоци или кликнете на копчето Продолжи ако сакате подоцна да ги внесете овие податоци:</h3> |
308 | | <asp:Label ID="lblUserName" runat="server" Text="" Visible="false"></asp:Label> |
309 | | <br /> |
310 | | <h3 class="message-success"> <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label></h3> |
311 | | <table class="auto-style1"> |
312 | | <tr> |
313 | | <td class="auto-style2"> |
314 | | |
315 | | <asp:Label ID="lblImePrezime" runat="server" Text="Име и презиме: "></asp:Label></td> |
316 | | <td class="auto-style3"> |
317 | | <asp:TextBox ID="txtImePrezime" runat="server"></asp:TextBox></td> |
318 | | </tr> |
319 | | |
320 | | <tr> |
321 | | <td class="auto-style2"> |
322 | | |
323 | | </td> |
324 | | <td class="auto-style3"> |
325 | | </td> |
326 | | </tr> |
327 | | |
328 | | <tr> |
329 | | <td class="auto-style2"> |
330 | | |
331 | | <asp:Label ID="lblPol" runat="server" Text="Пол: "></asp:Label> |
332 | | </td> |
333 | | <td class="auto-style3"> |
334 | | <asp:RadioButtonList ID="rblPol" runat="server" Height="50px" Width="139px"> |
335 | | <asp:ListItem Value="M" Selected="True">Машки</asp:ListItem> |
336 | | <asp:ListItem Value="F">Женски</asp:ListItem> |
337 | | </asp:RadioButtonList></td> |
338 | | </tr> |
339 | | |
340 | | <tr> |
341 | | <td class="auto-style2"> |
342 | | |
343 | | </td> |
344 | | <td class="auto-style3"> |
345 | | </td> |
346 | | </tr> |
347 | | |
348 | | <tr> |
349 | | <td class="auto-style2"> |
350 | | |
351 | | <asp:Label ID="lblMesto" runat="server" Text="Место на раѓање: "></asp:Label></td> |
352 | | <td class="auto-style3"> |
353 | | <asp:TextBox ID="txtMesto" runat="server"></asp:TextBox></td> |
354 | | </tr> |
355 | | |
356 | | <tr> |
357 | | <td class="auto-style2"> |
358 | | |
359 | | </td> |
360 | | <td class="auto-style3"> |
361 | | </td> |
362 | | </tr> |
363 | | <tr> |
364 | | <td class="auto-style2"> |
365 | | |
366 | | <asp:Label ID="lblDatum" runat="server" Text="Датум на раѓање: "></asp:Label></td> |
367 | | <td class="auto-style3"> |
368 | | <asp:TextBox ID="txtDatum" runat="server"></asp:TextBox> |
369 | | </td> |
370 | | <td> |
371 | | <asp:Calendar ID="BirthCalendar" runat="server" OnSelectionChanged="BirthCalendar_SelectionChanged"></asp:Calendar> |
372 | | </td> |
373 | | </tr> |
374 | | <tr> |
375 | | <td class="auto-style2"> |
376 | | |
377 | | </td> |
378 | | <td class="auto-style3"> |
379 | | </td> |
380 | | <td> |
381 | | </td> |
382 | | </tr> |
383 | | <tr> |
384 | | <td class="auto-style2"> |
385 | | |
386 | | <asp:Label ID="lblObrazovanie" runat="server" Text="Ниво на образование: "></asp:Label></td> |
387 | | <td class="auto-style3"> |
388 | | <asp:TextBox ID="txtObrazovanie" runat="server"></asp:TextBox></td> |
389 | | </tr> |
390 | | <tr> |
391 | | <td class="auto-style2"> |
392 | | |
393 | | </td> |
394 | | <td class="auto-style3"> |
395 | | </td> |
396 | | </tr> |
397 | | <tr> |
398 | | <td class="auto-style2"> |
399 | | |
400 | | <asp:Label ID="lblInstitucija" runat="server" Text="Име на образовната институција: "></asp:Label></td> |
401 | | <td class="auto-style3"> |
402 | | <asp:TextBox ID="txtInstitucija" runat="server"></asp:TextBox></td> |
403 | | </tr> |
404 | | <tr> |
405 | | <td class="auto-style2"> |
406 | | |
407 | | </td> |
408 | | <td class="auto-style3"> |
409 | | </td> |
410 | | </tr> |
411 | | <tr> |
412 | | <td class="auto-style2"> |
413 | | |
414 | | <asp:Label ID="lblVrabotenVo" runat="server" Text="Вработен во: "></asp:Label></td> |
415 | | <td class="auto-style3"> |
416 | | <asp:TextBox ID="txtVrabotenVo" runat="server"></asp:TextBox></td> |
417 | | </tr> |
418 | | <tr> |
419 | | <td class="auto-style2"> |
420 | | |
421 | | </td> |
422 | | <td class="auto-style3"> |
423 | | </td> |
424 | | </tr> |
425 | | <tr> |
426 | | <td class="auto-style2"> |
427 | | |
428 | | <asp:Label ID="lblPozicija" runat="server" Text="Работна позиција: "></asp:Label></td> |
429 | | <td class="auto-style3"> |
430 | | <asp:TextBox ID="txtPozicija" runat="server"></asp:TextBox></td> |
431 | | </tr> |
432 | | <tr> |
433 | | <td class="auto-style2"> </td> |
434 | | <td class="auto-style3"> </td> |
435 | | </tr> |
436 | | <tr> |
437 | | <td class="auto-style2"> </td> |
438 | | <td class="auto-style3"> |
439 | | <asp:Button ID="btnAdd" runat="server" Text="Зачувај" OnClick="btnAdd_Click" /> |
440 | | </td> |
441 | | </tr> |
442 | | <tr> |
443 | | <td class="auto-style2"> </td> |
444 | | <td class="auto-style3"></td> |
445 | | </tr> |
446 | | <tr> |
447 | | <td class="auto-style2"> </td> |
448 | | <td class="auto-style3"> |
449 | | <asp:Button ID="Button2" runat="server" PostBackUrl="~/Account/MyBiography.aspx" Text="Продолжи" /> |
450 | | </td> |
451 | | </tr> |
452 | | </table> |
453 | | <br /> |
454 | | <br /> |
455 | | |
456 | | |
457 | | |
458 | | |
459 | | </asp:Content> |
460 | | }}} |
461 | | |
462 | | '''Внес на нова активност за логираниот корисник и додавање на корисник кон веќе постоечка активност''' |
463 | | {{{ |
464 | | #!c# |
465 | | Inserting.aspx.cs |
466 | | |
467 | | using System; |
468 | | using System.Collections.Generic; |
469 | | using System.Configuration; |
470 | | using System.Data; |
471 | | using System.Data.SqlClient; |
472 | | using System.Linq; |
473 | | using System.Web; |
474 | | using System.Web.Security; |
475 | | using System.Web.UI; |
476 | | using System.Web.UI.WebControls; |
477 | | |
478 | | namespace CoDBIS.Account |
479 | | { |
480 | | public partial class Inserting : System.Web.UI.Page |
481 | | |
482 | | { |
483 | | string identity; |
484 | | |
485 | | protected void Page_Load(object sender, EventArgs e) |
486 | | |
487 | | { |
488 | | string korisnik = User.Identity.Name; |
489 | | lblUsername.Text = korisnik; |
490 | | |
491 | | string userId = Membership.GetUser().ProviderUserKey.ToString(); |
492 | | lblUserID.Text = userId; |
493 | | |
494 | | } |
495 | | |
496 | | |
497 | | protected void btnInsert_Click(object sender, EventArgs e) |
498 | | |
499 | | { |
500 | | |
501 | | string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; |
502 | | |
503 | | SqlConnection conn = new SqlConnection(connString); |
504 | | |
505 | | conn.Open(); |
506 | | |
507 | | string insertCommand1 = "insert into [Activities] (Name, Category, Place, Date) values (@Name, @Category, @Place, @Date)"; |
508 | | insertCommand1 += "; SELECT SCOPE_IDENTITY() ; "; |
509 | | |
510 | | SqlCommand cmd1 = new SqlCommand(insertCommand1, conn); |
511 | | |
512 | | cmd1.Parameters.AddWithValue("@Name", txtName.Text); |
513 | | cmd1.Parameters.AddWithValue("@Category", txtCategory.Text); |
514 | | cmd1.Parameters.AddWithValue("@Place", txtPlace.Text); |
515 | | cmd1.Parameters.AddWithValue("@Date", Convert.ToDateTime(txtDate.Text)); |
516 | | |
517 | | identity = cmd1.ExecuteScalar().ToString(); |
518 | | lblActivityID.Text = identity; |
519 | | |
520 | | |
521 | | string insertCommand2 = "insert into [UsersOnActivities] (NameOfRole, UserID, ActivityID) values (@NameOfRole, @UserID, @ActivityID)"; |
522 | | |
523 | | SqlCommand cmd2 = new SqlCommand(insertCommand2, conn); |
524 | | |
525 | | cmd2.Parameters.AddWithValue("@NameOfRole", txtRole.Text); |
526 | | cmd2.Parameters.AddWithValue("@UserID", lblUserID.Text); |
527 | | cmd2.Parameters.AddWithValue("@ActivityID", lblActivityID.Text); |
528 | | cmd2.ExecuteNonQuery(); |
529 | | |
530 | | conn.Close(); |
531 | | |
532 | | lblMessage.Text = "Активноста е успешно внесена во Вашата биографија."; |
533 | | txtName.Text = ""; |
534 | | txtCategory.Text = ""; |
535 | | txtPlace.Text = ""; |
536 | | txtDate.Text = ""; |
537 | | txtRole.Text = ""; |
538 | | |
539 | | } |
540 | | |
541 | | |
542 | | protected void btnShow_Click(object sender, EventArgs e) |
543 | | |
544 | | { |
545 | | |
546 | | gvMe.Visible = true; |
547 | | } |
548 | | |
549 | | |
550 | | |
551 | | protected void btnAddMe_Click(object sender, EventArgs e) |
552 | | { |
553 | | foreach (GridViewRow row in gvMe.Rows) |
554 | | { |
555 | | if (((CheckBox)row.FindControl("CheckBox1")).Checked) |
556 | | { |
557 | | |
558 | | int ActivityID = Convert.ToInt32(gvMe.DataKeys[row.RowIndex].Value); |
559 | | lblExistingActivity.Text = ActivityID.ToString(); |
560 | | |
561 | | |
562 | | string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; |
563 | | |
564 | | SqlConnection conn = new SqlConnection(connString); |
565 | | |
566 | | conn.Open(); |
567 | | string insertCommand3 = "insert into [UsersOnActivities] (NameOfRole, UserID, ActivityID) values (@NameOfRole, @UserID, @ActivityID)"; |
568 | | |
569 | | SqlCommand cmd3 = new SqlCommand(insertCommand3, conn); |
570 | | |
571 | | cmd3.Parameters.AddWithValue("@NameOfRole", txtRoleOnExisting.Text); |
572 | | cmd3.Parameters.AddWithValue("@UserID", lblUserID.Text); |
573 | | cmd3.Parameters.AddWithValue("@ActivityID", lblExistingActivity.Text); |
574 | | cmd3.ExecuteNonQuery(); |
575 | | |
576 | | conn.Close(); |
577 | | lblMessage.Text = "Успешно сте додадени на активноста."; |
578 | | } |
579 | | } |
580 | | |
581 | | |
582 | | } |
583 | | |
584 | | } |
585 | | } |
586 | | |
587 | | Inserting.aspx |
588 | | |
589 | | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Inserting.aspx.cs" Inherits="CoDBIS.Account.Inserting" %> |
590 | | <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> |
591 | | |
592 | | </asp:Content> |
593 | | <asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server"> |
594 | | |
595 | | </asp:Content> |
596 | | <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> |
597 | | |
598 | | |
599 | | <h3> |
600 | | <asp:Label ID="lblUsername" runat="server" Visible="false"></asp:Label> |
601 | | <asp:Label ID="lblActivityID" runat="server" Text="Label" Visible="false"></asp:Label> |
602 | | <asp:Label ID="lblUserID" runat="server" Text="Label" Visible="false"></asp:Label> |
603 | | </h3> |
604 | | |
605 | | |
606 | | <asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible="true"> |
607 | | |
608 | | <h3>Додадете нова активност на која сте учествувале: </h3> |
609 | | <h3 class="message-success"><asp:Label ID="lblMessage" runat="server" Text=""></asp:Label></h3> |
610 | | |
611 | | |
612 | | <table class="auto-style1" border="0"> |
613 | | |
614 | | <tr> |
615 | | |
616 | | <td> |
617 | | <asp:Label ID="lblName" runat="server" Text="Име на активноста: "></asp:Label> |
618 | | </td> |
619 | | <td> |
620 | | <asp:TextBox ID="txtName" runat="server"></asp:TextBox> |
621 | | </td> |
622 | | </tr> |
623 | | <tr> |
624 | | <td> |
625 | | <asp:Label ID="lblCategory" runat="server" Text="Категорија: "></asp:Label> |
626 | | </td> |
627 | | <td> |
628 | | <asp:TextBox ID="txtCategory" runat="server"></asp:TextBox> |
629 | | |
630 | | </td> |
631 | | </tr> |
632 | | <tr> |
633 | | <td> |
634 | | <asp:Label ID="lblPlace" runat="server" Text="Место на одржување/објава: "></asp:Label> |
635 | | </td> |
636 | | <td> |
637 | | <asp:TextBox ID="txtPlace" runat="server"></asp:TextBox> |
638 | | |
639 | | </td> |
640 | | </tr> |
641 | | <tr> |
642 | | <td> |
643 | | <asp:Label ID="lblDate" runat="server" Text="Датум на одржување/објава: "></asp:Label> |
644 | | </td> |
645 | | <td> |
646 | | <asp:TextBox ID="txtDate" runat="server"></asp:TextBox> |
647 | | |
648 | | </td> |
649 | | </tr> |
650 | | <tr> |
651 | | <td><asp:Label ID="lblRole" runat="server" Text="Улога: "></asp:Label></td> |
652 | | <td> |
653 | | <asp:TextBox ID="txtRole" runat="server"></asp:TextBox> |
654 | | |
655 | | </td> |
656 | | </tr> |
657 | | <tr> |
658 | | <td> </td> |
659 | | <td> </td> |
660 | | </tr> |
661 | | <tr> |
662 | | <td> |
663 | | <asp:Button ID="btnInsert" runat="server" Text="Внеси" OnClick="btnInsert_Click"/> |
664 | | </td> |
665 | | <td></td> |
666 | | |
667 | | </tr> |
668 | | </table> |
669 | | |
670 | | <hr /> |
671 | | </asp:PlaceHolder> |
672 | | |
673 | | |
674 | | <asp:PlaceHolder ID="PlaceHolder2" runat="server" Visible="true"> |
675 | | <h3>Пребарајте веќе постоечки активности и приклучете се: </h3> |
676 | | <br /> |
677 | | Внеси име на активноста: |
678 | | <asp:TextBox ID="txtActivity" runat="server" ></asp:TextBox> <asp:Button ID="btnShow" runat="server" Text="Прикажи активности" OnClick="btnShow_Click"/><br /> |
679 | | <asp:Label ID="lblRoleOnExisting" runat="server" Text="Улога: "></asp:Label><asp:TextBox ID="txtRoleOnExisting" runat="server"></asp:TextBox> |
680 | | <asp:Label ID="lblExistingActivity" runat="server" Text="Label" Visible="false"></asp:Label> |
681 | | |
682 | | <asp:GridView ID="gvMe" EmptyDataText="Не постојат активности со тоа име." runat="server" AutoGenerateColumns="False" DataKeyNames="ActivityID" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" Visible="false" OnSelectedIndexChanged="btnAddMe_Click" CellPadding="4" ForeColor="#333333" GridLines="None"> |
683 | | <AlternatingRowStyle BackColor="White" ForeColor="#284775"></AlternatingRowStyle> |
684 | | <Columns> |
685 | | <asp:TemplateField HeaderText="Означи активност"> |
686 | | <ItemTemplate> |
687 | | <asp:CheckBox ID="CheckBox1" runat="server" /> |
688 | | </ItemTemplate> |
689 | | </asp:TemplateField> |
690 | | <asp:BoundField DataField="Name" HeaderText="ИмеНаАктивноста " SortExpression="Name" InsertVisible="False" ReadOnly="True"></asp:BoundField> |
691 | | <asp:BoundField DataField="Category" HeaderText="Категорија " SortExpression="Category"></asp:BoundField> |
692 | | <asp:BoundField DataField="Place" HeaderText="МестоНаОбјаваОдржување " SortExpression="Place"></asp:BoundField> |
693 | | <asp:BoundField DataField="Date" HeaderText="ДатумНаОбјаваОдржување " SortExpression="Date"></asp:BoundField> |
694 | | </Columns> |
695 | | <EditRowStyle BackColor="#999999"></EditRowStyle> |
696 | | |
697 | | <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"></FooterStyle> |
698 | | |
699 | | <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"></HeaderStyle> |
700 | | |
701 | | <PagerStyle HorizontalAlign="Center" BackColor="#284775" ForeColor="White"></PagerStyle> |
702 | | |
703 | | <RowStyle BackColor="#F7F6F3" ForeColor="#333333"></RowStyle> |
704 | | |
705 | | <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"></SelectedRowStyle> |
706 | | |
707 | | <SortedAscendingCellStyle BackColor="#E9E7E2"></SortedAscendingCellStyle> |
708 | | |
709 | | <SortedAscendingHeaderStyle BackColor="#506C8C"></SortedAscendingHeaderStyle> |
710 | | |
711 | | <SortedDescendingCellStyle BackColor="#FFFDF8"></SortedDescendingCellStyle> |
712 | | |
713 | | <SortedDescendingHeaderStyle BackColor="#6F8DAE"></SortedDescendingHeaderStyle> |
714 | | </asp:GridView> |
715 | | <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:DefaultConnection %>' SelectCommand="SELECT [ActivityID], [Name], [Category], [Place], [Date] FROM [Activities] WHERE ([Name] = @Name)"> |
716 | | <SelectParameters> |
717 | | <asp:ControlParameter ControlID="txtActivity" PropertyName="Text" DefaultValue="Избери активност" Name="Name" Type="String"></asp:ControlParameter> |
718 | | </SelectParameters> |
719 | | </asp:SqlDataSource> |
720 | | <br /> |
721 | | |
722 | | <asp:Button ID="btnAddMe" runat="server" Text="Додади ме" OnClick="btnAddMe_Click"/><br /> |
723 | | |
724 | | |
725 | | </asp:PlaceHolder> |
726 | | <br /> |
727 | | |
728 | | </asp:Content> |
729 | | |
730 | | }}} |
731 | | |
732 | | '''Преглед на биографија за корисникот''' |
733 | | {{{ |
734 | | #!c# |
735 | | MyBiography.aspx.cs |
736 | | |
737 | | using System; |
738 | | using System.Collections.Generic; |
739 | | using System.Linq; |
740 | | using System.Web; |
741 | | using System.Web.UI; |
742 | | using System.Web.UI.WebControls; |
743 | | using Microsoft.AspNet.Membership.OpenAuth; |
744 | | using System.Web.Security; |
745 | | using System.Data.SqlClient; |
746 | | using System.Configuration; |
747 | | using System.Data; |
748 | | |
749 | | |
750 | | |
751 | | |
752 | | namespace CoDBIS.Account |
753 | | { |
754 | | public partial class MyBiography : System.Web.UI.Page |
755 | | { |
756 | | protected void Page_Load(object sender, EventArgs e) |
757 | | { |
758 | | |
759 | | string korisnik = User.Identity.Name; |
760 | | lblUsername.Text = korisnik; |
761 | | |
762 | | |
763 | | if (!User.Identity.IsAuthenticated) |
764 | | { |
765 | | Response.Redirect("Login.aspx"); |
766 | | |
767 | | } |
768 | | |
769 | | } |
770 | | } |
771 | | } |
772 | | |
773 | | MyBiography.aspx |
774 | | |
775 | | <%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="MyBiography.aspx.cs" Inherits="CoDBIS.Account.MyBiography" %> |
776 | | |
777 | | <asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent"> |
778 | | <section class="featured"> |
779 | | <div class="content-wrapper"> |
780 | | <hgroup class="title"> |
781 | | <h1>Мојата биографија.</h1> |
782 | | <h2>На оваа страница можете да ги најдете сите информации поврзани со вашата биографија.</h2> |
783 | | </hgroup> |
784 | | </div> |
785 | | </section> |
786 | | |
787 | | </asp:Content> |
788 | | <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> |
789 | | |
790 | | <table class="auto-style1"> |
791 | | <tr> |
792 | | <td class="auto-style2"> |
793 | | <asp:Label ID="lblUsername" runat="server" Visible="false"></asp:Label> |
794 | | </td> |
795 | | <td style="text-align: center"> |
796 | | <asp:Button ID="Button1" runat="server" Text="Внеси нова активност" Width="220px" PostBackUrl="~/Account/Inserting.aspx" /> |
797 | | </td> |
798 | | </tr> |
799 | | </table> |
800 | | |
801 | | <h3>Лични податоци:</h3> |
802 | | <p> |
803 | | <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource2" CellPadding="3" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" GridLines="Vertical"> |
804 | | <EditItemTemplate> |
805 | | ИмеПрезиме: |
806 | | <asp:TextBox ID="ИмеПрезимеTextBox" runat="server" Text='<%# Bind("ИмеПрезиме") %>' /> |
807 | | <br /> |
808 | | ДатумНаРаѓање: |
809 | | <asp:TextBox ID="ДатумНаРаѓањеTextBox" runat="server" Text='<%# Bind("ДатумНаРаѓање") %>' /> |
810 | | <br /> |
811 | | МестоНаРаѓање: |
812 | | <asp:TextBox ID="МестоНаРаѓањеTextBox" runat="server" Text='<%# Bind("МестоНаРаѓање") %>' /> |
813 | | <br /> |
814 | | Пол: |
815 | | <asp:TextBox ID="ПолTextBox" runat="server" Text='<%# Bind("Пол") %>' /> |
816 | | <br /> |
817 | | КонтактЕмеил: |
818 | | <asp:TextBox ID="КонтактЕмеилTextBox" runat="server" Text='<%# Bind("КонтактЕмеил") %>' /> |
819 | | <br /> |
820 | | ИмеНаОбразовнаИнституција: |
821 | | <asp:TextBox ID="ИмеНаОбразовнаИнституцијаTextBox" runat="server" Text='<%# Bind("ИмеНаОбразовнаИнституција") %>' /> |
822 | | <br /> |
823 | | НивоНаОбразование: |
824 | | <asp:TextBox ID="НивоНаОбразованиеTextBox" runat="server" Text='<%# Bind("НивоНаОбразование") %>' /> |
825 | | <br /> |
826 | | ОстанатоОбразование: |
827 | | <asp:TextBox ID="ОстанатоОбразованиеTextBox" runat="server" Text='<%# Bind("ОстанатоОбразование") %>' /> |
828 | | <br /> |
829 | | ВработенВо: |
830 | | <asp:TextBox ID="ВработенВоTextBox" runat="server" Text='<%# Bind("ВработенВо") %>' /> |
831 | | <br /> |
832 | | РаботнаПозиција: |
833 | | <asp:TextBox ID="РаботнаПозицијаTextBox" runat="server" Text='<%# Bind("РаботнаПозиција") %>' /> |
834 | | <br /> |
835 | | <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> |
836 | | <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> |
837 | | </EditItemTemplate> |
838 | | <EditRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> |
839 | | <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> |
840 | | <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /> |
841 | | <InsertItemTemplate> |
842 | | ИмеПрезиме: |
843 | | <asp:TextBox ID="ИмеПрезимеTextBox" runat="server" Text='<%# Bind("ИмеПрезиме") %>' /> |
844 | | <br /> |
845 | | ДатумНаРаѓање: |
846 | | <asp:TextBox ID="ДатумНаРаѓањеTextBox" runat="server" Text='<%# Bind("ДатумНаРаѓање") %>' /> |
847 | | <br /> |
848 | | МестоНаРаѓање: |
849 | | <asp:TextBox ID="МестоНаРаѓањеTextBox" runat="server" Text='<%# Bind("МестоНаРаѓање") %>' /> |
850 | | <br /> |
851 | | Пол: |
852 | | <asp:TextBox ID="ПолTextBox" runat="server" Text='<%# Bind("Пол") %>' /> |
853 | | <br /> |
854 | | КонтактЕмеил: |
855 | | <asp:TextBox ID="КонтактЕмеилTextBox" runat="server" Text='<%# Bind("КонтактЕмеил") %>' /> |
856 | | <br /> |
857 | | ИмеНаОбразовнаИнституција: |
858 | | <asp:TextBox ID="ИмеНаОбразовнаИнституцијаTextBox" runat="server" Text='<%# Bind("ИмеНаОбразовнаИнституција") %>' /> |
859 | | <br /> |
860 | | НивоНаОбразование: |
861 | | <asp:TextBox ID="НивоНаОбразованиеTextBox" runat="server" Text='<%# Bind("НивоНаОбразование") %>' /> |
862 | | <br /> |
863 | | ОстанатоОбразование: |
864 | | <asp:TextBox ID="ОстанатоОбразованиеTextBox" runat="server" Text='<%# Bind("ОстанатоОбразование") %>' /> |
865 | | <br /> |
866 | | ВработенВо: |
867 | | <asp:TextBox ID="ВработенВоTextBox" runat="server" Text='<%# Bind("ВработенВо") %>' /> |
868 | | <br /> |
869 | | РаботнаПозиција: |
870 | | <asp:TextBox ID="РаботнаПозицијаTextBox" runat="server" Text='<%# Bind("РаботнаПозиција") %>' /> |
871 | | <br /> |
872 | | <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" /> |
873 | | <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> |
874 | | </InsertItemTemplate> |
875 | | <ItemTemplate> |
876 | | ИмеПрезиме: |
877 | | <asp:Label ID="ИмеПрезимеLabel" runat="server" Text='<%# Bind("ИмеПрезиме") %>' /> |
878 | | <br /> |
879 | | ДатумНаРаѓање: |
880 | | <asp:Label ID="ДатумНаРаѓањеLabel" runat="server" Text='<%# Bind("ДатумНаРаѓање") %>' /> |
881 | | <br /> |
882 | | МестоНаРаѓање: |
883 | | <asp:Label ID="МестоНаРаѓањеLabel" runat="server" Text='<%# Bind("МестоНаРаѓање") %>' /> |
884 | | <br /> |
885 | | Пол: |
886 | | <asp:Label ID="ПолLabel" runat="server" Text='<%# Bind("Пол") %>' /> |
887 | | <br /> |
888 | | КонтактЕмеил: |
889 | | <asp:Label ID="КонтактЕмеилLabel" runat="server" Text='<%# Bind("КонтактЕмеил") %>' /> |
890 | | <br /> |
891 | | ИмеНаОбразовнаИнституција: |
892 | | <asp:Label ID="ИмеНаОбразовнаИнституцијаLabel" runat="server" Text='<%# Bind("ИмеНаОбразовнаИнституција") %>' /> |
893 | | <br /> |
894 | | НивоНаОбразование: |
895 | | <asp:Label ID="НивоНаОбразованиеLabel" runat="server" Text='<%# Bind("НивоНаОбразование") %>' /> |
896 | | <br /> |
897 | | ОстанатоОбразование: |
898 | | <asp:Label ID="ОстанатоОбразованиеLabel" runat="server" Text='<%# Bind("ОстанатоОбразование") %>' /> |
899 | | <br /> |
900 | | |
901 | | ВработенВо: |
902 | | <asp:Label ID="ВработенВоLabel" runat="server" Text='<%# Bind("ВработенВо") %>' /> |
903 | | <br /> |
904 | | РаботнаПозиција: |
905 | | <asp:Label ID="РаботнаПозицијаLabel" runat="server" Text='<%# Bind("РаботнаПозиција") %>' /> |
906 | | <br /> |
907 | | |
908 | | </ItemTemplate> |
909 | | <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> |
910 | | <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> |
911 | | </asp:FormView> |
912 | | <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT Users.FirstNameLastName AS ИмеПрезиме, Users.DateOfBirth AS ДатумНаРаѓање, Users.PlaceOfBirth AS МестоНаРаѓање, Users.Gender AS Пол, Memberships.Email AS КонтактЕмеил, Users.EducationInstitution AS ИмеНаОбразовнаИнституција, Users.EducationLevel AS НивоНаОбразование, Users.OtherEducation AS ОстанатоОбразование, Users.Employer AS ВработенВо, Users.Position AS РаботнаПозиција FROM Users INNER JOIN Memberships ON Users.UserId = Memberships.UserId WHERE (Users.UserName = @UserName)"> |
913 | | <SelectParameters> |
914 | | <asp:ControlParameter ControlID="lblUsername" Name="UserName" PropertyName="Text" /> |
915 | | </SelectParameters> |
916 | | </asp:SqlDataSource> |
917 | | </p> |
918 | | <p> |
919 | | </p> |
920 | | |
921 | | |
922 | | <h3>Листа на активности:</h3> |
923 | | <p> |
924 | | <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT Activities.Name as ИмеНаАктивноста, Activities.Category as ТипКатегоријаНаАктивноста, Activities.Place as МестоНаОдржувањеОбјава, Activities.Date as Датум, UsersOnActivities.NameOfRole as Улога FROM Activities INNER JOIN UsersOnActivities ON Activities.ActivityID = UsersOnActivities.ActivityID INNER JOIN Users ON UsersOnActivities.UserID = Users.UserId and Users.UserName=@UserName"> |
925 | | <SelectParameters> |
926 | | <asp:ControlParameter ControlID="lblUsername" Name="UserName" PropertyName="Text" /> |
927 | | </SelectParameters> |
928 | | </asp:SqlDataSource> |
929 | | </p> |
930 | | <p hidden="hidden"> |
931 | | </p> |
932 | | <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" > |
933 | | <AlternatingItemTemplate> |
934 | | <span style="background-color: #FFF8DC;">ИмеНаАктивноста: |
935 | | <asp:Label ID="ИмеНаАктивностаLabel" runat="server" Text='<%# Eval("ИмеНаАктивноста") %>' /> |
936 | | <br /> |
937 | | ТипКатегоријаНаАктивноста: |
938 | | <asp:Label ID="ТипКатегоријаНаАктивностаLabel" runat="server" Text='<%# Eval("ТипКатегоријаНаАктивноста") %>' /> |
939 | | <br /> |
940 | | МестоНаОдржувањеОбјава: |
941 | | <asp:Label ID="МестоНаОдржувањеОбјаваLabel" runat="server" Text='<%# Eval("МестоНаОдржувањеОбјава") %>' /> |
942 | | <br /> |
943 | | Датум: |
944 | | <asp:Label ID="ДатумLabel" runat="server" Text='<%# Eval("Датум") %>' /> |
945 | | <br /> |
946 | | Улога: |
947 | | <asp:Label ID="УлогаLabel" runat="server" Text='<%# Eval("Улога") %>' /> |
948 | | <br /> |
949 | | <br /> |
950 | | </span> |
951 | | </AlternatingItemTemplate> |
952 | | <EditItemTemplate> |
953 | | <span style="background-color: #008A8C;color: #FFFFFF;">ИмеНаАктивноста: |
954 | | <asp:TextBox ID="ИмеНаАктивностаTextBox" runat="server" Text='<%# Bind("ИмеНаАктивноста") %>' /> |
955 | | <br /> |
956 | | ТипКатегоријаНаАктивноста: |
957 | | <asp:TextBox ID="ТипКатегоријаНаАктивностаTextBox" runat="server" Text='<%# Bind("ТипКатегоријаНаАктивноста") %>' /> |
958 | | <br /> |
959 | | МестоНаОдржувањеОбјава: |
960 | | <asp:TextBox ID="МестоНаОдржувањеОбјаваTextBox" runat="server" Text='<%# Bind("МестоНаОдржувањеОбјава") %>' /> |
961 | | <br /> |
962 | | Датум: |
963 | | <asp:TextBox ID="ДатумTextBox" runat="server" Text='<%# Bind("Датум") %>' /> |
964 | | <br /> |
965 | | Улога: |
966 | | <asp:TextBox ID="УлогаTextBox" runat="server" Text='<%# Bind("Улога") %>' /> |
967 | | <br /> |
968 | | <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /> |
969 | | <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" /> |
970 | | <br /> |
971 | | <br /> |
972 | | </span> |
973 | | </EditItemTemplate> |
974 | | <EmptyDataTemplate> |
975 | | <span>Листата со активности е празна.</span> |
976 | | </EmptyDataTemplate> |
977 | | <InsertItemTemplate> |
978 | | <span style="">ИмеНаАктивноста: |
979 | | <asp:TextBox ID="ИмеНаАктивностаTextBox" runat="server" Text='<%# Bind("ИмеНаАктивноста") %>' /> |
980 | | <br /> |
981 | | ТипКатегоријаНаАктивноста: |
982 | | <asp:TextBox ID="ТипКатегоријаНаАктивностаTextBox" runat="server" Text='<%# Bind("ТипКатегоријаНаАктивноста") %>' /> |
983 | | <br /> |
984 | | МестоНаОдржувањеОбјава: |
985 | | <asp:TextBox ID="МестоНаОдржувањеОбјаваTextBox" runat="server" Text='<%# Bind("МестоНаОдржувањеОбјава") %>' /> |
986 | | <br /> |
987 | | Датум: |
988 | | <asp:TextBox ID="ДатумTextBox" runat="server" Text='<%# Bind("Датум") %>' /> |
989 | | <br /> |
990 | | Улога: |
991 | | <asp:TextBox ID="УлогаTextBox" runat="server" Text='<%# Bind("Улога") %>' /> |
992 | | <br /> |
993 | | <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" /> |
994 | | <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" /> |
995 | | <br /> |
996 | | <br /> |
997 | | </span> |
998 | | </InsertItemTemplate> |
999 | | <ItemTemplate> |
1000 | | <span style="background-color: #DCDCDC;color: #000000;">ИмеНаАктивноста: |
1001 | | <asp:Label ID="ИмеНаАктивностаLabel" runat="server" Text='<%# Eval("ИмеНаАктивноста") %>' /> |
1002 | | <br /> |
1003 | | ТипКатегоријаНаАктивноста: |
1004 | | <asp:Label ID="ТипКатегоријаНаАктивностаLabel" runat="server" Text='<%# Eval("ТипКатегоријаНаАктивноста") %>' /> |
1005 | | <br /> |
1006 | | МестоНаОдржувањеОбјава: |
1007 | | <asp:Label ID="МестоНаОдржувањеОбјаваLabel" runat="server" Text='<%# Eval("МестоНаОдржувањеОбјава") %>' /> |
1008 | | <br /> |
1009 | | Датум: |
1010 | | <asp:Label ID="ДатумLabel" runat="server" Text='<%# Eval("Датум") %>' /> |
1011 | | <br /> |
1012 | | Улога: |
1013 | | <asp:Label ID="УлогаLabel" runat="server" Text='<%# Eval("Улога") %>' /> |
1014 | | <br /> |
1015 | | <br /> |
1016 | | </span> |
1017 | | </ItemTemplate> |
1018 | | <LayoutTemplate> |
1019 | | <div id="itemPlaceholderContainer" runat="server" style="font-family: Verdana, Arial, Helvetica, sans-serif;"> |
1020 | | <span runat="server" id="itemPlaceholder" /> |
1021 | | </div> |
1022 | | <div style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;"> |
1023 | | <asp:DataPager ID="DataPager1" runat="server"> |
1024 | | <Fields> |
1025 | | <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" FirstPageText="Прва" /> |
1026 | | <asp:NumericPagerField /> |
1027 | | <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" LastPageText="Последна" /> |
1028 | | </Fields> |
1029 | | </asp:DataPager> |
1030 | | </div> |
1031 | | </LayoutTemplate> |
1032 | | <SelectedItemTemplate> |
1033 | | <span style="background-color: #008A8C;font-weight: bold;color: #FFFFFF;">ИмеНаАктивноста: |
1034 | | <asp:Label ID="ИмеНаАктивностаLabel" runat="server" Text='<%# Eval("ИмеНаАктивноста") %>' /> |
1035 | | <br /> |
1036 | | ТипКатегоријаНаАктивноста: |
1037 | | <asp:Label ID="ТипКатегоријаНаАктивностаLabel" runat="server" Text='<%# Eval("ТипКатегоријаНаАктивноста") %>' /> |
1038 | | <br /> |
1039 | | МестоНаОдржувањеОбјава: |
1040 | | <asp:Label ID="МестоНаОдржувањеОбјаваLabel" runat="server" Text='<%# Eval("МестоНаОдржувањеОбјава") %>' /> |
1041 | | <br /> |
1042 | | Датум: |
1043 | | <asp:Label ID="ДатумLabel" runat="server" Text='<%# Eval("Датум") %>' /> |
1044 | | <br /> |
1045 | | Улога: |
1046 | | <asp:Label ID="УлогаLabel" runat="server" Text='<%# Eval("Улога") %>' /> |
1047 | | <br /> |
1048 | | <br /> |
1049 | | </span> |
1050 | | </SelectedItemTemplate> |
1051 | | </asp:ListView> |
1052 | | </asp:Content> |
1053 | | <asp:Content ID="Content1" runat="server" contentplaceholderid="HeadContent"> |
1054 | | <style type="text/css"> |
1055 | | .auto-style1 { |
1056 | | width: 100%; |
1057 | | } |
1058 | | .auto-style2 { |
1059 | | width: 528px; |
1060 | | } |
1061 | | </style> |
1062 | | </asp:Content> |
1063 | | |
1064 | | }}} |
1065 | | |
1066 | | '''Прототип на апликацијата направена со Naked Objects во ASP.Net''' |
1067 | | |
1068 | | '''User.cs''' |
1069 | | {{{ |
1070 | | #!c# |
1071 | | using NakedObjects; |
1072 | | using System; |
1073 | | using System.Collections.Generic; |
1074 | | using System.ComponentModel.DataAnnotations; |
1075 | | using System.Linq; |
1076 | | using System.Text; |
1077 | | using System.Threading.Tasks; |
1078 | | |
1079 | | namespace CoDBIS_NakedObjects |
1080 | | { |
1081 | | public class User |
1082 | | { |
1083 | | public override string ToString() |
1084 | | { |
1085 | | return Name; |
1086 | | } |
1087 | | |
1088 | | |
1089 | | [Hidden] |
1090 | | public virtual int Id { get; set; } |
1091 | | |
1092 | | [StringLength (50)] |
1093 | | public virtual string Name { get; set; } |
1094 | | |
1095 | | |
1096 | | public virtual string Gender { get; set; } |
1097 | | |
1098 | | |
1099 | | public virtual string PlaceOfBirth { get; set; } |
1100 | | |
1101 | | [Mask("d")] |
1102 | | public virtual DateTime DateOfBirth { get; set; } |
1103 | | |
1104 | | |
1105 | | public virtual string Email { get; set; } |
1106 | | |
1107 | | |
1108 | | public virtual string Employer { get; set; } |
1109 | | |
1110 | | |
1111 | | public virtual string Position { get; set; } |
1112 | | |
1113 | | public IDomainObjectContainer Container { set; protected get; } |
1114 | | |
1115 | | |
1116 | | #region AddActivity (collection) |
1117 | | private ICollection<AddUserOnActivity> _AddActivity = new List<AddUserOnActivity>(); |
1118 | | |
1119 | | public virtual ICollection<AddUserOnActivity> AddActivity |
1120 | | { |
1121 | | get |
1122 | | { |
1123 | | return _AddActivity; |
1124 | | } |
1125 | | set |
1126 | | { |
1127 | | _AddActivity = value; |
1128 | | } |
1129 | | } |
1130 | | |
1131 | | public void AddToAddActivity(AddUserOnActivity value) |
1132 | | { |
1133 | | if (!(_AddActivity.Contains(value))) |
1134 | | { |
1135 | | _AddActivity.Add(value); |
1136 | | } |
1137 | | } |
1138 | | |
1139 | | |
1140 | | public void RemoveFromAddActivity(AddUserOnActivity value) |
1141 | | { |
1142 | | if (_AddActivity.Contains(value)) |
1143 | | { |
1144 | | _AddActivity.Remove(value); |
1145 | | } |
1146 | | } |
1147 | | |
1148 | | public IList<AddUserOnActivity> Choices0RemoveFromAddActivity() |
1149 | | { |
1150 | | return _AddActivity.ToList(); |
1151 | | } |
1152 | | #endregion |
1153 | | |
1154 | | public AddUserOnActivity CreateNewUserOnActivity() //CreateNewOrder od tip Order |
1155 | | { |
1156 | | |
1157 | | var order = Container.NewTransientInstance<AddUserOnActivity>(); |
1158 | | order.User = this; |
1159 | | return order; |
1160 | | } |
1161 | | |
1162 | | |
1163 | | |
1164 | | |
1165 | | public AddUserOnActivity CreateNewAddUserOnActivity() |
1166 | | { |
1167 | | AddUserOnActivity obj = Container.NewTransientInstance<AddUserOnActivity>(); |
1168 | | |
1169 | | obj.User = this; |
1170 | | return obj; |
1171 | | } |
1172 | | |
1173 | | |
1174 | | |
1175 | | } |
1176 | | } |
1177 | | }}} |
1178 | | |
1179 | | '''Activity.cs''' |
1180 | | {{{ |
1181 | | #!c# |
1182 | | using NakedObjects; |
1183 | | using System; |
1184 | | using System.Collections.Generic; |
1185 | | using System.ComponentModel.DataAnnotations; |
1186 | | using System.Linq; |
1187 | | using System.Text; |
1188 | | using System.Threading.Tasks; |
1189 | | |
1190 | | namespace CoDBIS_NakedObjects |
1191 | | { |
1192 | | public class Activity |
1193 | | { |
1194 | | public override string ToString() |
1195 | | { |
1196 | | return Name; |
1197 | | } |
1198 | | |
1199 | | [Hidden] |
1200 | | public virtual int Id { get; set; } |
1201 | | |
1202 | | |
1203 | | [StringLength (50), Title] |
1204 | | public virtual string Name { get; set; } |
1205 | | |
1206 | | |
1207 | | public virtual string Place { get; set; } |
1208 | | |
1209 | | // [Title, Mask("d")] |
1210 | | public virtual DateTime Date { get; set; } |
1211 | | |
1212 | | |
1213 | | public virtual string Category { get; set; } |
1214 | | |
1215 | | } |
1216 | | } |
1217 | | }}} |
1218 | | |
1219 | | '''Activityhistory.cs''' |
1220 | | {{{ |
1221 | | #!c# |
1222 | | using NakedObjects; |
1223 | | using System; |
1224 | | using System.Collections.Generic; |
1225 | | using System.ComponentModel; |
1226 | | using System.Linq; |
1227 | | using System.Text; |
1228 | | using System.Threading.Tasks; |
1229 | | |
1230 | | namespace CoDBIS_NakedObjects |
1231 | | { |
1232 | | public class ActivityHistory |
1233 | | { |
1234 | | |
1235 | | public override string ToString() |
1236 | | { |
1237 | | return Role.ToString() + " на " + Activity; |
1238 | | } |
1239 | | |
1240 | | [Hidden] |
1241 | | public virtual int Id { get; set; } |
1242 | | |
1243 | | [Hidden] |
1244 | | public virtual AddUserOnActivity AddUserOnActivity { get; set; } |
1245 | | |
1246 | | |
1247 | | public virtual Activity Activity { get; set; } |
1248 | | |
1249 | | [DefaultValue("")] |
1250 | | public virtual string Role { get; set; } |
1251 | | |
1252 | | } |
1253 | | } |
1254 | | }}} |
1255 | | |
1256 | | '''Adduseronactivity.cs''' |
1257 | | {{{ |
1258 | | #!c# |
1259 | | using NakedObjects; |
1260 | | using System; |
1261 | | using System.Collections.Generic; |
1262 | | using System.Linq; |
1263 | | using System.Text; |
1264 | | using System.Threading.Tasks; |
1265 | | |
1266 | | namespace CoDBIS_NakedObjects |
1267 | | { |
1268 | | public class AddUserOnActivity |
1269 | | { |
1270 | | |
1271 | | public override string ToString() |
1272 | | { |
1273 | | return User.ToString(); |
1274 | | } |
1275 | | |
1276 | | [Hidden] |
1277 | | public virtual int Id { get; set; } |
1278 | | |
1279 | | [Disabled] |
1280 | | public virtual User User { get; set; } |
1281 | | |
1282 | | |
1283 | | |
1284 | | #region History (collection) |
1285 | | private ICollection<ActivityHistory> _History = new List<ActivityHistory>(); |
1286 | | |
1287 | | public virtual ICollection<ActivityHistory> History |
1288 | | { |
1289 | | get |
1290 | | { |
1291 | | return _History; |
1292 | | } |
1293 | | set |
1294 | | { |
1295 | | _History = value; |
1296 | | } |
1297 | | } |
1298 | | |
1299 | | public void AddToHistory(ActivityHistory value) |
1300 | | { |
1301 | | if (!(_History.Contains(value))) |
1302 | | { |
1303 | | _History.Add(value); |
1304 | | } |
1305 | | } |
1306 | | |
1307 | | public void RemoveFromHistory(ActivityHistory value) |
1308 | | { |
1309 | | if (_History.Contains(value)) |
1310 | | { |
1311 | | _History.Remove(value); |
1312 | | } |
1313 | | } |
1314 | | |
1315 | | public IList<ActivityHistory> Choices0RemoveFromHistory() |
1316 | | { |
1317 | | return _History.ToList(); |
1318 | | } |
1319 | | #endregion |
1320 | | |
1321 | | |
1322 | | public IDomainObjectContainer Container { set; protected get; } |
1323 | | |
1324 | | |
1325 | | public ActivityHistory AddToHistory() |
1326 | | { |
1327 | | |
1328 | | var history = Container.NewTransientInstance<ActivityHistory>(); |
1329 | | history.AddUserOnActivity = this; |
1330 | | return history; |
1331 | | } |
1332 | | |
1333 | | |
1334 | | public ActivityHistory CreateNewActivityHistory() |
1335 | | { |
1336 | | ActivityHistory obj = Container.NewTransientInstance<ActivityHistory>(); |
1337 | | |
1338 | | obj.AddUserOnActivity = this; |
1339 | | return obj; |
1340 | | } |
1341 | | |
1342 | | |
1343 | | |
1344 | | } |
1345 | | } |
1346 | | }}} |
1347 | | |
1348 | | '''Mydbcontext.cs''' |
1349 | | {{{ |
1350 | | #!c# |
1351 | | using System; |
1352 | | using System.Collections.Generic; |
1353 | | using System.Data.Entity; |
1354 | | using System.Linq; |
1355 | | using System.Text; |
1356 | | using System.Threading.Tasks; |
1357 | | |
1358 | | namespace CoDBIS_NakedObjects |
1359 | | { |
1360 | | public class MyDbContext : DbContext |
1361 | | { |
1362 | | public MyDbContext(String name) : base(name) { } |
1363 | | public MyDbContext() { } |
1364 | | public DbSet<User> Users { get; set; } |
1365 | | |
1366 | | } |
1367 | | } |
1368 | | }}} |
1369 | | |
1370 | | '''Userrepository.cs''' |
1371 | | {{{ |
1372 | | #!c# |
1373 | | using NakedObjects; |
1374 | | using System; |
1375 | | using System.Collections.Generic; |
1376 | | using System.ComponentModel; |
1377 | | using System.Linq; |
1378 | | using System.Text; |
1379 | | using System.Threading.Tasks; |
1380 | | |
1381 | | namespace CoDBIS_NakedObjects |
1382 | | { |
1383 | | |
1384 | | [DisplayName("Users")] |
1385 | | public class UserRepository |
1386 | | { |
1387 | | |
1388 | | public IDomainObjectContainer Container { set; protected get; } |
1389 | | |
1390 | | public IQueryable<User> AllUsers() |
1391 | | { |
1392 | | return Container.Instances<User>(); |
1393 | | } |
1394 | | |
1395 | | |
1396 | | public User CreateNewUser() |
1397 | | { |
1398 | | User obj = Container.NewTransientInstance<User>(); |
1399 | | //set up any parameters |
1400 | | //Container.Persist(ref obj); |
1401 | | return obj; |
1402 | | } |
1403 | | |
1404 | | |
1405 | | #region Find |
1406 | | public User Find(string searchString) |
1407 | | { |
1408 | | var query = from obj in Container.Instances<User>() |
1409 | | where obj.Name.ToUpper().Contains(searchString.ToUpper()) |
1410 | | select obj; |
1411 | | |
1412 | | return query.FirstOrDefault(); |
1413 | | //(If inheriting from AbsractFactoryAndRepository can use:) return SingleObjectWarnIfNoMatch(query); |
1414 | | } |
1415 | | #endregion |
1416 | | |
1417 | | |
1418 | | } |
1419 | | } |
1420 | | }}} |
1421 | | |
1422 | | |
1423 | | |
1424 | | '''Activityrepository.cs''' |
1425 | | {{{ |
1426 | | #!c# |
1427 | | using NakedObjects; |
1428 | | using System; |
1429 | | using System.Collections.Generic; |
1430 | | using System.ComponentModel; |
1431 | | using System.Linq; |
1432 | | using System.Text; |
1433 | | using System.Threading.Tasks; |
1434 | | |
1435 | | namespace CoDBIS_NakedObjects |
1436 | | { |
1437 | | [DisplayName("Activities")] |
1438 | | public class ActivityRepository |
1439 | | { |
1440 | | public IDomainObjectContainer Container { set; protected get; } |
1441 | | |
1442 | | |
1443 | | public IQueryable<Activity> AllActivitys() |
1444 | | { |
1445 | | return Container.Instances<Activity>(); |
1446 | | } |
1447 | | |
1448 | | |
1449 | | public Activity CreateNewActivity() |
1450 | | { |
1451 | | Activity obj = Container.NewTransientInstance<Activity>(); |
1452 | | //set up any parameters |
1453 | | //Container.Persist(ref obj); |
1454 | | return obj; |
1455 | | } |
1456 | | |
1457 | | |
1458 | | #region Find |
1459 | | public Activity Find(string name ) |
1460 | | { |
1461 | | var query = from obj in Container.Instances<Activity>() |
1462 | | where obj.Name.ToUpper().Contains(name.ToUpper()) |
1463 | | select obj; |
1464 | | |
1465 | | return query.FirstOrDefault(); |
1466 | | //(If inheriting from AbsractFactoryAndRepository can use:) return SingleObjectWarnIfNoMatch(query); |
1467 | | } |
1468 | | #endregion |
1469 | | |
1470 | | } |
1471 | | } |
1472 | | |
1473 | | }}} |
1474 | | |
1475 | | '''Runweb.cs''' |
1476 | | {{{ |
1477 | | #!c# |
1478 | | using CoDBIS_NakedObjects; |
1479 | | using NakedObjects.Boot; |
1480 | | using NakedObjects.Core.Context; |
1481 | | using NakedObjects.Core.NakedObjectsSystem; |
1482 | | using NakedObjects.EntityObjectStore; |
1483 | | using NakedObjects.Services; |
1484 | | using NakedObjects.Web.Mvc; |
1485 | | using NakedObjects.Web.Mvc.Helpers; |
1486 | | using System.Data.Entity; |
1487 | | using System.Data.Entity.Infrastructure; |
1488 | | |
1489 | | |
1490 | | namespace CoDBIS_MVC.App_Start { |
1491 | | public class RunWeb : RunMvc { |
1492 | | protected override NakedObjectsContext Context { |
1493 | | get { return HttpContextContext.CreateInstance(); } |
1494 | | } |
1495 | | |
1496 | | protected override IServicesInstaller MenuServices { |
1497 | | get { |
1498 | | return new ServicesInstaller( new UserRepository(), new ActivityRepository()); |
1499 | | } |
1500 | | } |
1501 | | |
1502 | | protected override IServicesInstaller ContributedActions { |
1503 | | get { return new ServicesInstaller(); } |
1504 | | } |
1505 | | |
1506 | | protected override IServicesInstaller SystemServices { |
1507 | | get { return new ServicesInstaller(new SimpleEncryptDecrypt()); } |
1508 | | } |
1509 | | |
1510 | | |
1511 | | // example functions that gets types for AssociateTypes below |
1512 | | //private static Type[] AdventureWorksTypes() { |
1513 | | // var allTypes = AppDomain.CurrentDomain.GetAssemblies().Single(a => a.GetName().Name == "AdventureWorksModel").GetTypes(); |
1514 | | // return allTypes.Where(t => t.BaseType == typeof(AWDomainObject) && !t.IsAbstract).ToArray(); |
1515 | | //} |
1516 | | // |
1517 | | //private static Type[] CodeFirstTypes() { |
1518 | | // return new[] {typeof(Class1), typeof(Class2)}; |
1519 | | //} |
1520 | | |
1521 | | protected override IObjectPersistorInstaller Persistor |
1522 | | { |
1523 | | get |
1524 | | { |
1525 | | Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0"); //For in-memory database |
1526 | | Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyDbContext>()); //Optional behaviour for CodeFirst |
1527 | | var installer = new EntityPersistorInstaller(); |
1528 | | |
1529 | | //installer.UsingEdmxContext("Model").AssociateTypes(AdventureWorksTypes); // for Model/Database First |
1530 | | installer.AddCodeFirstDbContextConstructor(() => new MyDbContext()); //For Code First |
1531 | | |
1532 | | return installer; |
1533 | | } |
1534 | | } |
1535 | | |
1536 | | public static void Run() { |
1537 | | new RunWeb().Start(); |
1538 | | } |
1539 | | } |
1540 | | } |
1541 | | }}} |
1542 | | |
1543 | | '''Тестирање на апликацијата со Selenium IDE''' |
1544 | | |
1545 | | Тестовите се експортирани како C#/NUnit/Web Driver. |
1546 | | |
1547 | | '''Register.cs''' |
1548 | | {{{ |
1549 | | using System; |
1550 | | using System.Text; |
1551 | | using System.Text.RegularExpressions; |
1552 | | using System.Threading; |
1553 | | using NUnit.Framework; |
1554 | | using OpenQA.Selenium; |
1555 | | using OpenQA.Selenium.Firefox; |
1556 | | using OpenQA.Selenium.Support.UI; |
1557 | | |
1558 | | namespace SeleniumTests |
1559 | | { |
1560 | | [TestFixture] |
1561 | | public class Register |
1562 | | { |
1563 | | private IWebDriver driver; |
1564 | | private StringBuilder verificationErrors; |
1565 | | private string baseURL; |
1566 | | private bool acceptNextAlert = true; |
1567 | | |
1568 | | [SetUp] |
1569 | | public void SetupTest() |
1570 | | { |
1571 | | driver = new FirefoxDriver(); |
1572 | | baseURL = "http://localhost:1400/"; |
1573 | | verificationErrors = new StringBuilder(); |
1574 | | } |
1575 | | |
1576 | | [TearDown] |
1577 | | public void TeardownTest() |
1578 | | { |
1579 | | try |
1580 | | { |
1581 | | driver.Quit(); |
1582 | | } |
1583 | | catch (Exception) |
1584 | | { |
1585 | | // Ignore errors if unable to close the browser |
1586 | | } |
1587 | | Assert.AreEqual("", verificationErrors.ToString()); |
1588 | | } |
1589 | | |
1590 | | [Test] |
1591 | | public void TheRegisterTest() |
1592 | | { |
1593 | | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
1594 | | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
1595 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
1596 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("novstudent3"); |
1597 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
1598 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("novstudent1@mail.com"); |
1599 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
1600 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("novstudent"); |
1601 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
1602 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("novstudent"); |
1603 | | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
1604 | | driver.FindElement(By.Id("MainContent_txtImePrezime")).Clear(); |
1605 | | driver.FindElement(By.Id("MainContent_txtImePrezime")).SendKeys("Student Nov"); |
1606 | | driver.FindElement(By.Id("MainContent_txtMesto")).Clear(); |
1607 | | driver.FindElement(By.Id("MainContent_txtMesto")).SendKeys("New York"); |
1608 | | driver.FindElement(By.Id("MainContent_txtDatum")).Clear(); |
1609 | | driver.FindElement(By.Id("MainContent_txtDatum")).SendKeys("01-08-1990"); |
1610 | | driver.FindElement(By.Id("MainContent_txtObrazovanie")).Clear(); |
1611 | | driver.FindElement(By.Id("MainContent_txtObrazovanie")).SendKeys("BS"); |
1612 | | driver.FindElement(By.Id("MainContent_txtInstitucija")).Clear(); |
1613 | | driver.FindElement(By.Id("MainContent_txtInstitucija")).SendKeys("Proba"); |
1614 | | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).Clear(); |
1615 | | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).SendKeys("Proba"); |
1616 | | driver.FindElement(By.Id("MainContent_txtPozicija")).Clear(); |
1617 | | driver.FindElement(By.Id("MainContent_txtPozicija")).SendKeys("Proba"); |
1618 | | driver.FindElement(By.Id("MainContent_btnAdd")).Click(); |
1619 | | driver.FindElement(By.Id("MainContent_Button2")).Click(); |
1620 | | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
1621 | | driver.FindElement(By.Id("MainContent_txtActivity")).Clear(); |
1622 | | driver.FindElement(By.Id("MainContent_txtActivity")).SendKeys("rrr"); |
1623 | | driver.FindElement(By.Id("MainContent_btnShow")).Click(); |
1624 | | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).Clear(); |
1625 | | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).SendKeys("uuu"); |
1626 | | driver.FindElement(By.Id("MainContent_gvMe_CheckBox1_0")).Click(); |
1627 | | driver.FindElement(By.Id("MainContent_btnAddMe")).Click(); |
1628 | | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
1629 | | } |
1630 | | private bool IsElementPresent(By by) |
1631 | | { |
1632 | | try |
1633 | | { |
1634 | | driver.FindElement(by); |
1635 | | return true; |
1636 | | } |
1637 | | catch (NoSuchElementException) |
1638 | | { |
1639 | | return false; |
1640 | | } |
1641 | | } |
1642 | | |
1643 | | private bool IsAlertPresent() |
1644 | | { |
1645 | | try |
1646 | | { |
1647 | | driver.SwitchTo().Alert(); |
1648 | | return true; |
1649 | | } |
1650 | | catch (NoAlertPresentException) |
1651 | | { |
1652 | | return false; |
1653 | | } |
1654 | | } |
1655 | | |
1656 | | private string CloseAlertAndGetItsText() { |
1657 | | try { |
1658 | | IAlert alert = driver.SwitchTo().Alert(); |
1659 | | string alertText = alert.Text; |
1660 | | if (acceptNextAlert) { |
1661 | | alert.Accept(); |
1662 | | } else { |
1663 | | alert.Dismiss(); |
1664 | | } |
1665 | | return alertText; |
1666 | | } finally { |
1667 | | acceptNextAlert = true; |
1668 | | } |
1669 | | } |
1670 | | } |
1671 | | } |
1672 | | }}} |
1673 | | |
1674 | | |
1675 | | '''LoginFieldValidation.cs''' |
1676 | | |
1677 | | {{{ |
1678 | | using System; |
1679 | | using System.Text; |
1680 | | using System.Text.RegularExpressions; |
1681 | | using System.Threading; |
1682 | | using NUnit.Framework; |
1683 | | using OpenQA.Selenium; |
1684 | | using OpenQA.Selenium.Firefox; |
1685 | | using OpenQA.Selenium.Support.UI; |
1686 | | |
1687 | | namespace SeleniumTests |
1688 | | { |
1689 | | [TestFixture] |
1690 | | public class LoginFieldValidation |
1691 | | { |
1692 | | private IWebDriver driver; |
1693 | | private StringBuilder verificationErrors; |
1694 | | private string baseURL; |
1695 | | private bool acceptNextAlert = true; |
1696 | | |
1697 | | [SetUp] |
1698 | | public void SetupTest() |
1699 | | { |
1700 | | driver = new FirefoxDriver(); |
1701 | | baseURL = "http://localhost:1400/"; |
1702 | | verificationErrors = new StringBuilder(); |
1703 | | } |
1704 | | |
1705 | | [TearDown] |
1706 | | public void TeardownTest() |
1707 | | { |
1708 | | try |
1709 | | { |
1710 | | driver.Quit(); |
1711 | | } |
1712 | | catch (Exception) |
1713 | | { |
1714 | | // Ignore errors if unable to close the browser |
1715 | | } |
1716 | | Assert.AreEqual("", verificationErrors.ToString()); |
1717 | | } |
1718 | | |
1719 | | [Test] |
1720 | | public void TheLoginFieldValidationTest() |
1721 | | { |
1722 | | driver.Navigate().GoToUrl(baseURL + "/"); |
1723 | | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
1724 | | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
1725 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
1726 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
1727 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
1728 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("aaa"); |
1729 | | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
1730 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
1731 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student12"); |
1732 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
1733 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1233"); |
1734 | | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
1735 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
1736 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
1737 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
1738 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
1739 | | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
1740 | | } |
1741 | | private bool IsElementPresent(By by) |
1742 | | { |
1743 | | try |
1744 | | { |
1745 | | driver.FindElement(by); |
1746 | | return true; |
1747 | | } |
1748 | | catch (NoSuchElementException) |
1749 | | { |
1750 | | return false; |
1751 | | } |
1752 | | } |
1753 | | |
1754 | | private bool IsAlertPresent() |
1755 | | { |
1756 | | try |
1757 | | { |
1758 | | driver.SwitchTo().Alert(); |
1759 | | return true; |
1760 | | } |
1761 | | catch (NoAlertPresentException) |
1762 | | { |
1763 | | return false; |
1764 | | } |
1765 | | } |
1766 | | |
1767 | | private string CloseAlertAndGetItsText() { |
1768 | | try { |
1769 | | IAlert alert = driver.SwitchTo().Alert(); |
1770 | | string alertText = alert.Text; |
1771 | | if (acceptNextAlert) { |
1772 | | alert.Accept(); |
1773 | | } else { |
1774 | | alert.Dismiss(); |
1775 | | } |
1776 | | return alertText; |
1777 | | } finally { |
1778 | | acceptNextAlert = true; |
1779 | | } |
1780 | | } |
1781 | | } |
1782 | | } |
1783 | | }}} |
1784 | | |
1785 | | '''Registerfieldvalidation.cs''' |
1786 | | {{{ |
1787 | | using System; |
1788 | | using System.Text; |
1789 | | using System.Text.RegularExpressions; |
1790 | | using System.Threading; |
1791 | | using NUnit.Framework; |
1792 | | using OpenQA.Selenium; |
1793 | | using OpenQA.Selenium.Firefox; |
1794 | | using OpenQA.Selenium.Support.UI; |
1795 | | |
1796 | | namespace SeleniumTests |
1797 | | { |
1798 | | [TestFixture] |
1799 | | public class RegisterFieldValidation |
1800 | | { |
1801 | | private IWebDriver driver; |
1802 | | private StringBuilder verificationErrors; |
1803 | | private string baseURL; |
1804 | | private bool acceptNextAlert = true; |
1805 | | |
1806 | | [SetUp] |
1807 | | public void SetupTest() |
1808 | | { |
1809 | | driver = new FirefoxDriver(); |
1810 | | baseURL = "http://localhost:1400/"; |
1811 | | verificationErrors = new StringBuilder(); |
1812 | | } |
1813 | | |
1814 | | [TearDown] |
1815 | | public void TeardownTest() |
1816 | | { |
1817 | | try |
1818 | | { |
1819 | | driver.Quit(); |
1820 | | } |
1821 | | catch (Exception) |
1822 | | { |
1823 | | // Ignore errors if unable to close the browser |
1824 | | } |
1825 | | Assert.AreEqual("", verificationErrors.ToString()); |
1826 | | } |
1827 | | |
1828 | | [Test] |
1829 | | public void TheRegisterFieldValidationTest() |
1830 | | { |
1831 | | driver.Navigate().GoToUrl(baseURL + "/"); |
1832 | | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
1833 | | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
1834 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
1835 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abc"); |
1836 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
1837 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("abc@mail.com"); |
1838 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
1839 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("abcabc1"); |
1840 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
1841 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abcabc1"); |
1842 | | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
1843 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
1844 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abcde"); |
1845 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
1846 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("abcdefg1"); |
1847 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
1848 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abvv"); |
1849 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
1850 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abcdefg1"); |
1851 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
1852 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abcdefg"); |
1853 | | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
1854 | | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
1855 | | } |
1856 | | private bool IsElementPresent(By by) |
1857 | | { |
1858 | | try |
1859 | | { |
1860 | | driver.FindElement(by); |
1861 | | return true; |
1862 | | } |
1863 | | catch (NoSuchElementException) |
1864 | | { |
1865 | | return false; |
1866 | | } |
1867 | | } |
1868 | | |
1869 | | private bool IsAlertPresent() |
1870 | | { |
1871 | | try |
1872 | | { |
1873 | | driver.SwitchTo().Alert(); |
1874 | | return true; |
1875 | | } |
1876 | | catch (NoAlertPresentException) |
1877 | | { |
1878 | | return false; |
1879 | | } |
1880 | | } |
1881 | | |
1882 | | private string CloseAlertAndGetItsText() { |
1883 | | try { |
1884 | | IAlert alert = driver.SwitchTo().Alert(); |
1885 | | string alertText = alert.Text; |
1886 | | if (acceptNextAlert) { |
1887 | | alert.Accept(); |
1888 | | } else { |
1889 | | alert.Dismiss(); |
1890 | | } |
1891 | | return alertText; |
1892 | | } finally { |
1893 | | acceptNextAlert = true; |
1894 | | } |
1895 | | } |
1896 | | } |
1897 | | } |
1898 | | }}} |
1899 | | |
1900 | | '''Search.cs''' |
1901 | | {{{ |
1902 | | using System; |
1903 | | using System.Text; |
1904 | | using System.Text.RegularExpressions; |
1905 | | using System.Threading; |
1906 | | using NUnit.Framework; |
1907 | | using OpenQA.Selenium; |
1908 | | using OpenQA.Selenium.Firefox; |
1909 | | using OpenQA.Selenium.Support.UI; |
1910 | | |
1911 | | namespace SeleniumTests |
1912 | | { |
1913 | | [TestFixture] |
1914 | | public class Search |
1915 | | { |
1916 | | private IWebDriver driver; |
1917 | | private StringBuilder verificationErrors; |
1918 | | private string baseURL; |
1919 | | private bool acceptNextAlert = true; |
1920 | | |
1921 | | [SetUp] |
1922 | | public void SetupTest() |
1923 | | { |
1924 | | driver = new FirefoxDriver(); |
1925 | | baseURL = "http://localhost:1400/"; |
1926 | | verificationErrors = new StringBuilder(); |
1927 | | } |
1928 | | |
1929 | | [TearDown] |
1930 | | public void TeardownTest() |
1931 | | { |
1932 | | try |
1933 | | { |
1934 | | driver.Quit(); |
1935 | | } |
1936 | | catch (Exception) |
1937 | | { |
1938 | | // Ignore errors if unable to close the browser |
1939 | | } |
1940 | | Assert.AreEqual("", verificationErrors.ToString()); |
1941 | | } |
1942 | | |
1943 | | [Test] |
1944 | | public void TheSearchTest() |
1945 | | { |
1946 | | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
1947 | | driver.FindElement(By.LinkText("Контакт")).Click(); |
1948 | | driver.FindElement(By.Id("txtSearch")).Clear(); |
1949 | | driver.FindElement(By.Id("txtSearch")).SendKeys("IS"); |
1950 | | driver.FindElement(By.Id("btnSearch")).Click(); |
1951 | | driver.FindElement(By.LinkText("Почетна")).Click(); |
1952 | | driver.FindElement(By.Id("txtSearch")).Clear(); |
1953 | | driver.FindElement(By.Id("txtSearch")).SendKeys("IS"); |
1954 | | driver.FindElement(By.Id("btnSearch")).Click(); |
1955 | | } |
1956 | | private bool IsElementPresent(By by) |
1957 | | { |
1958 | | try |
1959 | | { |
1960 | | driver.FindElement(by); |
1961 | | return true; |
1962 | | } |
1963 | | catch (NoSuchElementException) |
1964 | | { |
1965 | | return false; |
1966 | | } |
1967 | | } |
1968 | | |
1969 | | private bool IsAlertPresent() |
1970 | | { |
1971 | | try |
1972 | | { |
1973 | | driver.SwitchTo().Alert(); |
1974 | | return true; |
1975 | | } |
1976 | | catch (NoAlertPresentException) |
1977 | | { |
1978 | | return false; |
1979 | | } |
1980 | | } |
1981 | | |
1982 | | private string CloseAlertAndGetItsText() { |
1983 | | try { |
1984 | | IAlert alert = driver.SwitchTo().Alert(); |
1985 | | string alertText = alert.Text; |
1986 | | if (acceptNextAlert) { |
1987 | | alert.Accept(); |
1988 | | } else { |
1989 | | alert.Dismiss(); |
1990 | | } |
1991 | | return alertText; |
1992 | | } finally { |
1993 | | acceptNextAlert = true; |
1994 | | } |
1995 | | } |
1996 | | } |
1997 | | } |
1998 | | }}} |
1999 | | |
2000 | | '''Changepassword.cs''' |
2001 | | {{{ |
2002 | | using System; |
2003 | | using System.Text; |
2004 | | using System.Text.RegularExpressions; |
2005 | | using System.Threading; |
2006 | | using NUnit.Framework; |
2007 | | using OpenQA.Selenium; |
2008 | | using OpenQA.Selenium.Firefox; |
2009 | | using OpenQA.Selenium.Support.UI; |
2010 | | |
2011 | | namespace SeleniumTests |
2012 | | { |
2013 | | [TestFixture] |
2014 | | public class ChangePassword |
2015 | | { |
2016 | | private IWebDriver driver; |
2017 | | private StringBuilder verificationErrors; |
2018 | | private string baseURL; |
2019 | | private bool acceptNextAlert = true; |
2020 | | |
2021 | | [SetUp] |
2022 | | public void SetupTest() |
2023 | | { |
2024 | | driver = new FirefoxDriver(); |
2025 | | baseURL = "http://localhost:1400/"; |
2026 | | verificationErrors = new StringBuilder(); |
2027 | | } |
2028 | | |
2029 | | [TearDown] |
2030 | | public void TeardownTest() |
2031 | | { |
2032 | | try |
2033 | | { |
2034 | | driver.Quit(); |
2035 | | } |
2036 | | catch (Exception) |
2037 | | { |
2038 | | // Ignore errors if unable to close the browser |
2039 | | } |
2040 | | Assert.AreEqual("", verificationErrors.ToString()); |
2041 | | } |
2042 | | |
2043 | | [Test] |
2044 | | public void TheChangePasswordTest() |
2045 | | { |
2046 | | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
2047 | | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
2048 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
2049 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
2050 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
2051 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
2052 | | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
2053 | | driver.FindElement(By.Id("ctl10_hpLink")).Click(); |
2054 | | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_CurrentPassword")).Clear(); |
2055 | | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_CurrentPassword")).SendKeys("student123"); |
2056 | | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_NewPassword")).Clear(); |
2057 | | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_NewPassword")).SendKeys("student1234"); |
2058 | | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_ConfirmNewPassword")).Clear(); |
2059 | | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_ConfirmNewPassword")).SendKeys("student1234"); |
2060 | | driver.FindElement(By.Name("ctl00$MainContent$ctl07$ChangePasswordContainerID$ctl04")).Click(); |
2061 | | driver.FindElement(By.LinkText("Одјави се")).Click(); |
2062 | | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
2063 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
2064 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
2065 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
2066 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1234"); |
2067 | | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
2068 | | driver.FindElement(By.LinkText("Одјави се")).Click(); |
2069 | | } |
2070 | | private bool IsElementPresent(By by) |
2071 | | { |
2072 | | try |
2073 | | { |
2074 | | driver.FindElement(by); |
2075 | | return true; |
2076 | | } |
2077 | | catch (NoSuchElementException) |
2078 | | { |
2079 | | return false; |
2080 | | } |
2081 | | } |
2082 | | |
2083 | | private bool IsAlertPresent() |
2084 | | { |
2085 | | try |
2086 | | { |
2087 | | driver.SwitchTo().Alert(); |
2088 | | return true; |
2089 | | } |
2090 | | catch (NoAlertPresentException) |
2091 | | { |
2092 | | return false; |
2093 | | } |
2094 | | } |
2095 | | |
2096 | | private string CloseAlertAndGetItsText() { |
2097 | | try { |
2098 | | IAlert alert = driver.SwitchTo().Alert(); |
2099 | | string alertText = alert.Text; |
2100 | | if (acceptNextAlert) { |
2101 | | alert.Accept(); |
2102 | | } else { |
2103 | | alert.Dismiss(); |
2104 | | } |
2105 | | return alertText; |
2106 | | } finally { |
2107 | | acceptNextAlert = true; |
2108 | | } |
2109 | | } |
2110 | | } |
2111 | | } |
2112 | | }}} |
2113 | | |
2114 | | '''Addinfo.cs''' |
2115 | | {{{ |
2116 | | using System; |
2117 | | using System.Text; |
2118 | | using System.Text.RegularExpressions; |
2119 | | using System.Threading; |
2120 | | using NUnit.Framework; |
2121 | | using OpenQA.Selenium; |
2122 | | using OpenQA.Selenium.Firefox; |
2123 | | using OpenQA.Selenium.Support.UI; |
2124 | | |
2125 | | namespace SeleniumTests |
2126 | | { |
2127 | | [TestFixture] |
2128 | | public class AddInfoLater |
2129 | | { |
2130 | | private IWebDriver driver; |
2131 | | private StringBuilder verificationErrors; |
2132 | | private string baseURL; |
2133 | | private bool acceptNextAlert = true; |
2134 | | |
2135 | | [SetUp] |
2136 | | public void SetupTest() |
2137 | | { |
2138 | | driver = new FirefoxDriver(); |
2139 | | baseURL = "http://localhost:1400/"; |
2140 | | verificationErrors = new StringBuilder(); |
2141 | | } |
2142 | | |
2143 | | [TearDown] |
2144 | | public void TeardownTest() |
2145 | | { |
2146 | | try |
2147 | | { |
2148 | | driver.Quit(); |
2149 | | } |
2150 | | catch (Exception) |
2151 | | { |
2152 | | // Ignore errors if unable to close the browser |
2153 | | } |
2154 | | Assert.AreEqual("", verificationErrors.ToString()); |
2155 | | } |
2156 | | |
2157 | | [Test] |
2158 | | public void TheAddInfoLaterTest() |
2159 | | { |
2160 | | driver.Navigate().GoToUrl(baseURL + "/"); |
2161 | | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
2162 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
2163 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("mojasmetka1"); |
2164 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
2165 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("adresa@mail.com"); |
2166 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
2167 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("mojasmetka1"); |
2168 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
2169 | | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("mojasmetka1"); |
2170 | | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
2171 | | driver.FindElement(By.Id("MainContent_Button2")).Click(); |
2172 | | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
2173 | | driver.FindElement(By.CssSelector("span.username")).Click(); |
2174 | | driver.FindElement(By.Id("MainContent_txtImePrezime")).Clear(); |
2175 | | driver.FindElement(By.Id("MainContent_txtImePrezime")).SendKeys("moja"); |
2176 | | driver.FindElement(By.Id("MainContent_rblPol_1")).Click(); |
2177 | | driver.FindElement(By.Id("MainContent_txtMesto")).Clear(); |
2178 | | driver.FindElement(By.Id("MainContent_txtMesto")).SendKeys("ww"); |
2179 | | driver.FindElement(By.Id("MainContent_txtDatum")).Clear(); |
2180 | | driver.FindElement(By.Id("MainContent_txtDatum")).SendKeys("16.06.1989"); |
2181 | | driver.FindElement(By.Id("MainContent_txtObrazovanie")).Clear(); |
2182 | | driver.FindElement(By.Id("MainContent_txtObrazovanie")).SendKeys("ww"); |
2183 | | driver.FindElement(By.Id("MainContent_txtInstitucija")).Clear(); |
2184 | | driver.FindElement(By.Id("MainContent_txtInstitucija")).SendKeys("ww"); |
2185 | | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).Clear(); |
2186 | | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).SendKeys("ww"); |
2187 | | driver.FindElement(By.Id("MainContent_txtPozicija")).Clear(); |
2188 | | driver.FindElement(By.Id("MainContent_txtPozicija")).SendKeys("ww"); |
2189 | | driver.FindElement(By.Id("MainContent_btnAdd")).Click(); |
2190 | | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
2191 | | } |
2192 | | private bool IsElementPresent(By by) |
2193 | | { |
2194 | | try |
2195 | | { |
2196 | | driver.FindElement(by); |
2197 | | return true; |
2198 | | } |
2199 | | catch (NoSuchElementException) |
2200 | | { |
2201 | | return false; |
2202 | | } |
2203 | | } |
2204 | | |
2205 | | private bool IsAlertPresent() |
2206 | | { |
2207 | | try |
2208 | | { |
2209 | | driver.SwitchTo().Alert(); |
2210 | | return true; |
2211 | | } |
2212 | | catch (NoAlertPresentException) |
2213 | | { |
2214 | | return false; |
2215 | | } |
2216 | | } |
2217 | | |
2218 | | private string CloseAlertAndGetItsText() { |
2219 | | try { |
2220 | | IAlert alert = driver.SwitchTo().Alert(); |
2221 | | string alertText = alert.Text; |
2222 | | if (acceptNextAlert) { |
2223 | | alert.Accept(); |
2224 | | } else { |
2225 | | alert.Dismiss(); |
2226 | | } |
2227 | | return alertText; |
2228 | | } finally { |
2229 | | acceptNextAlert = true; |
2230 | | } |
2231 | | } |
2232 | | } |
2233 | | } |
2234 | | |
2235 | | }}} |
2236 | | |
2237 | | '''Addnewactivity.cs''' |
2238 | | {{{ |
2239 | | using System; |
2240 | | using System.Text; |
2241 | | using System.Text.RegularExpressions; |
2242 | | using System.Threading; |
2243 | | using NUnit.Framework; |
2244 | | using OpenQA.Selenium; |
2245 | | using OpenQA.Selenium.Firefox; |
2246 | | using OpenQA.Selenium.Support.UI; |
2247 | | |
2248 | | namespace SeleniumTests |
2249 | | { |
2250 | | [TestFixture] |
2251 | | public class AddNewActivity |
2252 | | { |
2253 | | private IWebDriver driver; |
2254 | | private StringBuilder verificationErrors; |
2255 | | private string baseURL; |
2256 | | private bool acceptNextAlert = true; |
2257 | | |
2258 | | [SetUp] |
2259 | | public void SetupTest() |
2260 | | { |
2261 | | driver = new FirefoxDriver(); |
2262 | | baseURL = "http://localhost:1400/"; |
2263 | | verificationErrors = new StringBuilder(); |
2264 | | } |
2265 | | |
2266 | | [TearDown] |
2267 | | public void TeardownTest() |
2268 | | { |
2269 | | try |
2270 | | { |
2271 | | driver.Quit(); |
2272 | | } |
2273 | | catch (Exception) |
2274 | | { |
2275 | | // Ignore errors if unable to close the browser |
2276 | | } |
2277 | | Assert.AreEqual("", verificationErrors.ToString()); |
2278 | | } |
2279 | | |
2280 | | [Test] |
2281 | | public void TheAddNewActivityTest() |
2282 | | { |
2283 | | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
2284 | | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
2285 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
2286 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
2287 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
2288 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1234"); |
2289 | | driver.FindElement(By.Id("MainContent_ctl00_RememberMe")).Click(); |
2290 | | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
2291 | | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
2292 | | driver.FindElement(By.Id("MainContent_txtName")).Clear(); |
2293 | | driver.FindElement(By.Id("MainContent_txtName")).SendKeys("nestonovo"); |
2294 | | driver.FindElement(By.Id("MainContent_txtCategory")).Clear(); |
2295 | | driver.FindElement(By.Id("MainContent_txtCategory")).SendKeys("/"); |
2296 | | driver.FindElement(By.Id("MainContent_txtPlace")).Clear(); |
2297 | | driver.FindElement(By.Id("MainContent_txtPlace")).SendKeys("Proba"); |
2298 | | driver.FindElement(By.Id("MainContent_txtDate")).Clear(); |
2299 | | driver.FindElement(By.Id("MainContent_txtDate")).SendKeys("11.11.2013"); |
2300 | | driver.FindElement(By.Id("MainContent_txtRole")).Clear(); |
2301 | | driver.FindElement(By.Id("MainContent_txtRole")).SendKeys("/"); |
2302 | | driver.FindElement(By.Id("MainContent_btnInsert")).Click(); |
2303 | | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
2304 | | driver.FindElement(By.LinkText("Одјави се")).Click(); |
2305 | | } |
2306 | | private bool IsElementPresent(By by) |
2307 | | { |
2308 | | try |
2309 | | { |
2310 | | driver.FindElement(by); |
2311 | | return true; |
2312 | | } |
2313 | | catch (NoSuchElementException) |
2314 | | { |
2315 | | return false; |
2316 | | } |
2317 | | } |
2318 | | |
2319 | | private bool IsAlertPresent() |
2320 | | { |
2321 | | try |
2322 | | { |
2323 | | driver.SwitchTo().Alert(); |
2324 | | return true; |
2325 | | } |
2326 | | catch (NoAlertPresentException) |
2327 | | { |
2328 | | return false; |
2329 | | } |
2330 | | } |
2331 | | |
2332 | | private string CloseAlertAndGetItsText() { |
2333 | | try { |
2334 | | IAlert alert = driver.SwitchTo().Alert(); |
2335 | | string alertText = alert.Text; |
2336 | | if (acceptNextAlert) { |
2337 | | alert.Accept(); |
2338 | | } else { |
2339 | | alert.Dismiss(); |
2340 | | } |
2341 | | return alertText; |
2342 | | } finally { |
2343 | | acceptNextAlert = true; |
2344 | | } |
2345 | | } |
2346 | | } |
2347 | | } |
2348 | | }}} |
2349 | | |
2350 | | '''Addusertoexistingactivity.cs''' |
2351 | | {{{ |
2352 | | using System; |
2353 | | using System.Text; |
2354 | | using System.Text.RegularExpressions; |
2355 | | using System.Threading; |
2356 | | using NUnit.Framework; |
2357 | | using OpenQA.Selenium; |
2358 | | using OpenQA.Selenium.Firefox; |
2359 | | using OpenQA.Selenium.Support.UI; |
2360 | | |
2361 | | namespace SeleniumTests |
2362 | | { |
2363 | | [TestFixture] |
2364 | | public class AddUserToExistingActivity |
2365 | | { |
2366 | | private IWebDriver driver; |
2367 | | private StringBuilder verificationErrors; |
2368 | | private string baseURL; |
2369 | | private bool acceptNextAlert = true; |
2370 | | |
2371 | | [SetUp] |
2372 | | public void SetupTest() |
2373 | | { |
2374 | | driver = new FirefoxDriver(); |
2375 | | baseURL = "http://localhost:1400/"; |
2376 | | verificationErrors = new StringBuilder(); |
2377 | | } |
2378 | | |
2379 | | [TearDown] |
2380 | | public void TeardownTest() |
2381 | | { |
2382 | | try |
2383 | | { |
2384 | | driver.Quit(); |
2385 | | } |
2386 | | catch (Exception) |
2387 | | { |
2388 | | // Ignore errors if unable to close the browser |
2389 | | } |
2390 | | Assert.AreEqual("", verificationErrors.ToString()); |
2391 | | } |
2392 | | |
2393 | | [Test] |
2394 | | public void TheAddUserToExistingActivityTest() |
2395 | | { |
2396 | | driver.Navigate().GoToUrl(baseURL + "/"); |
2397 | | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
2398 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
2399 | | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
2400 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
2401 | | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
2402 | | driver.FindElement(By.Id("MainContent_ctl00_RememberMe")).Click(); |
2403 | | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
2404 | | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
2405 | | driver.FindElement(By.Id("MainContent_txtActivity")).Clear(); |
2406 | | driver.FindElement(By.Id("MainContent_txtActivity")).SendKeys("nnnn"); |
2407 | | driver.FindElement(By.Id("MainContent_btnShow")).Click(); |
2408 | | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).Clear(); |
2409 | | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).SendKeys("mmm"); |
2410 | | driver.FindElement(By.Id("MainContent_gvMe_CheckBox1_0")).Click(); |
2411 | | driver.FindElement(By.Id("MainContent_btnAddMe")).Click(); |
2412 | | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
2413 | | driver.FindElement(By.LinkText("2")).Click(); |
2414 | | } |
2415 | | private bool IsElementPresent(By by) |
2416 | | { |
2417 | | try |
2418 | | { |
2419 | | driver.FindElement(by); |
2420 | | return true; |
2421 | | } |
2422 | | catch (NoSuchElementException) |
2423 | | { |
2424 | | return false; |
2425 | | } |
2426 | | } |
2427 | | |
2428 | | private bool IsAlertPresent() |
2429 | | { |
2430 | | try |
2431 | | { |
2432 | | driver.SwitchTo().Alert(); |
2433 | | return true; |
2434 | | } |
2435 | | catch (NoAlertPresentException) |
2436 | | { |
2437 | | return false; |
2438 | | } |
2439 | | } |
2440 | | |
2441 | | private string CloseAlertAndGetItsText() { |
2442 | | try { |
2443 | | IAlert alert = driver.SwitchTo().Alert(); |
2444 | | string alertText = alert.Text; |
2445 | | if (acceptNextAlert) { |
2446 | | alert.Accept(); |
2447 | | } else { |
2448 | | alert.Dismiss(); |
2449 | | } |
2450 | | return alertText; |
2451 | | } finally { |
2452 | | acceptNextAlert = true; |
2453 | | } |
2454 | | } |
2455 | | } |
2456 | | } |
2457 | | }}} |