private bool IsTypeRequested(string status, int editor) { switch (Convert.ToInt32(ddlWhichContent.SelectedItem.Value)) { case 0: return(StatusCodes.isAwaitingEdit(status) || StatusCodes.isEditing(status)); case 1: if (editor == 0) { return(false); } return(StatusCodes.isAwaitingEdit(status) || StatusCodes.isRequiresUpdate(status) || StatusCodes.isEditing(status) || StatusCodes.isAwaitingApproval(status)); case 2: if (editor == 0) { return(false); } return(true); default: return(false); } }
private void BuildPage(int cver) { AccountProperty property = new AccountProperty(appEnv.GetConnection()); DataRow dr = dt.Rows[cver]; lbContentID.Text = dr["ContentID"].ToString(); lbVersion.Text = dr["Version"].ToString(); lbHeadline.Text = dr["Headline"].ToString(); lbSource.Text = dr["Source"].ToString() + " "; lbByline.Text = property.GetValue(Convert.ToInt32(dr["Byline"]), "UserName").Trim(); lbTeaser.Text = dr["Teaser"].ToString() + " "; lbBody.Text = dr["Body"].ToString(); lbTagline.Text = dr["Tagline"].ToString() + " "; lbStatus.Text = StatusCodes.ToString(Convert.ToInt32(dr["Status"])); lbEditor.Text = property.GetValue(Convert.ToInt32(dr["Editor"]), "UserName").Trim(); lbApprover.Text = property.GetValue(Convert.ToInt32(dr["Approver"]), "UserName").Trim(); lbUpdateUser.Text = property.GetValue(Convert.ToInt32(dr["UpdateUserID"]), "UserName").Trim(); lbModifiedDate.Text = dr["ModifiedDate"].ToString(); lbCreationDate.Text = dr["CreationDate"].ToString(); if (cver > 0) { bnNext.Enabled = true; int tmp = cver - 1; bnNext.CommandArgument = tmp.ToString(); } else { bnNext.Enabled = false; } if (cver < dt.Rows.Count - 1) { bnPrevious.Enabled = true; int tmp = cver + 1; bnPrevious.CommandArgument = tmp.ToString(); } else { bnPrevious.Enabled = false; } bnApprove.Visible = (cver == 0 && StatusCodes.isAwaitingApproval(dr["Status"].ToString())); bnReturn.Visible = (cver == 0 && StatusCodes.isAwaitingApproval(dr["Status"].ToString())); }
private void Page_Load(object sender, System.EventArgs e) { account = new Account(appEnv.GetConnection()); content = new Content(appEnv.GetConnection()); notes = new ContentNotes(appEnv.GetConnection()); DataTable dt; int accountNo = account.GetAccountID(User.Identity.Name); if (accountNo == 1) // Admin sees all { dt = content.GetHeadlines(); } else { dt = content.GetHeadlinesForApprove(accountNo); } LiteralControl lit; TableCell cell; int prv = -1; int cur; foreach (DataRow dr in dt.Rows) { cur = Convert.ToInt32(dr["ContentID"]); if (cur != prv) { prv = cur; if (IsTypeRequested(dr["Status"].ToString(), Convert.ToInt32(dr["Approver"]))) { TableRow row = new TableRow(); tblView.Rows.Add(row); lit = new LiteralControl(dr["ContentID"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); cell.HorizontalAlign = HorizontalAlign.Center; row.Cells.Add(cell); lit = new LiteralControl(dr["Version"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); cell.HorizontalAlign = HorizontalAlign.Center; row.Cells.Add(cell); lit = new LiteralControl(dr["Headline"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); row.Cells.Add(cell); lit = new LiteralControl(StatusCodes.ToString( Convert.ToInt32(dr["Status"]))); cell = new TableCell(); cell.Font.Size = new FontUnit(FontSize.XSmall); cell.HorizontalAlign = HorizontalAlign.Center; cell.Controls.Add(lit); row.Cells.Add(cell); BuildImageButton(row, "AppView.aspx?ContentID=" + dr["ContentID"].ToString(), -1); BuildImageButton(row, "../Note/NoteList.aspx?ContentID=" + dr["ContentID"].ToString() + "&Origin=Approval", notes.CountNotesForID(Convert.ToInt32(dr["ContentID"]))); if (StatusCodes.isAwaitingApproval(dr["Status"].ToString())) { BuildImageButton(row, "AppApprove.aspx?ContentID=" + dr["ContentID"].ToString(), -1); BuildImageButton(row, "AppReturn.aspx?ContentID=" + dr["ContentID"].ToString(), -1); BuildImageButton(row, "AppDiscont.aspx?ContentID=" + dr["ContentID"].ToString(), -1); } else { BuildImageButton(row, null, -1); BuildImageButton(row, null, -1); BuildImageButton(row, null, -1); } } } } }