protected void btnSave_Click(object sender, EventArgs e) { if (Page.Request.QueryString["testerId"] != null) { cuvUsername.Enabled = false; } Page.Validate(); if (Page.IsValid) { // insert new tesnter in database if (OldTester == null) { Data.Tester tester = TestersDBManager.GetTesterByUsername(Membership.GetUser().UserName); tester.LastAction = "Създаване на тестер №" + TestersDBManager.Insert(NewTester); TestersDBManager.Update(tester); Membership.CreateUser(NewTester.Username, NewTester.Password, NewTester.Email); Roles.AddUserToRole(NewTester.Username, "Tester"); } // update existing one else { TestersDBManager.Update(NewTester); Data.Tester tester = TestersDBManager.GetTesterByUsername(Membership.GetUser().UserName); tester.LastAction = "Редакция на тестер №" + NewTester.TesterId; TestersDBManager.Update(tester); // update data in membership provider MembershipUser user = Membership.GetUser(OldTester.Username); user.Email = NewTester.Email; Membership.UpdateUser(user); } Response.Redirect("Testers.aspx"); } }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.Request.QueryString["ProjectId"] != null) { cuvName.Enabled = false; } Page.Validate(); if (Page.IsValid) { Data.Tester tester = TestersDBManager.GetTesterByUsername(Membership.GetUser().UserName); // insert new project in database if (OldProject == null) { tester.LastAction = "Създаване на проект №" + ProjectsDBManager.Insert(NewProject); } // update existing one else { ProjectsDBManager.Update(NewProject); tester.LastAction = "Редакция на проект №" + NewProject.ProjectId; } TestersDBManager.Update(tester); Response.Redirect("Projects.aspx"); } }
public static int Insert(Tester tester) { DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext(); db.Testers.InsertOnSubmit(tester); db.SubmitChanges(); return tester.TesterId; }
protected void btnSave_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { Data.Tester tester = TestersDBManager.GetTesterByUsername(Membership.GetUser().UserName); // insert new bug in database if (OldBug == null) { tester.LastAction = "Създаване на грешка №" + BugsDBManager.Insert(NewBug); } // update existing one else { BugsDBManager.Update(NewBug); tester.LastAction = "Редакция на грешка №" + NewBug.BugId; } TestersDBManager.Update(tester); Response.Redirect("ProjectsBugs.aspx?projectId=" + NewBug.ProjectId); } }
public static void Update(Tester tester) { DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext(); Tester testerToUpdate = db.Testers.Single(t => t.TesterId == tester.TesterId); testerToUpdate.Password = tester.Password; testerToUpdate.Name = tester.Name; testerToUpdate.Surname = tester.Surname; testerToUpdate.Phone = tester.Phone; testerToUpdate.Email = tester.Email; testerToUpdate.LastAction = tester.LastAction; db.SubmitChanges(); }
protected void lvTesters_ItemCommand(object sender, ListViewCommandEventArgs e) { switch (e.CommandName) { case "EditTester": int testerId = -1; if (Int32.TryParse(e.CommandArgument.ToString(), out testerId)) { Response.Redirect("Tester.aspx?testerId=" + testerId.ToString()); } break; case "DeleteTester": testerId = -1; if (Int32.TryParse(e.CommandArgument.ToString(), out testerId)) { var testerToDelete = TestersDBManager.GetTesterByTesterId(testerId); Membership.DeleteUser(testerToDelete.Username); Roles.RemoveUserFromRole(testerToDelete.Username, "Tester"); TestersDBManager.Delete(testerId); Data.Tester tester = TestersDBManager.GetTesterByUsername(Membership.GetUser().UserName); tester.LastAction = "Изтриване на тестер №" + testerId; TestersDBManager.Update(tester); BindTesters(); BuildPager(); } break; case "SortName": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortName"; BindTesters(); LinkButton btnName = (LinkButton)lvTesters.FindControl("btnName"); if (btnName != null) { btnName.CommandArgument = "DESC"; btnName.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortName"; BindTesters(); LinkButton btnName = (LinkButton)lvTesters.FindControl("btnName"); if (btnName != null) { btnName.CommandArgument = "ASC"; btnName.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; case "SortSurname": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortSurname"; BindTesters(); LinkButton btnSurname = (LinkButton)lvTesters.FindControl("btnSurname"); if (btnSurname != null) { btnSurname.CommandArgument = "DESC"; btnSurname.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortSurname"; BindTesters(); LinkButton btnSurname = (LinkButton)lvTesters.FindControl("btnSurname"); if (btnSurname != null) { btnSurname.CommandArgument = "ASC"; btnSurname.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; } }
protected void lvBugs_ItemCommand(object sender, ListViewCommandEventArgs e) { switch (e.CommandName) { case "EditBug": int bugId = -1; if (Int32.TryParse(e.CommandArgument.ToString(), out bugId)) { Response.Redirect("Bug.aspx?bugId=" + bugId.ToString()); } break; case "DeleteBug": bugId = -1; if (Int32.TryParse(e.CommandArgument.ToString(), out bugId)) { BugsDBManager.Delete(bugId); Data.Tester tester = TestersDBManager.GetTesterByUsername(Membership.GetUser().UserName); tester.LastAction = "Изтриване на грешка №" + bugId; TestersDBManager.Update(tester); BindBugs(); BuildPager(); } break; case "SortId": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortId"; BindBugs(); LinkButton btnId = (LinkButton)lvBugs.FindControl("btnId"); if (btnId != null) { btnId.CommandArgument = "DESC"; btnId.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortId"; BindBugs(); LinkButton btnId = (LinkButton)lvBugs.FindControl("btnId"); if (btnId != null) { btnId.CommandArgument = "ASC"; btnId.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; case "SortOwner": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortOwner"; BindBugs(); LinkButton btnOwner = (LinkButton)lvBugs.FindControl("btnOwner"); if (btnOwner != null) { btnOwner.CommandArgument = "DESC"; btnOwner.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortOwner"; BindBugs(); LinkButton btnOwner = (LinkButton)lvBugs.FindControl("btnOwner"); if (btnOwner != null) { btnOwner.CommandArgument = "ASC"; btnOwner.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; case "SortPriority": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortPriority"; BindBugs(); LinkButton btnPriority = (LinkButton)lvBugs.FindControl("btnPriority"); if (btnPriority != null) { btnPriority.CommandArgument = "DESC"; btnPriority.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortPriority"; BindBugs(); LinkButton btnPriority = (LinkButton)lvBugs.FindControl("btnPriority"); if (btnPriority != null) { btnPriority.CommandArgument = "ASC"; btnPriority.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; case "SortDate": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortDate"; BindBugs(); LinkButton btnDate = (LinkButton)lvBugs.FindControl("btnDate"); if (btnDate != null) { btnDate.CommandArgument = "DESC"; btnDate.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortDate"; BindBugs(); LinkButton btnDate = (LinkButton)lvBugs.FindControl("btnDate"); if (btnDate != null) { btnDate.CommandArgument = "ASC"; btnDate.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; } }
protected void lvProjects_ItemCommand(object sender, ListViewCommandEventArgs e) { switch (e.CommandName) { case "EditProject": int projectId = -1; if (Int32.TryParse(e.CommandArgument.ToString(), out projectId)) { Response.Redirect("Project.aspx?projectId=" + projectId.ToString()); } break; case "DeleteProject": projectId = -1; if (Int32.TryParse(e.CommandArgument.ToString(), out projectId)) { ProjectsDBManager.Delete(projectId); Data.Tester tester = TestersDBManager.GetTesterByUsername(Membership.GetUser().UserName); tester.LastAction = "Изтриване на проект №" + projectId; TestersDBManager.Update(tester); BindProjects(); BuildPager(); } break; case "SortNumber": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortNumber"; BindProjects(); LinkButton btnNumber = (LinkButton)lvProjects.FindControl("btnNumber"); if (btnNumber != null) { btnNumber.CommandArgument = "DESC"; btnNumber.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortNumber"; BindProjects(); LinkButton btnNumber = (LinkButton)lvProjects.FindControl("btnNumber"); if (btnNumber != null) { btnNumber.CommandArgument = "ASC"; btnNumber.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; case "SortName": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortName"; BindProjects(); LinkButton btnName = (LinkButton)lvProjects.FindControl("btnName"); if (btnName != null) { btnName.CommandArgument = "DESC"; btnName.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortName"; BindProjects(); LinkButton btnName = (LinkButton)lvProjects.FindControl("btnName"); if (btnName != null) { btnName.CommandArgument = "ASC"; btnName.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; case "SortDescription": BindColumsNames(); if (e.CommandArgument.ToString() == "ASC") { Asc = true; SortExpression = "SortDescription"; BindProjects(); LinkButton btnDescription = (LinkButton)lvProjects.FindControl("btnDescription"); if (btnDescription != null) { btnDescription.CommandArgument = "DESC"; btnDescription.Text += " <img src='../style/arrow_order_down.gif'/>"; } } else { Asc = false; SortExpression = "SortDescription"; BindProjects(); LinkButton btnDescription = (LinkButton)lvProjects.FindControl("btnDescription"); if (btnDescription != null) { btnDescription.CommandArgument = "ASC"; btnDescription.Text += " <img src='../style/arrow_order_up.gif'/>"; } } break; } }
partial void DeleteTester(Tester instance);
partial void UpdateTester(Tester instance);
partial void InsertTester(Tester instance);