protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <ProjectDetailDTO> list = projectApplication.GetUserProjects(UserInfo); List <TicketsEntity> listTicket = ticketAPP.GetTicketsByCreateId(UserInfo.UserID); var projectDetailDto = list.FirstOrDefault(c => { var firstOrDefault = listTicket.FirstOrDefault(); return(firstOrDefault != null && c.Title == firstOrDefault.ProjectTitle); }); jsonProjectInfo = projectApplication.GetProjectInfoJson(list); if (QS("tid", 0) > 0) { TicketsEntity entity = new TicketsApplication().GetTickets(QS("tid", 0)); if (entity == null && entity.CreatedBy != UserInfo.UserID) { ShowFailMessageToClient("unauthorized access."); return; } this.ddlProject.DataTextField = "Title"; this.ddlProject.DataValueField = "ProjectID"; if (list != null && list.Count > 0) { list.RemoveAll(r => r.Status == ProjectStatus.Cancelled || r.Status == ProjectStatus.Completed); } ddlProject.DataSource = list; ddlProject.DataBind(); jsonProjectInfo = projectApplication.GetProjectInfoJson(list); if (list.Count != 1) { ddlProject.Items.Insert(0, new ListItem() { Value = "", Text = "Please select..." }); } BindTicket(entity); this.btnEditSave.Visible = true; this.btnEditSubmit.Visible = true; this.btnSaveAndNew.Visible = false; this.btnSaveAsDraft.Visible = false; this.btnClear.Visible = false; btnSubmit.Visible = false; } else { if (projectDetailDto != null) { list.Remove(projectDetailDto); list.Insert(0, projectDetailDto); list.BindDropdown <ProjectDetailDTO>(ddlProject, "Title", "ProjectID"); ddlProject.Items.FindByValue(projectDetailDto.ProjectID.ToString()).Selected = true; } else { list.BindDropdown <ProjectDetailDTO>(ddlProject, "Title", "ProjectID", DefaulSelectText, "", QS("project")); } if (UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.ADMIN) { dvSource.Style.Remove("visibility"); lblSource.Style.Remove("visibility"); ddlSource.DataSource = ConvertEnumtToListItem(typeof(RolesEnum)); ddlSource.DataBind(); ddlSource.SelectedValue = RolesEnum.CLIENT.ToString(); } this.btnEditSave.Visible = false; this.btnEditSubmit.Visible = false; } if (list.Count == 1 && !projectApplication.CheckIfEstimated(list[0])) //只有一个Project,且已过期 { this.btnSaveAsDraft.Enabled = false; this.btnSubmit.Enabled = false; this.btnSaveAndNew.Enabled = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ProjectApplication projectApplication = new ProjectApplication(); List <ProjectDetailDTO> list = projectApplication.GetUserProjectsForCreateObject(UserInfo); List <TicketsEntity> listTicket = ticketAPP.GetTicketsByCreateId(UserInfo.UserID); var projectDetailDto = list.FirstOrDefault(c => { var firstOrDefault = listTicket.FirstOrDefault(); return(firstOrDefault != null && c.Title == firstOrDefault.ProjectTitle); }); if (projectDetailDto != null) { List <UsersEntity> users = new List <UsersEntity>(); var sunnetUser = projectApplication.GetProjectSunnetUserList(projectDetailDto.ProjectID); users.AddRange(sunnetUser.Select(t => userApp.GetUser(t.UserID)).Where(user => user != null && user.Status.Trim() != "INACTIVE")); UsersEntity myselef = users.FirstOrDefault(c => c.UserID == UserInfo.UserID); if (myselef != null) { users.Remove(myselef); users.Add(new UsersEntity() { FirstName = "System", UserID = -1 }); users.BindDropdown <UsersEntity>(ddlRes, "FirstAndLastName", "UserID", myselef.FirstAndLastName, myselef.UserID.ToString(), "", true); } else { users.Add(new UsersEntity() { FirstName = "System", UserID = -1 }); users.BindDropdown <UsersEntity>(ddlRes, "FirstAndLastName", "UserID"); } list.Remove(projectDetailDto); list.Insert(0, projectDetailDto); list.BindDropdown <ProjectDetailDTO>(ddlProject, "Title", "ProjectID"); ddlProject.Items.FindByValue(projectDetailDto.ProjectID.ToString()).Selected = true; } else { list.BindDropdown <ProjectDetailDTO>(ddlProject, "Title", "ProjectID", DefaulSelectText, "", QS("project")); } jsonProjectInfo = projectApplication.GetProjectInfoJson(list); if (UserInfo.Role == RolesEnum.PM) { dvRes.Style.Remove("display"); lblRes.Style.Remove("display"); } if (UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.ADMIN || UserInfo.Role == RolesEnum.Sales) { ViewState["curRole"] = UserInfo.Role.ToString(); dvSource.Style.Remove("display"); lblSource.Style.Remove("display"); lblAccounting.Style.Remove("display"); dvAccounting.Style.Remove("display"); rdoAccounting.SelectedIndex = 0; ddlSource.DataSource = ConvertEnumtToListItem(typeof(RolesEnum)); ddlSource.DataBind(); if (UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.ADMIN) { ddlSource.SelectedValue = RolesEnum.PM.ToString(); } else { ddlSource.SelectedValue = RolesEnum.Sales.ToString(); } dvIsInteral.Style.Remove("display"); lblIsInternal.Style.Remove("display"); } else { rdoAccounting.SelectedIndex = 2; } if (list.Count == 1 && !projectApplication.CheckIfEstimated(list[0])) //只有一个Project,且已过期 { this.btnSubmit.Enabled = false; this.btnSave.Enabled = false; this.btnSubmitAndNew.Enabled = false; } } }