186 lines
6.7 KiB
C#
186 lines
6.7 KiB
C#
using BLL;
|
|
using NPOI.SS.Formula.Functions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.DataShow
|
|
{
|
|
public partial class JDWeekDetail : PageBase
|
|
{
|
|
#region 项目主键
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
public string WeekNo
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["WeekNo"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["WeekNo"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
}
|
|
Model.SGGLDB db = Funs.DB;
|
|
var lastWeek = (from x in db.JDGL_WeekPlan where x.ProjectId == this.ProjectId && DateTime.Now > ((DateTime)x.EndDate).AddDays(1) orderby x.EndDate descending select x).FirstOrDefault();
|
|
|
|
this.WeekNo = lastWeek != null ? lastWeek.WeekNo : string.Empty;
|
|
this.InitDropDownList();
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化下拉框
|
|
/// </summary>
|
|
private void InitDropDownList()
|
|
{
|
|
WeekItemService.InitWeekItemDropDownList(this.drpWeekNo, this.ProjectId, false);
|
|
if (!string.IsNullOrWhiteSpace(this.WeekNo))
|
|
{
|
|
var item = WeekItemService.GetWeekItemByProjectIdAndWeekNo(this.ProjectId, int.Parse(this.WeekNo));
|
|
if (item != null)
|
|
{
|
|
this.drpWeekNo.SelectedValue = item.WeekNo.ToString();
|
|
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", item.StartDate);
|
|
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", item.EndDate);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//获取当前时间所在周号,存在默认选中当前时间点所在周,否则选择最后一个周
|
|
var item = WeekItemService.GetWeekItemByDateNow(this.ProjectId);
|
|
if (item != null)
|
|
{//存在默认选中当前时间点所在周
|
|
this.drpWeekNo.SelectedValue = item.WeekNo.ToString();
|
|
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", item.StartDate);
|
|
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", item.EndDate);
|
|
}
|
|
else
|
|
{
|
|
var items = WeekItemService.GetWeekItemList(this.ProjectId);
|
|
if (items.Any())
|
|
{//否则选择最后一个周
|
|
item = items.First();
|
|
this.drpWeekNo.SelectedValue = item.WeekNo.ToString();
|
|
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", item.StartDate);
|
|
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", item.EndDate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 周号选择触发事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpWeekNo_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
string weekNo = this.drpWeekNo.SelectedValue;
|
|
this.WeekNo = weekNo;
|
|
var item = BLL.WeekItemService.GetWeekItemByProjectIdAndWeekNo(this.ProjectId, int.Parse(weekNo));
|
|
if (item != null)
|
|
{
|
|
this.drpWeekNo.SelectedValue = item.WeekNo.ToString();
|
|
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", item.StartDate);
|
|
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", item.EndDate);
|
|
}
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载Grid
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
DataTable tb = BindData();
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private DataTable BindData()
|
|
{
|
|
string strSql = @"select mp.*,u.UnitName,uw.UnitWorkName,cn.ProfessionalName,case mp.IsOK when 1 then '已完成' when 0 then '未完成' else '' end as IsOKStr
|
|
,DutyPersonName = STUFF((SELECT ',' + p.UserName FROM dbo.Sys_User as p where PATINDEX('%,' + RTRIM(p.UserId) + ',%', ',' + mp.DutyPerson + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
|
from [dbo].[JDGL_WeekPlan] mp
|
|
left join Base_Unit u on u.UnitId=mp.UnitId
|
|
left join WBS_UnitWork uw on uw.UnitWorkId=mp.UnitWork
|
|
left join Base_CNProfessional cn on cn.CNProfessionalId=mp.Major
|
|
where mp.ProjectId=@ProjectId and mp.WeekNo=@WeekNo order by mp.SortIndex";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
|
listStr.Add(new SqlParameter("@WeekNo", this.WeekNo));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
return tb;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox2_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
#region 表排序、分页、关闭窗口
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
} |