using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web.UI.WebControls;
using BLL;
using Model;
using Newtonsoft.Json.Linq;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Performance
{
public partial class Performance : PageBase
{
#region 定义项
///
/// 主键
///
public string PerformanceGid
{
get
{
return (string)ViewState["PerformanceGid"];
}
set
{
ViewState["PerformanceGid"] = value;
}
}
public string CompileDateMonth
{
get
{
return (string)ViewState["CompileDateMonth"];
}
set
{
ViewState["CompileDateMonth"] = value;
}
}
public string CreateUser
{
get
{
return (string)ViewState["CreateUser"];
}
set
{
ViewState["CreateUser"] = value;
}
}
#endregion
///
/// 页面加载
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CreateUser = CurrUser.UserId;
BindGrid();
OutputSummaryData();
}
}
private void OutputSummaryData()
{
decimal EvaScore = 0;
EvaScore = Funs.DB.CQMS_Performance_Child1.Where(x => x.PerformanceGid == PerformanceGid).Sum(x => x.EvaScore) ?? 0;
JObject summary = new JObject();
//summary.Add("Major", "全部合计");
summary.Add("EvaScore", EvaScore.ToString("F2"));
Grid1.SummaryData = summary;
}
///
/// 加载表头
///
protected void Page_Init(object sender, EventArgs e)
{
CreateUser = CurrUser.UserId;
drpCompileDateMonth.Text = DateTime.Now.ToString();
if (string.IsNullOrEmpty(CompileDateMonth))
{
CompileDateMonth = Request.QueryString["CompileDateMonth"];
if (!string.IsNullOrEmpty(CompileDateMonth))
{
drpCompileDateMonth.Text = CompileDateMonth;
}
}
else {
drpCompileDateMonth.Text = CompileDateMonth;
}
InitGrid();
}
#region 加载表头
string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
private void InitGrid()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var NowDate = Convert.ToDateTime(drpCompileDateMonth.Text.Trim());
var Year = NowDate.Year;
var Month = 1;
if (NowDate.Month != 12)
{
Month = NowDate.Month + 1;
}
else {
Year += 1;
}
//获取配置
var modelConfig = Funs.DB.CQMS_Performance_SetUp.FirstOrDefault(x => x.CreateYear == Year.ToString() && x.SortIndex == Month);
if (modelConfig != null)
{
int child3Index = 1;
//先加载周,再加载周里面的天数
for (int i = 1; i <= modelConfig.SetUpWeek; i++)
{
#region 第?周任务安排、工程量、人材机资源需求计划
BoundField bf = new BoundField();
bf.Width = Unit.Pixel(150);
bf.DataField = "TaskContent" + i.ToString();
bf.ColumnID = "TaskContent" + i.ToString();
bf.HeaderText = "第" + i.ToString() + "周施工工作任务安排";
bf.TextAlign = TextAlign.Center;
Grid1.Columns.Add(bf);
bf = new BoundField();
bf.Width = Unit.Pixel(100);
bf.DataField = "ProjectQuantity" + i.ToString();
bf.ColumnID = "ProjectQuantity" + i.ToString();
bf.HeaderText = "工程量";
Grid1.Columns.Add(bf);
bf = new BoundField();
bf.Width = Unit.Pixel(150);
bf.DataField = "DemandPlan" + i.ToString();
bf.ColumnID = "DemandPlan" + i.ToString();
bf.HeaderText = "人材机资源需求计划";
Grid1.Columns.Add(bf);
#endregion
var month = Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Year + "-" + Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Month;
if (Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Month.ToString().Length == 1)
{
month = Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Year + "-0" + Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Month;
}
//1.先获取主表的基础数据
var modelCQMS_Performance = db.CQMS_Performance.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId
&& x.CreateDateMonth == month && x.CreateMan == CreateUser);
if (modelCQMS_Performance != null)
{
PerformanceGid = modelCQMS_Performance.PerformanceGid;
}
else {
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
var Child2Model = db.CQMS_Performance_Child2.FirstOrDefault(x => x.NowWeek == i && x.CreateMan == CreateUser && x.PerformanceGid== PerformanceGid);
if (Child2Model==null)
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
//获取当前周的gid
var Child2Gid = Child2Model.Performance_ChildGid2;
//根据周gid获取天数
var listChild3 = db.CQMS_Performance_Child3.Where(x => x.Performance_ChildGid2 == Child2Gid
&& x.CreateMan==CreateUser).OrderBy(x => x.CurrentDate).ToList();
if (listChild3.Count==0)
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
foreach (var item in listChild3)
{
var Cdate = Convert.ToDateTime(item.CurrentDate);
string week = Day[Convert.ToInt32(Cdate.DayOfWeek.ToString("d"))].ToString();
//头部
GroupField p = new GroupField();
p.Width = Unit.Pixel(200);
p.HeaderText = week + "(" + Cdate.Month + "月" + Cdate.Day + "日)";
p.TextAlign = TextAlign.Left;
BoundField gzjh = new BoundField();
gzjh.Width = Unit.Pixel(200);
gzjh.HeaderText = "本日工作计划";
gzjh.DataField = "WorkPlan" + child3Index.ToString();
gzjh.ColumnID = "WorkPlan" + child3Index.ToString();
gzjh.TextAlign = TextAlign.Center;
BoundField wcqk = new BoundField();
wcqk.Width = Unit.Pixel(200);
wcqk.HeaderText = "本日完成情况";
wcqk.DataField = "CompletStatus" + child3Index.ToString();
wcqk.ColumnID = "CompletStatus" + child3Index.ToString();
p.Columns.Add(gzjh);
p.Columns.Add(wcqk);
Grid1.Columns.Add(p);
child3Index += 1;
}
bf = new BoundField();
bf.Width = Unit.Pixel(150);
bf.DataField = "TaskCompletContent" + i.ToString();
bf.ColumnID = "TaskCompletContent" + i.ToString();
bf.HeaderText = "本周工作任务完成情况";
Grid1.Columns.Add(bf);
}
}
else {
ShowNotify("当前日期未设置规则,请前往施工绩效设置页面进行操作。", MessageBoxIcon.Warning);
//PageContext.RegisterStartupScript("CloseRefresh()");
return;
}
}
}
#endregion
#region 合并单元格定义项
///
/// 第一行的gid 为了合并单元格用
///
public string OneGid
{
get
{
return (string)ViewState["OneGid"];
}
set
{
ViewState["OneGid"] = value;
}
}
public string Gid2
{
get
{
return (string)ViewState["Gid2"];
}
set
{
ViewState["Gid2"] = value;
}
}
public string Gid3
{
get
{
return (string)ViewState["Gid3"];
}
set
{
ViewState["Gid3"] = value;
}
}
public string Gid4
{
get
{
return (string)ViewState["Gid4"];
}
set
{
ViewState["Gid4"] = value;
}
}
public string Gid5
{
get
{
return (string)ViewState["Gid5"];
}
set
{
ViewState["Gid5"] = value;
}
}
public string Gid6
{
get
{
return (string)ViewState["Gid6"];
}
set
{
ViewState["Gid6"] = value;
}
}
public int child2Count
{
get
{
return Convert.ToInt32(ViewState["child2Count"]);
}
set
{
ViewState["child2Count"] = value;
}
}
#endregion
#region 加载表格数据
///
/// 加载表格的实体类
///
public class GridModels {
public string Performance_ChildGid1 { get; set; }
public string PerformanceGid { get; set; }
public string PType { get; set; }
public decimal? EvaScore { get; set; }
public string Itemize { get; set; }
public string WorkArea { get; set; }
public string MonthTarget { get; set; }
public int? SortIndex { get; set; }
#region 任务安排 下标9;工程量 14;材机资源需求计划 19
public string Performance_ChildGid2 { get; set; }
//任务安排 下标9
public string TaskContent1 { get; set; }
public string TaskContent2 { get; set; }
public string TaskContent3 { get; set; }
public string TaskContent4 { get; set; }
public string TaskContent5 { get; set; }
//工程量 14
public string ProjectQuantity1 { get; set; }
public string ProjectQuantity2 { get; set; }
public string ProjectQuantity3 { get; set; }
public string ProjectQuantity4 { get; set; }
public string ProjectQuantity5 { get; set; }
//材机资源需求计划 19
public string DemandPlan1 { get; set; }
public string DemandPlan2 { get; set; }
public string DemandPlan3 { get; set; }
public string DemandPlan4 { get; set; }
public string DemandPlan5 { get; set; }
//本周工作任务完成情况 24
public string TaskCompletContent1 { get; set; }
public string TaskCompletContent2 { get; set; }
public string TaskCompletContent3 { get; set; }
public string TaskCompletContent4 { get; set; }
public string TaskCompletContent5 { get; set; }
#endregion
#region 每天任务完成情况 下标29
public string WorkPlan1 { get; set; }
public string WorkPlan2 { get; set; }
public string WorkPlan3 { get; set; }
public string WorkPlan4 { get; set; }
public string WorkPlan5 { get; set; }
public string WorkPlan6 { get; set; }
public string WorkPlan7 { get; set; }
public string WorkPlan8 { get; set; }
public string WorkPlan9 { get; set; }
public string WorkPlan10 { get; set; }
public string WorkPlan11 { get; set; }
public string WorkPlan12 { get; set; }
public string WorkPlan13 { get; set; }
public string WorkPlan14 { get; set; }
public string WorkPlan15 { get; set; }
public string WorkPlan16 { get; set; }
public string WorkPlan17 { get; set; }
public string WorkPlan18 { get; set; }
public string WorkPlan19 { get; set; }
public string WorkPlan20 { get; set; }
public string WorkPlan21 { get; set; }
public string WorkPlan22 { get; set; }
public string WorkPlan23 { get; set; }
public string WorkPlan24 { get; set; }
public string WorkPlan25 { get; set; }
public string WorkPlan26 { get; set; }
public string WorkPlan27 { get; set; }
public string WorkPlan28 { get; set; }
public string WorkPlan29 { get; set; }
public string WorkPlan30 { get; set; }
public string WorkPlan31 { get; set; }
public string WorkPlan32 { get; set; }
public string WorkPlan33 { get; set; }
#endregion
#region 本日完成情况 下标 62
public string CompletStatus1 { get; set; }
public string CompletStatus2 { get; set; }
public string CompletStatus3 { get; set; }
public string CompletStatus4 { get; set; }
public string CompletStatus5 { get; set; }
public string CompletStatus6 { get; set; }
public string CompletStatus7 { get; set; }
public string CompletStatus8 { get; set; }
public string CompletStatus9 { get; set; }
public string CompletStatus10 { get; set; }
public string CompletStatus11 { get; set; }
public string CompletStatus12 { get; set; }
public string CompletStatus13 { get; set; }
public string CompletStatus14 { get; set; }
public string CompletStatus15 { get; set; }
public string CompletStatus16 { get; set; }
public string CompletStatus17 { get; set; }
public string CompletStatus18 { get; set; }
public string CompletStatus19 { get; set; }
public string CompletStatus20 { get; set; }
public string CompletStatus21 { get; set; }
public string CompletStatus22 { get; set; }
public string CompletStatus23 { get; set; }
public string CompletStatus24 { get; set; }
public string CompletStatus25 { get; set; }
public string CompletStatus26 { get; set; }
public string CompletStatus27 { get; set; }
public string CompletStatus28 { get; set; }
public string CompletStatus29 { get; set; }
public string CompletStatus30 { get; set; }
public string CompletStatus31 { get; set; }
public string CompletStatus32 { get; set; }
public string CompletStatus33 { get; set; }
#endregion
#region 定义索引
//定义索引器,name 字段的索引值为 0 ,password 字段的索引值为 1
public string this[int index]
{
#region get
get
{
if (index == 0)
{
return WorkPlan1;
}
else if (index == 1)
{
return WorkPlan2;
}
else if (index == 2)
{
return WorkPlan3;
}
else if (index == 3)
{
return WorkPlan4;
}
else if (index == 4)
{
return WorkPlan5;
}
else if (index == 5)
{
return WorkPlan6;
}
else if (index == 6)
{
return WorkPlan7;
}
else if (index == 7)
{
return WorkPlan8;
}
else if (index == 8)
{
return WorkPlan9;
}
else if (index == 9)
{
return WorkPlan10;
}
else if (index == 10)
{
return WorkPlan11;
}
else if (index == 11)
{
return WorkPlan12;
}
else if (index == 12)
{
return WorkPlan13;
}
else if (index == 13)
{
return WorkPlan14;
}
else if (index == 14)
{
return WorkPlan15;
}
else if (index == 15)
{
return WorkPlan16;
}
else if (index == 16)
{
return WorkPlan17;
}
else if (index == 17)
{
return WorkPlan18;
}
else if (index == 18)
{
return WorkPlan19;
}
else if (index == 19)
{
return WorkPlan20;
}
else if (index == 20)
{
return WorkPlan21;
}
else if (index == 21)
{
return WorkPlan22;
}
else if (index == 22)
{
return WorkPlan23;
}
else if (index == 23)
{
return WorkPlan24;
}
else if (index == 24)
{
return WorkPlan25;
}
else if (index == 25)
{
return WorkPlan26;
}
else if (index == 26)
{
return WorkPlan27;
}
else if (index == 27)
{
return WorkPlan28;
}
else if (index == 28)
{
return WorkPlan29;
}
else if (index == 29)
{
return WorkPlan30;
}
else if (index == 30)
{
return WorkPlan31;
}
else if (index == 31)
{
return WorkPlan32;
}
else if (index == 32)
{
return CompletStatus1;
}
else if (index == 33)
{
return CompletStatus2;
}
else if (index == 34)
{
return CompletStatus3;
}
else if (index == 35)
{
return CompletStatus4;
}
else if (index == 36)
{
return CompletStatus5;
}
else if (index == 37)
{
return CompletStatus6;
}
else if (index == 38)
{
return CompletStatus7;
}
else if (index == 39)
{
return CompletStatus8;
}
else if (index == 40)
{
return CompletStatus9;
}
else if (index == 41)
{
return CompletStatus10;
}
else if (index == 42)
{
return CompletStatus11;
}
else if (index == 43)
{
return CompletStatus12;
}
else if (index == 44)
{
return CompletStatus13;
}
else if (index == 45)
{
return CompletStatus14;
}
else if (index == 46)
{
return CompletStatus15;
}
else if (index == 47)
{
return CompletStatus16;
}
else if (index == 48)
{
return CompletStatus17;
}
else if (index == 49)
{
return CompletStatus18;
}
else if (index == 50)
{
return CompletStatus19;
}
else if (index == 51)
{
return CompletStatus20;
}
else if (index == 52)
{
return CompletStatus21;
}
else if (index == 53)
{
return CompletStatus22;
}
else if (index == 54)
{
return CompletStatus23;
}
else if (index == 55)
{
return CompletStatus24;
}
else if (index == 56)
{
return CompletStatus25;
}
else if (index == 57)
{
return CompletStatus26;
}
else if (index == 58)
{
return CompletStatus27;
}
else if (index == 59)
{
return CompletStatus28;
}
else if (index == 60)
{
return CompletStatus29;
}
else if (index == 61)
{
return CompletStatus30;
}
else if (index == 62)
{
return CompletStatus31;
}
else if (index == 63)
{
return CompletStatus32;
}
else { return null; }
#endregion
}
set
{
if (index == 0)
{
WorkPlan1 = value;
}
else if (index == 1)
{
WorkPlan2 = value;
}
else if (index == 2)
{
WorkPlan3 = value;
}
else if (index == 3)
{
WorkPlan4 = value;
}
else if (index == 4)
{
WorkPlan5 = value;
}
else if (index == 5)
{
WorkPlan6 = value;
}
else if (index == 6)
{
WorkPlan7 = value;
}
else if (index == 7)
{
WorkPlan8 = value;
}
else if (index == 8)
{
WorkPlan9 = value;
}
else if (index == 9)
{
WorkPlan10 = value;
}
else if (index == 10)
{
WorkPlan11 = value;
}
else if (index == 11)
{
WorkPlan12 = value;
}
else if (index == 12)
{
WorkPlan13 = value;
}
else if (index == 13)
{
WorkPlan14 = value;
}
else if (index == 14)
{
WorkPlan15 = value;
}
else if (index == 15)
{
WorkPlan16 = value;
}
else if (index == 16)
{
WorkPlan17 = value;
}
else if (index == 17)
{
WorkPlan18 = value;
}
else if (index == 18)
{
WorkPlan19 = value;
}
else if (index == 19)
{
WorkPlan20 = value;
}
else if (index == 20)
{
WorkPlan21 = value;
}
else if (index == 21)
{
WorkPlan22 = value;
}
else if (index == 22)
{
WorkPlan23 = value;
}
else if (index == 23)
{
WorkPlan24 = value;
}
else if (index == 24)
{
WorkPlan25 = value;
}
else if (index == 25)
{
WorkPlan26 = value;
}
else if (index == 26)
{
WorkPlan27 = value;
}
else if (index == 27)
{
WorkPlan28 = value;
}
else if (index == 28)
{
WorkPlan29 = value;
}
else if (index == 29)
{
WorkPlan30 = value;
}
else if (index == 30)
{
WorkPlan31 = value;
}
else if (index == 31)
{
WorkPlan32 = value;
}
else if (index == 32)
{
CompletStatus1 = value;
}
else if (index == 33)
{
CompletStatus2 = value;
}
else if (index == 34)
{
CompletStatus3 = value;
}
else if (index == 35)
{
CompletStatus4 = value;
}
else if (index == 36)
{
CompletStatus5 = value;
}
else if (index == 37)
{
CompletStatus6 = value;
}
else if (index == 38)
{
CompletStatus7 = value;
}
else if (index == 39)
{
CompletStatus8 = value;
}
else if (index == 40)
{
CompletStatus9 = value;
}
else if (index == 41)
{
CompletStatus10 = value;
}
else if (index == 42)
{
CompletStatus11 = value;
}
else if (index == 43)
{
CompletStatus12 = value;
}
else if (index == 44)
{
CompletStatus13 = value;
}
else if (index == 45)
{
CompletStatus14 = value;
}
else if (index == 46)
{
CompletStatus15 = value;
}
else if (index == 47)
{
CompletStatus16 = value;
}
else if (index == 48)
{
CompletStatus17 = value;
}
else if (index == 49)
{
CompletStatus18 = value;
}
else if (index == 50)
{
CompletStatus19 = value;
}
else if (index == 51)
{
CompletStatus20 = value;
}
else if (index == 52)
{
CompletStatus21 = value;
}
else if (index == 53)
{
CompletStatus22 = value;
}
else if (index == 54)
{
CompletStatus23 = value;
}
else if (index == 55)
{
CompletStatus24 = value;
}
else if (index == 56)
{
CompletStatus25 = value;
}
else if (index == 57)
{
CompletStatus26 = value;
}
else if (index == 58)
{
CompletStatus27 = value;
}
else if (index == 59)
{
CompletStatus28 = value;
}
else if (index == 60)
{
CompletStatus29 = value;
}
else if (index == 61)
{
CompletStatus30 = value;
}
else if (index == 62)
{
CompletStatus31 = value;
}
else if (index == 63)
{
CompletStatus32 = value;
}
}
}
#endregion
}
private void BindGrid()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var month = Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Year + "-" + Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Month;
if (Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Month.ToString().Length==1)
{
month = Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Year + "-0" + Convert.ToDateTime(drpCompileDateMonth.Text.Trim()).Month;
}
//1.先获取主表的基础数据
var modelCQMS_Performance = db.CQMS_Performance.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId
&& x.CreateDateMonth == month && x.CreateMan== CreateUser);
if (modelCQMS_Performance != null)
{
Grid1.Title= "五环责任人:" + modelCQMS_Performance.HeadUserid + ";本月完成专业产值:" +
modelCQMS_Performance.ProOutputValue + "万元;分包商负责人:" +
modelCQMS_Performance.SubUserids + ";分包工程师、班组长:" + modelCQMS_Performance.SubpackageUserids;
PerformanceGid = modelCQMS_Performance.PerformanceGid;
//根据主键查询CQMS_Performance_Child1
var listChild1 = db.CQMS_Performance_Child1.Where(x => x.PerformanceGid == PerformanceGid).OrderBy(x => x.SortIndex)
.Select(x=> new GridModels {
Performance_ChildGid1=x.Performance_ChildGid1,
PerformanceGid=x.PerformanceGid,
PType=x.PType,
EvaScore=x.EvaScore,
Itemize=x.Itemize,
WorkArea=x.WorkArea,
MonthTarget=x.MonthTarget,
SortIndex=x.SortIndex
}).ToList();
#region 合并单元格参数
//获取各行的gid
OneGid = listChild1[0].Performance_ChildGid1;
Gid2 = listChild1[1].Performance_ChildGid1;
Gid3 = listChild1[2].Performance_ChildGid1;
Gid4 = listChild1[3].Performance_ChildGid1;
Gid5 = listChild1[4].Performance_ChildGid1;
Gid6 = listChild1[5].Performance_ChildGid1;
//获取CQMS_Performance_Child2 表中的数据
int child2Count = db.CQMS_Performance_Child2.Where(x => x.NowWeek == 1 && x.PerformanceGid == PerformanceGid).ToList().Count();
#endregion
//加载各周任务、工程量、人材机、完成情况
//根据gid获取CQMS_Performance_Child2 施工进度管理的子表数据,大于一条,就要多增加数据到List中
var ChildSgjdCount = db.CQMS_Performance_Child2.Where(x => x.NowWeek == 1 && x.PerformanceGid == PerformanceGid
&&x.Performance_ChildGid1== OneGid).ToList().Count();
for (int i = 0; i < ChildSgjdCount-1; i++)
{
var addList = db.CQMS_Performance_Child1.Where(x => x.PerformanceGid == PerformanceGid && x.SortIndex == 1)
.Select(x => new GridModels
{
Performance_ChildGid1 = x.Performance_ChildGid1,
PerformanceGid = x.PerformanceGid,
PType = x.PType,
EvaScore = x.EvaScore,
Itemize = x.Itemize,
WorkArea = x.WorkArea,
MonthTarget = x.MonthTarget,
SortIndex = x.SortIndex
}).ToList();
addList[0].Performance_ChildGid1 = addList[0].Performance_ChildGid1 + "one"+i.ToString();
listChild1.InsertRange(i+1, addList);
}
//if (ChildSgjdCount == 2)
//{
// addList[0].Performance_ChildGid1 = addList[0].Performance_ChildGid1 + "one";
// listChild1.InsertRange(1, addList);
//}
//else if (ChildSgjdCount == 3)
//{
// var pgid = addList[0].Performance_ChildGid1;
// addList[0].Performance_ChildGid1 = pgid + "one";
// listChild1.InsertRange(1, addList);
// addList[0].Performance_ChildGid1 = pgid + "two";
// listChild1.InsertRange(2, addList);
//}
//循环list给每周任务、工程量、资源需求计划、本周工作任务完成情况 ,每日工作计划、完成情况赋值
//获取周数
var NowDate = Convert.ToDateTime(drpCompileDateMonth.Text.Trim());
var Year = NowDate.Year;
var Month = 1;
if (NowDate.Month != 12)
{
Month = NowDate.Month + 1;
}
else {
Year += 1;
}
var modelConfig = Funs.DB.CQMS_Performance_SetUp.FirstOrDefault(x => x.CreateYear == Year.ToString() && x.SortIndex == Month);
for (int i = 0; i < listChild1.Count; i++)
{
var CompletStatusIndex = 32;
var zIndex = 0;
//循环周数-
for (int y = 0; y < modelConfig.SetUpWeek; y++)
{
var chilGid = listChild1[i].Performance_ChildGid1;
if (chilGid.IndexOf("one")>-1|| chilGid.IndexOf("two") > -1)
{
chilGid = chilGid.Substring(0, chilGid.Length - 4);
}
//根据周数获取数据
var Child2ListNew = db.CQMS_Performance_Child2.FirstOrDefault(x => x.PerformanceGid == listChild1[i].PerformanceGid
&& x.Performance_ChildGid1 == chilGid && x.NowWeek == (y + 1) && x.SortIndex == (i + 1));
//将list中的周数数据插入
if (Child2ListNew==null)
{
ShowNotify("数据有误。请重新生成", MessageBoxIcon.Warning);
return;
}
switch (y)
{
case 0:
listChild1[i].TaskContent1 = Child2ListNew.TaskContent;
listChild1[i].ProjectQuantity1 = Child2ListNew.ProjectQuantity;
listChild1[i].DemandPlan1 = Child2ListNew.DemandPlan;
listChild1[i].TaskCompletContent1= Child2ListNew.TaskCompletContent;
break;
case 1:
listChild1[i].TaskContent2 = Child2ListNew.TaskContent;
listChild1[i].ProjectQuantity2 = Child2ListNew.ProjectQuantity;
listChild1[i].DemandPlan2 = Child2ListNew.DemandPlan;
listChild1[i].TaskCompletContent2 = Child2ListNew.TaskCompletContent;
break;
case 2:
listChild1[i].TaskContent3 = Child2ListNew.TaskContent;
listChild1[i].ProjectQuantity3 = Child2ListNew.ProjectQuantity;
listChild1[i].DemandPlan3 = Child2ListNew.DemandPlan;
listChild1[i].TaskCompletContent3 = Child2ListNew.TaskCompletContent;
break;
case 3:
listChild1[i].TaskContent4 = Child2ListNew.TaskContent;
listChild1[i].ProjectQuantity4 = Child2ListNew.ProjectQuantity;
listChild1[i].DemandPlan4 = Child2ListNew.DemandPlan;
listChild1[i].TaskCompletContent4 = Child2ListNew.TaskCompletContent;
break;
case 4:
listChild1[i].TaskContent5 = Child2ListNew.TaskContent;
listChild1[i].ProjectQuantity5 = Child2ListNew.ProjectQuantity;
listChild1[i].DemandPlan5 = Child2ListNew.DemandPlan;
listChild1[i].TaskCompletContent5 = Child2ListNew.TaskCompletContent;
break;
}
#region 根据周id获取日
var Child3ListNew = db.CQMS_Performance_Child3.Where(x => x.Performance_ChildGid2 == Child2ListNew.Performance_ChildGid2)
.OrderBy(x => x.CurrentDate).ToList();
for (var z = 0; z < Child3ListNew.Count; z++)
{
listChild1[i][zIndex] = Child3ListNew[z].WorkPlan;
listChild1[i][CompletStatusIndex] = Child3ListNew[z].CompletStatus;
CompletStatusIndex += 1;
zIndex += 1;
}
#endregion
}
}
//重新给list设置 序号
int sindex = 1;
listChild1.ForEach(x =>
{
x.SortIndex = sindex;
sindex += 1;
});
var table = ToDataTable(listChild1);
Grid1.DataSource = table;
Grid1.DataBind();
#region 合并单元格
var DateIffs = DateDiff(Convert.ToDateTime(modelConfig.SetUpStartDate), Convert.ToDateTime(modelConfig.SetUpEndDate))+1;
if (ChildSgjdCount > 1)
{
//合并单元格方法
PageContext.RegisterStartupScript("onGridDataLoad('" + OneGid + "','" + child2Count + "','" + Gid2 + "','"
+ Gid3 + "','" + Gid4 + "','" + Gid5 + "','" + Gid6 + "','"+ ChildSgjdCount + "','"+ modelConfig.SetUpWeek + "',"+ DateIffs + ")");
}
else {
//合并单元格方法
PageContext.RegisterStartupScript("onGridDataLoad('" + OneGid + "','" + child2Count + "','" + Gid2 + "','"
+ Gid3 + "','" + Gid4 + "','" + Gid5 + "','" + Gid6 + "',0,'" + modelConfig.SetUpWeek + "'," + DateIffs + ")");
}
#endregion
}
else
{
var NowDate = Convert.ToDateTime(drpCompileDateMonth.Text.Trim());
var Year = NowDate.Year;
var Month = 1;
if (NowDate.Month != 12)
{
Month = NowDate.Month + 1;
}
else
{
Year += 1;
}
//获取配置
var modelConfig = Funs.DB.CQMS_Performance_SetUp.FirstOrDefault(x => x.CreateYear == Year.ToString() && x.SortIndex == Month);
if (modelConfig==null)
{
return;
}
if (string.IsNullOrEmpty(CurrUser.LoginProjectId))
{
ShowNotify("未查询到当前项目,请刷新页面重试。", MessageBoxIcon.Warning);
}
else
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
}
}
}
}
///
/// 计算日期之间的天数
///
///
///
///
private int DateDiff(DateTime dateStart, DateTime dateEnd)
{
DateTime start = Convert.ToDateTime(dateStart.ToShortDateString());
DateTime end = Convert.ToDateTime(dateEnd.ToShortDateString());
TimeSpan sp = end.Subtract(start);
return sp.Days;
}
#endregion
///
/// 查询绑定数据
///
///
///
protected void btnBindGrid(object sender, EventArgs e)
{
var Rurl = Request.Url.ToString();
if (Rurl.IndexOf("?")>-1)
{
Rurl = Rurl.Substring(0, Rurl.IndexOf("?"));
}
//重定向当前页面传值
Response.Redirect(Rurl + "?CompileDateMonth="+ drpCompileDateMonth.Text);
//BindGrid();
}
///
/// 判断生成操作
///
protected void btnNew_Juge(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.drpCompileDateMonth.Text.Trim()))
{
ShowNotify("日期不能为空。", MessageBoxIcon.Warning);
PageContext.RegisterStartupScript("CloseRefresh()");
return;
}
var dates = Convert.ToDateTime(drpCompileDateMonth.Text.Trim());
var Year = dates.Year;
var Month = 1;
if (dates.Month != 12)
{
Month = dates.Month + 1;
}
else
{
Year += 1;
}
//按照日期查询是否有设置
var modelConfig = Funs.DB.CQMS_Performance_SetUp.FirstOrDefault(x => x.CreateYear == Year.ToString() && x.SortIndex == Month);
if (modelConfig == null)
{
ShowNotify("当前日期未设置规则,请前往施工绩效设置页面进行操作。", MessageBoxIcon.Warning);
PageContext.RegisterStartupScript("CloseRefresh()");
return;
}
//根据日期查询是否有数据
var modelSum = Funs.DB.CQMS_Performance.Where(x => x.CreateDateMonth == drpCompileDateMonth.Text.Trim() && x.ProjectId == CurrUser.LoginProjectId&&x.CreateMan== CreateUser).FirstOrDefault();
//查到数据,二次确认
if (modelSum != null)
{
PageContext.RegisterStartupScript(Confirm.GetShowReference("该日期已生成数据,是否确认重新生成?", String.Empty, MessageBoxIcon.Question,
PageManager1.GetCustomEventReference("Confirmgd_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
//PageContext.RegisterStartupScript("CloseRefresh()");
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PerformanceEdit.aspx?CreateDateMonth=" + drpCompileDateMonth.Text.Trim(), ""),
"新增", Unit.Parse("1000px"), Unit.Parse("800px")));
}
}
///
/// 确认按钮
///
///
///
protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
{
if (e.EventArgument == "Confirmgd_OK")
{
// 根据日期查询是否有数据
var modelSum = Funs.DB.CQMS_Performance.Where(x => x.CreateDateMonth == drpCompileDateMonth.Text.Trim()
&& x.ProjectId == CurrUser.LoginProjectId && x.CreateMan == CreateUser).FirstOrDefault();
if (modelSum != null)
{
//删除数据
PerformanceService.Delete(modelSum.PerformanceGid);
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PerformanceEdit.aspx?CreateDateMonth="
+ drpCompileDateMonth.Text.Trim(), ""), "新增", Unit.Parse("1000px"), Unit.Parse("800px")));
}
//BindGrid();
//btnNew_Click();
}
}
#region list转换datatable
///
/// Convert a List{T} to a DataTable.
///
private DataTable ToDataTable(List items)
{
var tb = new DataTable(typeof(T).Name);
PropertyInfo[] props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo prop in props)
{
Type t = GetCoreType(prop.PropertyType);
tb.Columns.Add(prop.Name, t);
}
foreach (T item in items)
{
var values = new object[props.Length];
for (int i = 0; i < props.Length-1; i++)
{
values[i] = props[i].GetValue(item, null);
}
tb.Rows.Add(values);
}
return tb;
}
///
/// Determine of specified type is nullable
///
public static bool IsNullable(Type t)
{
return !t.IsValueType || (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>));
}
///
/// Return underlying type if type is Nullable otherwise return the type
///
public static Type GetCoreType(Type t)
{
if (t != null && IsNullable(t))
{
if (!t.IsValueType)
{
return t;
}
else
{
return Nullable.GetUnderlyingType(t);
}
}
else
{
return t;
}
}
#endregion
protected void Window1_Close(object sender, EventArgs e)
{
BindGrid();
OutputSummaryData();
}
///
/// 修改月节点目标
///
///
///
protected void btnMonthTarget(object sender, EventArgs e) {
if (string.IsNullOrEmpty(PerformanceGid))
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else {
//查询状态是否是0 不是0的不允许修改
var model = Funs.DB.CQMS_Performance.FirstOrDefault(x => x.PerformanceGid == PerformanceGid);
if (model == null)
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else {
if (CurrUser.UserId != Const.sysglyId && CurrUser.UserId != Const.hfnbdId)
{
if (model.States != "0")
{
ShowNotify("当前数据已经提交,不允许修改。", MessageBoxIcon.Warning);
return;
}
}
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthTargetEdit.aspx?PerformanceGid=" + PerformanceGid, ""),
"修改月节点目标", Unit.Parse("1000px"), Unit.Parse("800px")));
}
}
///
/// 修改各周工作任务
///
///
///
protected void btnTaskContent(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(PerformanceGid))
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else
{
//查询状态是否是0 不是0的不允许修改
var model = Funs.DB.CQMS_Performance.FirstOrDefault(x => x.PerformanceGid == PerformanceGid);
if (model == null)
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else
{
if (CurrUser.UserId != Const.sysglyId && CurrUser.UserId != Const.hfnbdId)
{
if (model.States != "0")
{
ShowNotify("当前数据已经提交,不允许修改。", MessageBoxIcon.Warning);
return;
}
}
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TaskContentEdit.aspx?PerformanceGid=" + PerformanceGid+ "&CreateDateMonth="+ drpCompileDateMonth.Text.Trim(), ""),
"修改各周工作任务", Unit.Parse("1000px"), Unit.Parse("800px")));
}
}
///
///
///
///
///
protected void btnWorkPlan(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(PerformanceGid))
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else
{
//查询状态是否是0 不是0的不允许修改
var model = Funs.DB.CQMS_Performance.FirstOrDefault(x => x.PerformanceGid == PerformanceGid);
if (model == null)
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else
{
if (CurrUser.UserId != Const.sysglyId && CurrUser.UserId != Const.hfnbdId)
{
if (model.States != "0")
{
ShowNotify("当前数据已经提交,不允许修改。", MessageBoxIcon.Warning);
return;
}
}
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WorkPlanEdit.aspx?PerformanceGid=" + PerformanceGid + "&CreateDateMonth=" + drpCompileDateMonth.Text.Trim(), ""),
"填写每日工作计划", Unit.Parse("1000px"), Unit.Parse("800px")));
}
}
///
/// 提交打分
///
///
///
protected void btnSubmit(object sender, EventArgs e) {
if (string.IsNullOrEmpty(PerformanceGid))
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else {
var model = Funs.DB.CQMS_Performance.FirstOrDefault(x => x.PerformanceGid == PerformanceGid);
if (model.States == "1")
{
ShowNotify("无需重复提交。", MessageBoxIcon.Warning);
return;
}
else {
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PerformanceSubmit.aspx?PerformanceGid=" + PerformanceGid + "&CreateDateMonth=" + drpCompileDateMonth.Text.Trim(), ""),
"提交报表", Unit.Parse("440px"), Unit.Parse("300px")));
//model.States = "1";
//Funs.DB.SubmitChanges();
//ShowNotify("提交成功,请等待领导打分。", MessageBoxIcon.Success);
}
}
}
///
/// 修改出差天数
///
///
///
protected void btnDays_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(PerformanceGid))
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else
{
//查询状态是否是0 不是0的不允许修改
var model = Funs.DB.CQMS_Performance.FirstOrDefault(x => x.PerformanceGid == PerformanceGid);
if (model == null)
{
ShowNotify("未查询到数据,请先生成表单。", MessageBoxIcon.Warning);
return;
}
else
{
if (CurrUser.UserId != Const.sysglyId && CurrUser.UserId != Const.hfnbdId)
{
if (model.States != "0")
{
ShowNotify("当前数据已经提交,不允许修改。", MessageBoxIcon.Warning);
return;
}
}
}
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("OutDayEdit.aspx?PerformanceGid=" + PerformanceGid, ""),
"修改出差天数", Unit.Parse("440px"), Unit.Parse("300px")));
}
}
#region 导出excel
///
/// 格式化html
///
///
///
private string GetGridTableHtml(Grid grid)
{
StringBuilder sb = new StringBuilder();
MultiHeaderTable mht = new MultiHeaderTable();
mht.ResolveMultiHeaderTable(Grid1.Columns);
sb.Append("");
sb.Append("");
////列数
//var rowCount = "";
//var list = Funs.DB.Base_Project.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).OrderBy(x => x.ProjectCode).ToList();
//for (int i = 0; i < list.Count; i++)
//{
// rowCount+="{}"
//}
foreach (List
");
return sb.ToString();
}
public static string MidStrEx(string sourse, string startstr, string endstr)
{
string result = string.Empty;
int startindex, endindex;
try
{
startindex = sourse.IndexOf(startstr);
if (startindex == -1)
return result;
string tmpstr = sourse.Substring(startindex + startstr.Length);
endindex = tmpstr.IndexOf(endstr);
if (endindex == -1)
return result;
result = tmpstr.Remove(endindex);
}
catch (Exception ex)
{
}
return result;
}
#region 多表头处理
///
/// 处理多表头的类
///
public class MultiHeaderTable
{
// 包含 rowspan,colspan 的多表头,方便生成 HTML 的 table 标签
public List> MultiTable = new List>();
// 最终渲染的列数组
public List Columns = new List();
public void ResolveMultiHeaderTable(GridColumnCollection columns)
{
List