Basf_EProject/EProject/FineUIPro.Web/Report/MonthReport.aspx.cs

190 lines
6.6 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace FineUIPro.Web.Report
{
public partial class MonthReport : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetButtonPower();//权限设置
//项目类型
this.drpJobType.DataTextField = "ConstText";
this.drpJobType.DataValueField = "ConstValue";
this.drpJobType.DataSource = BLL.ConstService.GetConstListByGroupId(BLL.Const.ProjectPlanner_JobType);
this.drpJobType.DataBind();
Funs.FineUIPleaseSelectJobType(this.drpJobType);
//项目状态
this.drpJobStatus.DataTextField = "ConstText";
this.drpJobStatus.DataValueField = "ConstValue";
this.drpJobStatus.DataSource = BLL.ConstService.GetConstListByGroupId(BLL.Const.ProjectPlanner_JobStatus);
this.drpJobStatus.DataBind();
Funs.FineUIPleaseSelectJobStatus(this.drpJobStatus);
//this.btnPrint.OnClientClick = Window1.GetShowReference("MonthPrint.aspx") + "return false;";
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
// 绑定表格
BindGrid();
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = "SELECT EProjectId," +
"ProjectControl_JobNo," +
"ProjectControl_JobType," +
"ProjectControl_JobStatus," +
"ProjectControl_JobTitle," +
"ProjectControl_BUCode," +
"PM_General_Priority," +
"PM_General_Category " +
"FROM dbo.Editor_EProject WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim()))
{
strSql += " AND ProjectControl_JobNo LIKE @jobNo ";
listStr.Add(new SqlParameter("@jobNo", this.txtJobNo.Text.Trim() + "%"));
}
if (this.drpJobType.SelectedValue != BLL.Const._Null)
{
strSql += " AND ProjectControl_JobType=@JobType ";
listStr.Add(new SqlParameter("@JobType", this.drpJobType.SelectedItem.Text));
}
if (this.drpJobStatus.SelectedValue != BLL.Const._Null && this.drpJobStatus.SelectedValue != null)
{
strSql += " AND ProjectControl_JobStatus=@Status ";
listStr.Add(new SqlParameter("@Status", this.drpJobStatus.SelectedItem.Text));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#endregion
#region
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, EventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 菜单按钮权限
/// </summary>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.MonthReportMenuId);
if (buttonList.Count > 0)
{
if (buttonList.Contains(BLL.Const.BtnPrint))
{
this.btnPrint.Hidden = false;
}
}
}
#endregion
#region
protected void drpJobType_SelectedIndexChanged(object sender, EventArgs e)
{
this.drpJobStatus.Items.Clear();
if (drpJobType.SelectedText == "Other")
{
BLL.ConstService.InitConstValueProjectStatus(this.drpJobStatus, BLL.Const.ProjectPlanner_JobStatus, "3", true);
}
if (drpJobType.SelectedText != "Other")
{
BLL.ConstService.InitConstValueProjectStatus(this.drpJobStatus, BLL.Const.ProjectPlanner_JobStatus, "2", true);
}
}
/// <summary>
/// 下拉框选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click(object sender, EventArgs e)
{
BindGrid();
}
#endregion
protected void btnPrint_Click(object sender, EventArgs e)
{
string eprojectId = this.Grid1.SelectedRowID;
if (string.IsNullOrEmpty(eprojectId))
{
Alert.ShowInParent("Please select at least one record!");
return;
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ReportPrint.aspx?report=2&eProjectId={0}&parm={1}", eprojectId, "编辑 - ")));
}
}
}
}