SPWeb currentWeb = SPControl.GetContextWeb(Context);
SPList lstTasks = currentWeb.Lists["Tasks"];
if (lstTasks != null)
{
SPQuery sQuery = new SPQuery();
sQuery.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy><Where><Neq><FieldRef Name='Status' /><Value Type='Choice'>Completed</Value></Neq></Where>";
//sQuery.Query = "<Query><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query>";
sQuery.RowLimit = 5;
SPListItemCollection tasksList = lstTasks.GetItems(sQuery);
//SPListItem item = tasksList.Add();
writer.Write("<Table width='100%' style='"+strStyleValign+"'>");
if (tasksList.Count > 0)
{
writer.Write("<Tr>");
writer.Write("<Td colspan='3' align='Center'>");
writer.Write("<Strong>");
writer.Write("<Font color='Red'>");
writer.Write("Top five tasks");
writer.Write("</Font>");
writer.Write("</Strong>");
writer.Write("</Td>");
writer.Write("</Tr>");
writer.Write("<Tr>");
writer.Write("<Td>");
writer.Write("Task Name");
writer.Write("</Td>");
writer.Write("<Td>");
writer.Write("Task Status");
writer.Write("</Td>");
writer.Write("<Td>");
writer.Write("Task Priority");
writer.Write("</Td>");
writer.Write("</Tr>");
foreach (SPListItem sQueryItem in tasksList)
{
string strTitle = string.Empty;
strTitle = sQueryItem["Title"].ToString();
string strStatus = string.Empty;
string strPriority = string.Empty;
string strUrl = currentWeb.Url + "/Lists/Tasks/DispForm.aspx?ID=" + sQueryItem.ID + "&source=" + Page.Request.Url;
writer.Write("<Tr>");
writer.Write("<Td>");
writer.Write("<A href='" + strUrl + "'>" + strTitle + "</A>");
writer.Write("</Td>");
writer.Write("<Td>");
if (sQueryItem["Status"] != null)
{
strStatus = sQueryItem["Status"].ToString().Substring(sQueryItem["Status"].ToString().LastIndexOf("#") + 1);
}
else
{
strStatus = "--";
}
writer.Write(strStatus);
writer.Write("</Td>");
writer.Write("<Td>");
if (sQueryItem["Priority"] != null)
{
strPriority = sQueryItem["Priority"].ToString().Substring(sQueryItem["Priority"].ToString().LastIndexOf("#") + 1);
}
else
{
strPriority = "--";
}
writer.Write(strPriority);
writer.Write("</Td>");
writer.Write("</Tr>");
}
}
else
{
writer.Write("<Tr>");
writer.Write("<Td colspan='3' align='Center'>");
writer.Write("There are no Active Tasks");
writer.Write("</Td>");
writer.Write("</Tr>");
}
}
else
{
writer.Write("<Tr>");
writer.Write("<Td colspan='3' align='Center'>");
writer.Write("Taks List Not available");
writer.Write("</Td>");
writer.Write("</Tr>");
}
writer.Write("</Table>");
SPList lstTasks = currentWeb.Lists["Tasks"];
if (lstTasks != null)
{
SPQuery sQuery = new SPQuery();
sQuery.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy><Where><Neq><FieldRef Name='Status' /><Value Type='Choice'>Completed</Value></Neq></Where>";
//sQuery.Query = "<Query><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query>";
sQuery.RowLimit = 5;
SPListItemCollection tasksList = lstTasks.GetItems(sQuery);
//SPListItem item = tasksList.Add();
writer.Write("<Table width='100%' style='"+strStyleValign+"'>");
if (tasksList.Count > 0)
{
writer.Write("<Tr>");
writer.Write("<Td colspan='3' align='Center'>");
writer.Write("<Strong>");
writer.Write("<Font color='Red'>");
writer.Write("Top five tasks");
writer.Write("</Font>");
writer.Write("</Strong>");
writer.Write("</Td>");
writer.Write("</Tr>");
writer.Write("<Tr>");
writer.Write("<Td>");
writer.Write("Task Name");
writer.Write("</Td>");
writer.Write("<Td>");
writer.Write("Task Status");
writer.Write("</Td>");
writer.Write("<Td>");
writer.Write("Task Priority");
writer.Write("</Td>");
writer.Write("</Tr>");
foreach (SPListItem sQueryItem in tasksList)
{
string strTitle = string.Empty;
strTitle = sQueryItem["Title"].ToString();
string strStatus = string.Empty;
string strPriority = string.Empty;
string strUrl = currentWeb.Url + "/Lists/Tasks/DispForm.aspx?ID=" + sQueryItem.ID + "&source=" + Page.Request.Url;
writer.Write("<Tr>");
writer.Write("<Td>");
writer.Write("<A href='" + strUrl + "'>" + strTitle + "</A>");
writer.Write("</Td>");
writer.Write("<Td>");
if (sQueryItem["Status"] != null)
{
strStatus = sQueryItem["Status"].ToString().Substring(sQueryItem["Status"].ToString().LastIndexOf("#") + 1);
}
else
{
strStatus = "--";
}
writer.Write(strStatus);
writer.Write("</Td>");
writer.Write("<Td>");
if (sQueryItem["Priority"] != null)
{
strPriority = sQueryItem["Priority"].ToString().Substring(sQueryItem["Priority"].ToString().LastIndexOf("#") + 1);
}
else
{
strPriority = "--";
}
writer.Write(strPriority);
writer.Write("</Td>");
writer.Write("</Tr>");
}
}
else
{
writer.Write("<Tr>");
writer.Write("<Td colspan='3' align='Center'>");
writer.Write("There are no Active Tasks");
writer.Write("</Td>");
writer.Write("</Tr>");
}
}
else
{
writer.Write("<Tr>");
writer.Write("<Td colspan='3' align='Center'>");
writer.Write("Taks List Not available");
writer.Write("</Td>");
writer.Write("</Tr>");
}
writer.Write("</Table>");
No comments:
Post a Comment