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"); } }
private void BindProjects() { ddlProjects.DataSource = ProjectsDBManager.GetAllProjects(); ddlProjects.DataTextField = "Name"; ddlProjects.DataValueField = "ProjectId"; ddlProjects.DataBind(); ddlProjects.Items.Insert(0, new ListItem("Изберете проект", "-1")); }
protected void cuvName_ServerValidate(object sender, ServerValidateEventArgs e) { if (ProjectsDBManager.GetProjectByName(txtName.Text) == null) { e.IsValid = true; } else { e.IsValid = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlProjects.DataSource = ProjectsDBManager.GetAllProjects(); ddlProjects.DataTextField = "Name"; ddlProjects.DataValueField = "ProjectId"; ddlProjects.DataBind(); if (Page.Request.QueryString["projectId"] != null) { ddlProjects.Items.FindByValue(Page.Request.QueryString["projectId"].ToString()).Selected = true; } var priorityList = Enum.GetValues(typeof(Priority)).Cast <Priority>(); List <EnumValues> priorityData = new List <EnumValues>(); foreach (var l in priorityList) { EnumValues v = new EnumValues(EnumStringValue.StringValue((Priority)Enum.Parse(typeof(Priority), l.ToString())), l.ToString()); priorityData.Add(v); } ddlPriority.DataSource = priorityData; ddlPriority.DataTextField = "Name"; ddlPriority.DataValueField = "Value"; ddlPriority.DataBind(); var statusList = Enum.GetValues(typeof(Status)).Cast <Status>(); List <EnumValues> statusData = new List <EnumValues>(); foreach (var l in statusList) { EnumValues v = new EnumValues(EnumStringValue.StringValue((Status)Enum.Parse(typeof(Status), l.ToString())), l.ToString()); statusData.Add(v); } ddlStatus.DataSource = statusData; ddlStatus.DataTextField = "Name"; ddlStatus.DataValueField = "Value"; ddlStatus.DataBind(); header.InnerHtml = "Нова грешка"; if (OldBug != null) { header.InnerHtml = "Редакция на грешка"; LoadContent(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlProjects.DataSource = ProjectsDBManager.GetAllProjects(); ddlProjects.DataTextField = "Name"; ddlProjects.DataValueField = "ProjectId"; ddlProjects.DataBind(); if (Page.Request.QueryString["projectId"] != null) { ddlProjects.Items.FindByValue(Page.Request.QueryString["projectId"]).Selected = true; } BindBugs(); BuildPager(); } }
protected void ddlProjects_SelectedIndexChanged(object sender, EventArgs e) { if (ddlProjects.SelectedValue != "-1") { CurrentPage = 1; Asc = true; SortExpression = "SortId"; BindProjectBugs(); ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorsInProjects", "ShowHideArea('dropdown');ShowArea('bugs');", true); this.lblBugsCount.Text = "Брой активни грешки: " + ProjectsDBManager.GetBugsCountByProject(this.ddlProjects.SelectedItem.Text); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorsInProjects", "ShowHideArea('dropdown');", true); } }
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; } }
private void BindProjects() { lvProjects.DataSource = ProjectsDBManager.GetProjects(CurrentPage - 1, itemsPerPage, Asc, SortExpression, out itemsCount); lvProjects.DataBind(); }