CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/CQMS/Performance/PerformanceEdit.aspx.cs

929 lines
45 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Performance
{
public partial class PerformanceEdit : PageBase
{
#region
/// <summary>
/// 日期
/// </summary>
public string CreateDateMonth
{
get
{
return (string)ViewState["CreateDateMonth"];
}
set
{
ViewState["CreateDateMonth"] = value;
}
}
public string PerformanceGid
{
get
{
return (string)ViewState["PerformanceGid"];
}
set
{
ViewState["PerformanceGid"] = value;
}
}
public int stepIndex
{
get
{
return Convert.ToInt32(ViewState["stepIndex"]);
}
set
{
ViewState["stepIndex"] = value;
}
}
public string CreateUser
{
get
{
return (string)ViewState["CreateUser"];
}
set
{
ViewState["CreateUser"] = value;
}
}
public string CreateProject
{
get
{
return (string)ViewState["CreateProject"];
}
set
{
ViewState["CreateProject"] = value;
}
}
public int TaskCount
{
get
{
return (int)ViewState["TaskCount"];
}
set
{
ViewState["TaskCount"] = value;
}
}
#endregion
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
JArray teamGroupData = Grid1.GetMergedData();
List<JObject> list = new List<JObject>();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
values.Add("Performance_ChildGid2", teamGroupRow.Value<string>("id"));
list.Add(values);
}
JObject defaultObj = new JObject
{ { "Performance_ChildGid2",Guid.NewGuid() },
{ "TaskContent", "" },
{ "ProjectQuantity", "" },
{ "DemandPlan",""},
{ "Delete", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", GetDeleteScript(), IconHelper.GetResolvedIconUrl(Icon.Delete)) }
};
list.Add(defaultObj);
Grid1.DataSource = list;
Grid1.DataBind();
#region
//stepIndex = 2;
//SimpleForm1.Hidden = true;
//SimpleForm2.Hidden = true;
//SimpleForm3.Hidden = true;
//SimpleForm4.Hidden = true;
//SimpleForm5.Hidden = true;
//SimpleForm6.Hidden = true;
//SimpleForm7.Hidden = true;
//pForm1.Hidden = false;
//Form2.Hidden = false;
//Form3.Hidden = false;
//Form4.Hidden = false;
//Form5.Hidden = false;
//Form6.Hidden = false;
#endregion
CreateDateMonth = Request.Params["CreateDateMonth"];
this.drpCompileDateMonth.Text = CreateDateMonth;
CreateUser = CurrUser.UserId;
CreateProject = CurrUser.LoginProjectId;
}
}
#region Performance_ChildGid1表的gid
public string Performance_ChildGid1Sg
{
get
{
return (string)ViewState["Performance_ChildGid1Sg"];
}
set
{
ViewState["Performance_ChildGid1Sg"] = value;
}
}
public string Performance_ChildGid1Hse
{
get
{
return (string)ViewState["Performance_ChildGid1Hse"];
}
set
{
ViewState["Performance_ChildGid1Hse"] = value;
}
}
public string Performance_ChildGid1Zl
{
get
{
return (string)ViewState["Performance_ChildGid1Zl"];
}
set
{
ViewState["Performance_ChildGid1Zl"] = value;
}
}
public string Performance_ChildGid1Tz
{
get
{
return (string)ViewState["Performance_ChildGid1Tz"];
}
set
{
ViewState["Performance_ChildGid1Tz"] = value;
}
}
public string Performance_ChildGid1Gj
{
get
{
return (string)ViewState["Performance_ChildGid1Gj"];
}
set
{
ViewState["Performance_ChildGid1Gj"] = value;
}
}
public string Performance_ChildGid1Kjf
{
get
{
return (string)ViewState["Performance_ChildGid1Kjf"];
}
set
{
ViewState["Performance_ChildGid1Kjf"] = value;
}
}
#endregion
/// <summary>
/// 下一步
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNextOne_Click(object sender, EventArgs e)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
if (stepIndex == 0)
{
if (string.IsNullOrEmpty(PerformanceGid))
{
if (string.IsNullOrEmpty(CurrUser.LoginProjectId))
{
ShowNotify("未查询到当前项目,请刷新页面重试。", MessageBoxIcon.Warning);
return;
}
//第一步,插入主表
Model.CQMS_Performance modelP = new Model.CQMS_Performance();
PerformanceGid = Guid.NewGuid().ToString();
modelP.PerformanceGid = PerformanceGid;
modelP.HeadUserid = txtHeadUserid.Text.Trim();
//if (!string.IsNullOrEmpty(txtProOutputValue.Text.Trim()))
//{
// modelP.ProOutputValue = Convert.ToDecimal(txtProOutputValue.Text.Trim());
//}
//else {
// modelP.ProOutputValue = 0;
//}
modelP.WorkRange = txtWorkRange.Text.Trim();
modelP.SubUserids = txtSubUserids.Text.Trim();
modelP.SubpackageUserids = txtSubpackageUserids.Text.Trim();
modelP.TotalScore = 0;
modelP.ProjectId = CurrUser.LoginProjectId;
modelP.CreateDateMonth = drpCompileDateMonth.Text.Trim();
modelP.CreateDate = Convert.ToDateTime(drpCompileDateMonth.Text.Trim());
modelP.CreateMan = CreateUser;
modelP.States = "0";
db.CQMS_Performance.InsertOnSubmit(modelP);
db.SubmitChanges();
#region 1
List<Model.CQMS_Performance_Child1> listC1 = new List<Model.CQMS_Performance_Child1>();
Model.CQMS_Performance_Child1 modelP1 = new Model.CQMS_Performance_Child1();
Performance_ChildGid1Sg = Guid.NewGuid().ToString();
modelP1.Performance_ChildGid1 = Performance_ChildGid1Sg;
modelP1.PerformanceGid = PerformanceGid;
modelP1.PType = "进度、质量、费用管理综合";
modelP1.EvaScore = 0;
modelP1.Itemize = "施工进度管理权重40%";
modelP1.WorkArea = "";
modelP1.MonthTarget = "";
modelP1.SortIndex = 1;
modelP1.CreateMan = CreateUser;
listC1.Add(modelP1);
modelP1 = new Model.CQMS_Performance_Child1();
Performance_ChildGid1Hse = Guid.NewGuid().ToString();
modelP1.Performance_ChildGid1 = Performance_ChildGid1Hse;
modelP1.PerformanceGid = PerformanceGid;
modelP1.PType = "进度、质量、费用管理综合";
modelP1.EvaScore = 0;
modelP1.Itemize = "HSE管理个人安全行动计划完情况)权重15 %";
modelP1.WorkArea = "";
modelP1.MonthTarget = "";
modelP1.SortIndex = 2;
modelP1.CreateMan = CreateUser;
listC1.Add(modelP1);
modelP1 = new Model.CQMS_Performance_Child1();
Performance_ChildGid1Zl = Guid.NewGuid().ToString();
modelP1.Performance_ChildGid1 = Performance_ChildGid1Zl;
modelP1.PerformanceGid = PerformanceGid;
modelP1.PType = "进度、质量、费用管理综合";
modelP1.EvaScore = 0;
modelP1.Itemize = "质量管理情况质量检查计划及实施权重20 %";
modelP1.WorkArea = "";
modelP1.MonthTarget = "";
modelP1.SortIndex = 3;
modelP1.CreateMan = CreateUser;
listC1.Add(modelP1);
modelP1 = new Model.CQMS_Performance_Child1();
Performance_ChildGid1Tz = Guid.NewGuid().ToString();
modelP1.Performance_ChildGid1 = Performance_ChildGid1Tz;
modelP1.PerformanceGid = PerformanceGid;
modelP1.PType = "进度、质量、费用管理综合";
modelP1.EvaScore = 0;
modelP1.Itemize = "图纸、材料状态跟踪;统计台账权重5%";
modelP1.WorkArea = "";
modelP1.MonthTarget = "";
modelP1.SortIndex = 4;
modelP1.CreateMan = CreateUser;
listC1.Add(modelP1);
modelP1 = new Model.CQMS_Performance_Child1();
Performance_ChildGid1Gj = Guid.NewGuid().ToString();
modelP1.Performance_ChildGid1 = Performance_ChildGid1Gj;
modelP1.PerformanceGid = PerformanceGid;
modelP1.PType = "进度、质量、费用管理综合";
modelP1.EvaScore = 0;
modelP1.Itemize = "关键事项跟踪权重5 %";
modelP1.WorkArea = "";
modelP1.MonthTarget = "";
modelP1.SortIndex = 5;
modelP1.CreateMan = CreateUser;
listC1.Add(modelP1);
modelP1 = new Model.CQMS_Performance_Child1();
Performance_ChildGid1Kjf = Guid.NewGuid().ToString();
modelP1.Performance_ChildGid1 = Performance_ChildGid1Kjf;
modelP1.PerformanceGid = PerformanceGid;
modelP1.PType = "进度、质量、费用管理综合";
modelP1.EvaScore = 0;
modelP1.Itemize = "可交付成果工程签证、费用审核、方案审编、计划编制技术总结等权重15%";
modelP1.WorkArea = "";
modelP1.MonthTarget = "";
modelP1.SortIndex = 6;
modelP1.CreateMan = CreateUser;
listC1.Add(modelP1);
db.CQMS_Performance_Child1.InsertAllOnSubmit(listC1);
db.SubmitChanges();
#endregion
}
//隐藏第一步
//显示第二步
SimpleForm1.Hidden = true;
SimpleForm2.Hidden = false;
SimpleForm3.Hidden = false;
SimpleForm4.Hidden = false;
SimpleForm5.Hidden = false;
SimpleForm6.Hidden = false;
SimpleForm7.Hidden = false;
stepIndex = 1;
string[] ValidateForms = { "SimpleForm2", "SimpleForm3", "SimpleForm4", "SimpleForm5", "SimpleForm6", "SimpleForm7" };
Button2.ValidateForms = ValidateForms;
}
else if (stepIndex == 1)
{
#region
if (string.IsNullOrEmpty(txtWorkArea.Text))
{
Alert.ShowInTop("施工进度管理-施工区域不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(txtMonthTarget1.Text))
{
Alert.ShowInTop("施工进度管理-月节点目标不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(txtMonthTarget2.Text))
{
Alert.ShowInTop("HSE管理-月节点目标不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(txtMonthTarget3.Text))
{
Alert.ShowInTop("质量管理情况-月节点目标不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(txtMonthTarget4.Text))
{
Alert.ShowInTop("图纸、材料状态跟踪;统计台账-月节点目标不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(txtMonthTarget5.Text))
{
Alert.ShowInTop("关键事项跟踪-月节点目标不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(txtMonthTarget6.Text))
{
Alert.ShowInTop("可交付成果-月节点目标不能为空。", MessageBoxIcon.Warning);
return;
}
#endregion
#region 1
//首先根据主表id获取到信息
var Child1List = db.CQMS_Performance_Child1.Where(x => x.PerformanceGid == PerformanceGid).OrderBy(x => x.SortIndex).ToList();
//施工进度管理
var modelC0 = Child1List[0];
//施工区域
modelC0.WorkArea = txtWorkArea.Text.Trim();
modelC0.MonthTarget = txtMonthTarget1.Text.Trim();
//修改
db.SubmitChanges();
//HSE管理
var modelC1 = Child1List[1];
modelC1.MonthTarget = txtMonthTarget2.Text.Trim();
db.SubmitChanges();
//质量管理情况
var modelC2 = Child1List[2];
modelC2.MonthTarget = txtMonthTarget3.Text.Trim();
db.SubmitChanges();
//施工进度管理
var modelC3 = Child1List[3];
modelC3.MonthTarget = txtMonthTarget4.Text.Trim();
db.SubmitChanges();
//施工进度管理
var modelC4 = Child1List[4];
modelC4.MonthTarget = txtMonthTarget5.Text.Trim();
db.SubmitChanges();
//施工进度管理
var modelC5 = Child1List[5];
modelC5.MonthTarget = txtMonthTarget6.Text.Trim();
db.SubmitChanges();
#endregion
//下一步生成每一周的任务安排、工程量、人材机资源需求计划
//隐藏生成施工区域/工序、月节点目标
#region /
SimpleForm2.Hidden = true;
SimpleForm3.Hidden = true;
SimpleForm4.Hidden = true;
SimpleForm5.Hidden = true;
SimpleForm6.Hidden = true;
SimpleForm7.Hidden = true;
pForm1.Hidden = false;
Form2.Hidden = false;
Form3.Hidden = false;
Form4.Hidden = false;
Form5.Hidden = false;
Form6.Hidden = false;
#endregion
stepIndex = 2;
Button2.Text = "生成";
string[] ValidateForms = { "pForm1", "Form2", "Form3", "Form4", "Form5", "Form6" };
Button2.ValidateForms = ValidateForms;
}
else if (stepIndex == 2)
{
#region
//var TaskContent1 = txtTaskContent1.Text.Trim();
//var ProjectQuantity1 = txtProjectQuantity1.Text.Trim();
//var DemandPlan1 = txtDemandPlan1.Text.Trim();
//var TaskContent2 = txtTaskContent2.Text.Trim();
//var ProjectQuantity2 = txtProjectQuantity2.Text.Trim();
//var DemandPlan2 = txtDemandPlan2.Text.Trim();
//var TaskContent3 = txtTaskContent3.Text.Trim();
//var ProjectQuantity3 = txtProjectQuantity3.Text.Trim();
//var DemandPlan3 = txtDemandPlan3.Text.Trim();
var TaskContentHse = txtTaskContentHse.Text.Trim();
var TaskContentZl = txtTaskContentZl.Text.Trim();
var TaskContentTz = txtTaskContentTz.Text.Trim();
var TaskContentGjsx = txtTaskContentGjsx.Text.Trim();
var TaskContentJf = txtTaskContentJf.Text.Trim();
#endregion
#region
//if (string.IsNullOrEmpty(TaskContent1))
//{
// Alert.ShowInTop("施工进度管理-各周工作任务安排不能为空。", MessageBoxIcon.Warning);
// return;
//}
if (string.IsNullOrEmpty(TaskContentHse))
{
Alert.ShowInTop("HSE管理-各周工作任务安排不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(TaskContentZl))
{
Alert.ShowInTop("质量管理情况-各周工作任务安排不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(TaskContentTz))
{
Alert.ShowInTop("图纸、材料状态跟踪;统计台账-各周工作任务安排不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(TaskContentGjsx))
{
Alert.ShowInTop("关键事项跟踪-各周工作任务安排不能为空。", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(TaskContentJf))
{
Alert.ShowInTop("可交付成果-各周工作任务安排不能为空。", MessageBoxIcon.Warning);
return;
}
#endregion
var datesConfig = Convert.ToDateTime(drpCompileDateMonth.Text.Trim());
var Month = 1;
var nowYear = datesConfig.Year;
if (datesConfig.Month != 12)
{
Month = datesConfig.Month + 1;
}
else
{
nowYear += 1;
}
var Child2SortIndex = 1;
//按照日期查询是否有设置
var modelConfig = Funs.DB.CQMS_Performance_SetUp.FirstOrDefault(x => x.CreateYear == nowYear.ToString() && x.SortIndex == Month);
if (modelConfig != null)
{
//根据设置的周数插入表格CQMS_Performance_Child2
List<Model.CQMS_Performance_Child2> listChild2 = new List<Model.CQMS_Performance_Child2>();
for (int i = 0; i < modelConfig.SetUpWeek; i++)
{
Model.CQMS_Performance_Child2 modelChild2 = new Model.CQMS_Performance_Child2();
#region
JArray teamGroupData = Grid1.GetMergedData();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
int rowIndex = teamGroupRow.Value<int>("index");
modelChild2 = new Model.CQMS_Performance_Child2();
modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
modelChild2.Performance_ChildGid1 = Performance_ChildGid1Sg;
modelChild2.PerformanceGid = PerformanceGid;
modelChild2.TaskContent = values.Value<string>("TaskContent");
modelChild2.ProjectQuantity = values.Value<string>("ProjectQuantity");
modelChild2.DemandPlan = values.Value<string>("DemandPlan");
modelChild2.NowWeek = (i + 1);
modelChild2.SortIndex = Child2SortIndex;
modelChild2.CreateMan = CreateUser;
listChild2.Add(modelChild2);
Child2SortIndex += 1;
}
var SgCountModel = db.CQMS_Performance.FirstOrDefault(x => x.PerformanceGid == PerformanceGid);
if (Child2SortIndex!=1)
{
Child2SortIndex = Child2SortIndex - 1;
}
SgCountModel.SgCount = Child2SortIndex;
db.SubmitChanges();
#endregion
//施工进度管理
//modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
//modelChild2.Performance_ChildGid1 = Performance_ChildGid1Sg;
//modelChild2.PerformanceGid = PerformanceGid;
////modelChild2.TaskContent = TaskContent1;
////modelChild2.ProjectQuantity = ProjectQuantity1;
////modelChild2.DemandPlan = DemandPlan1;
//modelChild2.NowWeek = (i + 1);
//modelChild2.SortIndex = Child2SortIndex;
//modelChild2.CreateMan = CreateUser;
//listChild2.Add(modelChild2);
#region 2
//if (!string.IsNullOrEmpty(TaskContent2))
//{
// modelChild2 = new Model.CQMS_Performance_Child2();
// modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
// modelChild2.Performance_ChildGid1 = Performance_ChildGid1Sg;
// modelChild2.PerformanceGid = PerformanceGid;
// modelChild2.TaskContent = TaskContent2;
// modelChild2.ProjectQuantity = ProjectQuantity2;
// modelChild2.DemandPlan = DemandPlan2;
// modelChild2.NowWeek = (i + 1);
// Child2SortIndex += 1;
// modelChild2.CreateMan = CreateUser;
// modelChild2.SortIndex = Child2SortIndex;
// listChild2.Add(modelChild2);
//}
//if (!string.IsNullOrEmpty(TaskContent3))
//{
// modelChild2 = new Model.CQMS_Performance_Child2();
// modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
// modelChild2.Performance_ChildGid1 = Performance_ChildGid1Sg;
// modelChild2.PerformanceGid = PerformanceGid;
// modelChild2.TaskContent = TaskContent3;
// modelChild2.ProjectQuantity = ProjectQuantity3;
// modelChild2.DemandPlan = DemandPlan3;
// modelChild2.NowWeek = (i + 1);
// Child2SortIndex += 1;
// modelChild2.SortIndex = Child2SortIndex;
// modelChild2.CreateMan = CreateUser;
// listChild2.Add(modelChild2);
//}
#endregion
//HSE管理
modelChild2 = new Model.CQMS_Performance_Child2();
modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
modelChild2.Performance_ChildGid1 = Performance_ChildGid1Hse;
modelChild2.PerformanceGid = PerformanceGid;
modelChild2.TaskContent = TaskContentHse;
modelChild2.ProjectQuantity = TaskContentHse;
modelChild2.DemandPlan = TaskContentHse;
modelChild2.NowWeek = (i + 1);
Child2SortIndex += 1;
modelChild2.SortIndex = Child2SortIndex;
modelChild2.CreateMan = CreateUser;
listChild2.Add(modelChild2);
//质量管理情况
modelChild2 = new Model.CQMS_Performance_Child2();
modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
modelChild2.Performance_ChildGid1 = Performance_ChildGid1Zl;
modelChild2.PerformanceGid = PerformanceGid;
modelChild2.TaskContent = TaskContentZl;
modelChild2.ProjectQuantity = TaskContentZl;
modelChild2.DemandPlan = TaskContentZl;
modelChild2.NowWeek = (i + 1);
Child2SortIndex += 1;
modelChild2.SortIndex = Child2SortIndex;
modelChild2.CreateMan = CreateUser;
listChild2.Add(modelChild2);
//图纸、材料状态跟踪
modelChild2 = new Model.CQMS_Performance_Child2();
modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
modelChild2.Performance_ChildGid1 = Performance_ChildGid1Tz;
modelChild2.PerformanceGid = PerformanceGid;
modelChild2.TaskContent = TaskContentTz;
modelChild2.ProjectQuantity = TaskContentTz;
modelChild2.DemandPlan = TaskContentTz;
modelChild2.NowWeek = (i + 1);
Child2SortIndex += 1;
modelChild2.SortIndex = Child2SortIndex;
modelChild2.CreateMan = CreateUser;
listChild2.Add(modelChild2);
//关键事项跟踪
modelChild2 = new Model.CQMS_Performance_Child2();
modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
modelChild2.Performance_ChildGid1 = Performance_ChildGid1Gj;
modelChild2.PerformanceGid = PerformanceGid;
modelChild2.TaskContent = TaskContentGjsx;
modelChild2.ProjectQuantity = TaskContentGjsx;
modelChild2.DemandPlan = TaskContentGjsx;
modelChild2.NowWeek = (i + 1);
Child2SortIndex += 1;
modelChild2.SortIndex = Child2SortIndex;
modelChild2.CreateMan = CreateUser;
listChild2.Add(modelChild2);
//可交付成果
modelChild2 = new Model.CQMS_Performance_Child2();
modelChild2.Performance_ChildGid2 = Guid.NewGuid().ToString();
modelChild2.Performance_ChildGid1 = Performance_ChildGid1Kjf;
modelChild2.PerformanceGid = PerformanceGid;
modelChild2.TaskContent = TaskContentJf;
modelChild2.ProjectQuantity = TaskContentJf;
modelChild2.DemandPlan = TaskContentJf;
modelChild2.NowWeek = (i + 1);
Child2SortIndex += 1;
modelChild2.SortIndex = Child2SortIndex;
modelChild2.CreateMan = CreateUser;
listChild2.Add(modelChild2);
Child2SortIndex = 1;
}
db.CQMS_Performance_Child2.InsertAllOnSubmit(listChild2);
db.SubmitChanges();
//根据CQMS_Performance_Child2的周数循环插入CQMS_Performance_Child3
//开始日期
var StartDate = Convert.ToDateTime(modelConfig.SetUpStartDate).AddDays(-1);
var EndDate = Convert.ToDateTime(modelConfig.SetUpEndDate);
//循环CQMS_Performance_Child2
//按周排序 第一次循环1、2、3、4等等
listChild2 = listChild2.OrderBy(x => x.NowWeek).ToList();
List<Model.CQMS_Performance_Child3> listChild3 = new List<Model.CQMS_Performance_Child3>();
//循环递增的天数
#region
//第一周最后的天数
var OneWeekDate = Convert.ToDateTime(modelConfig.SetUpStartDate);
//第二周最后的天数
var OneWeekDate1 = Convert.ToDateTime(modelConfig.SetUpStartDate);
//第三周最后的天数
var OneWeekDate2 = Convert.ToDateTime(modelConfig.SetUpStartDate);
//第四周最后的天数
var OneWeekDate3 = Convert.ToDateTime(modelConfig.SetUpStartDate);
#endregion
var OneWeekStartDate = Convert.ToDateTime(modelConfig.SetUpStartDate);
foreach (var item in listChild2)
{
Model.CQMS_Performance_Child3 modelChild3 = new Model.CQMS_Performance_Child3();
//如果是最后一周
if (item.NowWeek == modelConfig.SetUpWeek)
{
//最后一周的前一周
if (item.NowWeek == 4)
{
OneWeekDate2 = OneWeekDate1;
for (var i = OneWeekDate2.AddDays(1); i <= EndDate; i = i.AddDays(1))
{
modelChild3 = new Model.CQMS_Performance_Child3();
StartDate = i;
modelChild3.Performance_ChildGid3 = Guid.NewGuid().ToString();
modelChild3.Performance_ChildGid2 = item.Performance_ChildGid2;
modelChild3.PerformanceGid = PerformanceGid;
modelChild3.WorkPlan = "";
modelChild3.CompletStatus = "";
modelChild3.CurrentDate = StartDate;
modelChild3.CreateMan = CreateUser;
modelChild3.ProjectId = CreateProject;
listChild3.Add(modelChild3);
}
}
else if (item.NowWeek == 5)
{
OneWeekDate3 = OneWeekDate2;
for (var i = OneWeekDate3.AddDays(1); i <= EndDate; i = i.AddDays(1))
{
modelChild3 = new Model.CQMS_Performance_Child3();
StartDate = i;
modelChild3.Performance_ChildGid3 = Guid.NewGuid().ToString();
modelChild3.Performance_ChildGid2 = item.Performance_ChildGid2;
modelChild3.PerformanceGid = PerformanceGid;
modelChild3.WorkPlan = "";
modelChild3.CompletStatus = "";
modelChild3.CurrentDate = StartDate;
modelChild3.CreateMan = CreateUser;
modelChild3.ProjectId = CreateProject;
listChild3.Add(modelChild3);
}
}
}
else
{
switch (item.NowWeek)
{
case 1:
#region
//循环的天数
var Xhi = 1;
switch (OneWeekStartDate.DayOfWeek)
{
//星期天
case DayOfWeek.Sunday:
Xhi = 8;
break;
//星期一
case DayOfWeek.Monday:
Xhi = 7;
break;
//星期二
case DayOfWeek.Tuesday:
Xhi = 6;
break;
//星期三
case DayOfWeek.Wednesday:
Xhi = 5;
break;
//星期四
case DayOfWeek.Thursday:
Xhi = 4;
break;
//星期五
case DayOfWeek.Friday:
Xhi = 10;
break;
//星期六
case DayOfWeek.Saturday:
Xhi = 9;
break;
}
#endregion
StartDate = Convert.ToDateTime(modelConfig.SetUpStartDate).AddDays(-1);
//第一周的数据
for (int i = 0; i < Xhi; i++)
{
StartDate = StartDate.AddDays(1);
modelChild3 = new Model.CQMS_Performance_Child3();
modelChild3.Performance_ChildGid3 = Guid.NewGuid().ToString();
modelChild3.Performance_ChildGid2 = item.Performance_ChildGid2;
modelChild3.PerformanceGid = PerformanceGid;
modelChild3.WorkPlan = "";
modelChild3.CompletStatus = "";
modelChild3.CurrentDate = StartDate;
modelChild3.CreateMan = CreateUser;
modelChild3.ProjectId = CreateProject;
listChild3.Add(modelChild3);
}
OneWeekDate = StartDate;
break;
case 2:
OneWeekDate = StartDate;
//第2周的数据
for (int i = 0; i < 7; i++)
{
//第一周最后的日期
OneWeekDate = OneWeekDate.AddDays(1);
modelChild3 = new Model.CQMS_Performance_Child3();
modelChild3.Performance_ChildGid3 = Guid.NewGuid().ToString();
modelChild3.Performance_ChildGid2 = item.Performance_ChildGid2;
modelChild3.PerformanceGid = PerformanceGid;
modelChild3.WorkPlan = "";
modelChild3.CompletStatus = "";
modelChild3.CurrentDate = OneWeekDate;
modelChild3.CreateMan = CreateUser;
modelChild3.ProjectId = CreateProject;
listChild3.Add(modelChild3);
}
OneWeekDate1 = OneWeekDate;
break;
case 3:
OneWeekDate1 = OneWeekDate;
//第3周的数据
for (int i = 0; i < 7; i++)
{
modelChild3 = new Model.CQMS_Performance_Child3();
OneWeekDate1 = OneWeekDate1.AddDays(1);
modelChild3.Performance_ChildGid3 = Guid.NewGuid().ToString();
modelChild3.Performance_ChildGid2 = item.Performance_ChildGid2;
modelChild3.PerformanceGid = PerformanceGid;
modelChild3.WorkPlan = "";
modelChild3.CompletStatus = "";
modelChild3.CurrentDate = OneWeekDate1;
modelChild3.CreateMan = CreateUser;
modelChild3.ProjectId = CreateProject;
listChild3.Add(modelChild3);
}
OneWeekDate2 = OneWeekDate1;
break;
case 4:
OneWeekDate2 = OneWeekDate1;
//第4周的数据
for (int i = 0; i < 7; i++)
{
modelChild3 = new Model.CQMS_Performance_Child3();
OneWeekDate2 = OneWeekDate2.AddDays(1);
modelChild3.Performance_ChildGid3 = Guid.NewGuid().ToString();
modelChild3.Performance_ChildGid2 = item.Performance_ChildGid2;
modelChild3.PerformanceGid = PerformanceGid;
modelChild3.WorkPlan = "";
modelChild3.CompletStatus = "";
modelChild3.CurrentDate = OneWeekDate2;
modelChild3.CreateMan = CreateUser;
modelChild3.ProjectId = CreateProject;
listChild3.Add(modelChild3);
}
OneWeekDate3 = OneWeekDate2;
break;
}
}
}
db.CQMS_Performance_Child3.InsertAllOnSubmit(listChild3);
db.SubmitChanges();
//添加完成
ViewState["CompileDateMonth"] = drpCompileDateMonth.Text.Trim();
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
}
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
JArray teamGroupData = Grid1.GetMergedData();
List<JObject> list = new List<JObject>();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
values.Add("Performance_ChildGid2", teamGroupRow.Value<string>("id"));
list.Add(values);
}
JObject defaultObj = new JObject
{ { "Performance_ChildGid2",Guid.NewGuid() },
{ "TaskContent", "" },
{ "ProjectQuantity", "" },
{ "DemandPlan",""},
{ "Delete", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", GetDeleteScript(), IconHelper.GetResolvedIconUrl(Icon.Delete)) }
};
list.Add(defaultObj);
Grid1.DataSource = list;
Grid1.DataBind();
}
/// <summary>
/// 删除提示
/// </summary>
/// <returns></returns>
private string GetDeleteScript()
{
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question, Grid1.GetDeleteSelectedRowsReference(), String.Empty);
}
protected void Grid1_PreDataBound(object sender, EventArgs e)
{
// 设置LinkButtonField的点击客户端事件
LinkButtonField deleteField = Grid1.FindColumn("Delete") as LinkButtonField;
deleteField.OnClientClick = GetDeleteScript();
}
}
}