protected void ProjectGridview_RowCommand(object sender, GridViewCommandEventArgs e) { try { int rowIndex = Convert.ToInt32(e.CommandArgument); int projId = Convert.ToInt32(ProjectGridview.Rows[rowIndex].Cells[0].Text); using (Storage db = new Storage()) { DAL.Project proj = db.Projects.Include("Employees").Include("Tasks").Where(p => p.ProjectCode == projId).FirstOrDefault(); if (proj != null) { proj.Status = (proj.Status) ? false : true; db.SaveChanges(); } ProjectGridview.DataBind(); } } catch (Exception ex) { Loger.Log(Response, ex); } }
protected void ProjCreateBtn_Click(object sender, EventArgs e) { if (Page.IsValid) { try { using (Storage db = new Storage()) { Project p = new Project(); p.Name = ProjNameTb.Text; p.Status = ProjStatus.SelectedValue == "0" ? false : true; foreach (ListItem li in MemberList.Items) { if (li.Selected) { DAL.User su = db.Users.Where(u => u.Login == li.Value).Select(u => u).FirstOrDefault(); p.Employees.Add(su); } } db.Projects.Add(p); db.SaveChanges(); ResetProjectCreateForm(); ProjectGridview.DataBind(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Проект был успешно добавлен')", true); } } catch (Exception ex) { Loger.Log(Response, ex); } } }