1902 lines
71 KiB
C#
1902 lines
71 KiB
C#
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 定义项
|
||
/// <summary>
|
||
/// 主键
|
||
/// </summary>
|
||
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
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 页面加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 加载表头
|
||
/// </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 合并单元格定义项
|
||
/// <summary>
|
||
/// 第一行的gid 为了合并单元格用
|
||
/// </summary>
|
||
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 加载表格数据
|
||
/// <summary>
|
||
/// 加载表格的实体类
|
||
/// </summary>
|
||
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<GridModels>(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);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 计算日期之间的天数
|
||
/// </summary>
|
||
/// <param name="dateStart"></param>
|
||
/// <param name="dateEnd"></param>
|
||
/// <returns></returns>
|
||
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
|
||
/// <summary>
|
||
/// 查询绑定数据
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 判断生成操作
|
||
/// </summary>
|
||
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")));
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 确认按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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
|
||
/// <summary>
|
||
/// Convert a List{T} to a DataTable.
|
||
/// </summary>
|
||
private DataTable ToDataTable<T>(List<T> 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;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Determine of specified type is nullable
|
||
/// </summary>
|
||
public static bool IsNullable(Type t)
|
||
{
|
||
return !t.IsValueType || (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>));
|
||
}
|
||
|
||
/// <summary>
|
||
/// Return underlying type if type is Nullable otherwise return the type
|
||
/// </summary>
|
||
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();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改月节点目标
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
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")));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改各周工作任务
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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")));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
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")));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 提交打分
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改出差天数
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
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
|
||
|
||
|
||
/// <summary>
|
||
/// 格式化html
|
||
/// </summary>
|
||
/// <param name="grid"></param>
|
||
/// <returns></returns>
|
||
private string GetGridTableHtml(Grid grid)
|
||
{
|
||
StringBuilder sb = new StringBuilder();
|
||
|
||
MultiHeaderTable mht = new MultiHeaderTable();
|
||
mht.ResolveMultiHeaderTable(Grid1.Columns);
|
||
|
||
|
||
sb.Append("<meta http-equiv=\"Content-Type\" content=\"application/vnd.ms-excel;charset=utf-8\"/>");
|
||
|
||
|
||
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||
|
||
////列数
|
||
//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<object[]> rows in mht.MultiTable)
|
||
{
|
||
sb.Append("<tr>");
|
||
foreach (object[] cell in rows)
|
||
{
|
||
int rowspan = Convert.ToInt32(cell[0]);
|
||
int colspan = Convert.ToInt32(cell[1]);
|
||
GridColumn column = cell[2] as GridColumn;
|
||
|
||
sb.AppendFormat("<th{0}{1}{2}>{3}</th>",
|
||
rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "",
|
||
colspan != 1 ? " colspan=\"" + colspan + "\"" : "",
|
||
colspan != 1 ? " style=\"text-align:center;\"" : "",
|
||
column.HeaderText);
|
||
}
|
||
sb.Append("</tr>");
|
||
}
|
||
|
||
int i = 0;
|
||
foreach (GridRow row in grid.Rows)
|
||
{
|
||
sb.Append("<tr>");
|
||
|
||
string MenuC = "";
|
||
int y = 1;
|
||
foreach (GridColumn column in mht.Columns)
|
||
{
|
||
string html = row.Values[column.ColumnIndex].ToString();
|
||
if (column.ColumnID == "tfNumber")
|
||
{
|
||
html = (row.FindControl("spanNumber") as System.Web.UI.HtmlControls.HtmlGenericControl).InnerText;
|
||
}
|
||
else if (column.ColumnID == "tfGender")
|
||
{
|
||
html = (row.FindControl("labGender") as AspNet.Label).Text;
|
||
}
|
||
else if (column.ColumnID == "MenuC")
|
||
{
|
||
MenuC = html;
|
||
}
|
||
#region 合并单元格
|
||
//合并类别
|
||
else if (column.ColumnID == "PType" && i == 0)
|
||
{
|
||
sb.AppendFormat("<td rowspan='" + grid.Rows.Count + "'>{0}</td>", html);
|
||
}
|
||
else if (column.ColumnID == "PType" && i != 0)
|
||
{
|
||
|
||
}
|
||
//合并分项
|
||
else if (column.ColumnID== "Itemize"&& row.Values[column.ColumnIndex].ToString().IndexOf("施工进度管理")==-1)
|
||
{
|
||
sb.AppendFormat("<td colspan='2'>{0}</td>", html);
|
||
}
|
||
//施工区域不显示
|
||
else if (column.ColumnID == "WorkArea" && row.Values[column.ColumnIndex - 1].ToString().IndexOf("施工进度管理") == -1)
|
||
{
|
||
|
||
}
|
||
//合并施工工作任务安排
|
||
else if (column.ColumnID.IndexOf("TaskContent")!=-1 && row.Values[3].ToString().IndexOf("施工进度管理") == -1)
|
||
{
|
||
sb.AppendFormat("<td colspan='3'>{0}</td>", html);
|
||
}
|
||
else if (column.ColumnID.IndexOf("ProjectQuantity") != -1 && row.Values[3].ToString().IndexOf("施工进度管理") == -1)
|
||
{
|
||
|
||
}
|
||
else if (column.ColumnID.IndexOf("DemandPlan") != -1 && row.Values[3].ToString().IndexOf("施工进度管理") == -1)
|
||
{
|
||
|
||
}
|
||
//合并本日工作计划
|
||
else if (column.ColumnID.IndexOf("WorkPlan") != -1 && row.Values[3].ToString().IndexOf("施工进度管理") == -1)
|
||
{
|
||
sb.AppendFormat("<td colspan='2'>{0}</td>", html);
|
||
}
|
||
else if (column.ColumnID.IndexOf("CompletStatus") != -1 && row.Values[3].ToString().IndexOf("施工进度管理") == -1)
|
||
{
|
||
|
||
}
|
||
else
|
||
{
|
||
sb.AppendFormat("<td>{0}</td>", html);
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
|
||
y += 1;
|
||
}
|
||
i += 1;
|
||
sb.Append("</tr>");
|
||
}
|
||
|
||
sb.Append("</table>");
|
||
|
||
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 多表头处理
|
||
|
||
/// <summary>
|
||
/// 处理多表头的类
|
||
/// </summary>
|
||
public class MultiHeaderTable
|
||
{
|
||
// 包含 rowspan,colspan 的多表头,方便生成 HTML 的 table 标签
|
||
public List<List<object[]>> MultiTable = new List<List<object[]>>();
|
||
// 最终渲染的列数组
|
||
public List<GridColumn> Columns = new List<GridColumn>();
|
||
|
||
|
||
public void ResolveMultiHeaderTable(GridColumnCollection columns)
|
||
{
|
||
List<object[]> row = new List<object[]>();
|
||
foreach (GridColumn column in columns)
|
||
{
|
||
object[] cell = new object[4];
|
||
cell[0] = 1; // rowspan
|
||
cell[1] = 1; // colspan
|
||
cell[2] = column;
|
||
cell[3] = null;
|
||
|
||
row.Add(cell);
|
||
}
|
||
|
||
ResolveMultiTable(row, 0);
|
||
|
||
ResolveColumns(row);
|
||
}
|
||
|
||
private void ResolveColumns(List<object[]> row)
|
||
{
|
||
foreach (object[] cell in row)
|
||
{
|
||
GroupField groupField = cell[2] as GroupField;
|
||
if (groupField != null && groupField.Columns.Count > 0)
|
||
{
|
||
List<object[]> subrow = new List<object[]>();
|
||
foreach (GridColumn column in groupField.Columns)
|
||
{
|
||
subrow.Add(new object[]
|
||
{
|
||
1,
|
||
1,
|
||
column,
|
||
groupField
|
||
});
|
||
}
|
||
|
||
ResolveColumns(subrow);
|
||
}
|
||
else
|
||
{
|
||
Columns.Add(cell[2] as GridColumn);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
private void ResolveMultiTable(List<object[]> row, int level)
|
||
{
|
||
List<object[]> nextrow = new List<object[]>();
|
||
|
||
foreach (object[] cell in row)
|
||
{
|
||
GroupField groupField = cell[2] as GroupField;
|
||
if (groupField != null && groupField.Columns.Count > 0)
|
||
{
|
||
// 如果当前列包含子列,则更改当前列的 colspan,以及增加父列(向上递归)的colspan
|
||
cell[1] = Convert.ToInt32(groupField.Columns.Count);
|
||
PlusColspan(level - 1, cell[3] as GridColumn, groupField.Columns.Count - 1);
|
||
|
||
foreach (GridColumn column in groupField.Columns)
|
||
{
|
||
nextrow.Add(new object[]
|
||
{
|
||
1,
|
||
1,
|
||
column,
|
||
groupField
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|
||
MultiTable.Add(row);
|
||
|
||
// 如果当前下一行,则增加上一行(向上递归)中没有子列的列的 rowspan
|
||
if (nextrow.Count > 0)
|
||
{
|
||
PlusRowspan(level);
|
||
|
||
ResolveMultiTable(nextrow, level + 1);
|
||
}
|
||
}
|
||
|
||
private void PlusRowspan(int level)
|
||
{
|
||
if (level < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
foreach (object[] cells in MultiTable[level])
|
||
{
|
||
GroupField groupField = cells[2] as GroupField;
|
||
if (groupField != null && groupField.Columns.Count > 0)
|
||
{
|
||
// ...
|
||
}
|
||
else
|
||
{
|
||
cells[0] = Convert.ToInt32(cells[0]) + 1;
|
||
}
|
||
}
|
||
|
||
PlusRowspan(level - 1);
|
||
}
|
||
|
||
private void PlusColspan(int level, GridColumn parent, int plusCount)
|
||
{
|
||
if (level < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
foreach (object[] cells in MultiTable[level])
|
||
{
|
||
GridColumn column = cells[2] as GridColumn;
|
||
if (column == parent)
|
||
{
|
||
cells[1] = Convert.ToInt32(cells[1]) + plusCount;
|
||
|
||
PlusColspan(level - 1, cells[3] as GridColumn, plusCount);
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
#endregion
|
||
/// <summary>
|
||
/// 导出exccel
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnOut_Click(object sender, EventArgs e) {
|
||
Response.ClearContent();
|
||
var projectname = ProjectService.GetProjectNameByProjectId(CurrUser.LoginProjectId);
|
||
var excelDate = Convert.ToDateTime(drpCompileDateMonth.Text).Year + "年" + Convert.ToDateTime(drpCompileDateMonth.Text).Month + "月";
|
||
var userName = CurrUser.UserName;
|
||
|
||
var FileName = projectname+"项目"+ excelDate+ "施工工程师("+ userName +")绩效考核数据表(暨施工日报表)";
|
||
Response.AddHeader("content-disposition", "attachment; filename=" + FileName + ".xls");
|
||
Response.ContentType = "application/vnd.ms-excel";
|
||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
Response.Write(GetGridTableHtml(Grid1));
|
||
Response.End();
|
||
}
|
||
}
|
||
} |