730 lines
31 KiB
C#
730 lines
31 KiB
C#
using BLL;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Linq;
|
||
using System.Runtime.InteropServices.ComTypes;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace FineUIPro.Web.JDGL.Check
|
||
{
|
||
public partial class WeekPlanEdit : PageBase
|
||
{
|
||
/// <summary>
|
||
/// 项目id
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 本周周号
|
||
/// </summary>
|
||
public int ThisWeekNo
|
||
{
|
||
get
|
||
{
|
||
return (int)ViewState["ThisWeekNo"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ThisWeekNo"] = value;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 下周周号
|
||
/// </summary>
|
||
public int NextWeekNo
|
||
{
|
||
get
|
||
{
|
||
return (int)ViewState["NextWeekNo"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["NextWeekNo"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 页面加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
string weekNo = string.Empty;
|
||
if (!string.IsNullOrEmpty(Request.Params["WeekNo"]))
|
||
{
|
||
weekNo = Request.Params["WeekNo"];
|
||
}
|
||
this.ThisWeekNo = int.Parse(weekNo);
|
||
this.NextWeekNo = int.Parse(weekNo) + 1;
|
||
this.txtWeekNo.Text = this.ThisWeekNo.ToString();
|
||
this.txtNextWeekNo.Text = this.NextWeekNo.ToString();
|
||
|
||
|
||
UnitWorkService.InitUnitWorkList2(drpUnitWork, this.CurrUser.LoginProjectId, false);
|
||
CNProfessionalService.InitCNProfessional(drpMajor, false);
|
||
BLL.ProjectUnitService.InitUnitDropDownList2(drpUnitId, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, false);
|
||
UserService.Init(drpDutyPerson, CurrUser.LoginProjectId, false);
|
||
UnitWorkService.InitUnitWorkList2(drpUnitWork2, this.CurrUser.LoginProjectId, false);
|
||
CNProfessionalService.InitCNProfessional(drpMajor2, false);
|
||
BLL.ProjectUnitService.InitUnitDropDownList2(drpUnitId2, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, false);
|
||
UserService.Init(drpDutyPerson2, CurrUser.LoginProjectId, false);
|
||
|
||
|
||
DateTime now = DateTime.Now;
|
||
var thisWeek = BLL.WeekItemService.GetWeekItemByProjectIdAndWeekNo(this.CurrUser.LoginProjectId, this.ThisWeekNo);
|
||
|
||
var thisWeekPlan = Funs.DB.JDGL_WeekPlan.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.WeekNo == this.ThisWeekNo.ToString());
|
||
if (thisWeekPlan != null)
|
||
{
|
||
ThisWeekGrid();
|
||
if (now > ((DateTime)thisWeekPlan.EndDate).AddDays(1))//|| now < ((DateTime)thisWeekPlan.StartDate)
|
||
{//当前时间大于本周结束时间,禁止维护本周计划
|
||
this.btnNew2.Hidden = true;
|
||
this.Grid2.Columns[9].Hidden = true;
|
||
}
|
||
else if (now > ((DateTime)thisWeekPlan.StartDate))
|
||
{//当前时间大于本周开始时间,禁止删除本周计划(当前时间处于本周区间,禁止删除本周计划)
|
||
this.Grid2.Columns[9].Hidden = true;
|
||
}
|
||
}
|
||
|
||
if (now > thisWeek.EndDate.AddDays(1))// || now < thisWeek.StartDate
|
||
{//当前时间大于本周结束时间,禁止维护本周计划
|
||
this.btnNew2.Hidden = true;
|
||
this.Grid2.Columns[9].Hidden = true;
|
||
}
|
||
else if (now > thisWeek.StartDate)
|
||
{//当前时间大于本周开始时间小于本周结束时间,禁止删除本周计划(当前时间处于本周区间,禁止删除本周计划)
|
||
this.Grid2.Columns[9].Hidden = true;
|
||
}
|
||
|
||
var nextWeek = BLL.WeekItemService.GetWeekItemByProjectIdAndWeekNo(this.CurrUser.LoginProjectId, this.NextWeekNo);
|
||
var nextWeekPlan = Funs.DB.JDGL_WeekPlan.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.WeekNo == this.NextWeekNo.ToString());
|
||
if (nextWeekPlan != null)
|
||
{
|
||
NextWeekGrid();
|
||
if (now > ((DateTime)nextWeekPlan.EndDate).AddDays(1))
|
||
{//当前时间大于下周结束时间,禁止维护下周计划
|
||
this.Toolbar5.Hidden = true;
|
||
this.btnNew.Hidden = true;
|
||
this.btnSelectWeekPlan.Hidden = true;
|
||
this.Grid1.Columns[9].Hidden = true;
|
||
}
|
||
}
|
||
if (nextWeek != null)
|
||
{
|
||
if (now > nextWeek.EndDate.AddDays(1))//|| now < nextWeek.StartDate
|
||
{//当前时间大于下周结束时间,禁止维护下周计划
|
||
//this.btnNew2.Hidden = true;
|
||
//this.Grid2.Columns[9].Hidden = true;
|
||
this.Toolbar5.Hidden = true;
|
||
this.btnNew.Hidden = true;
|
||
this.btnSelectWeekPlan.Hidden = true;
|
||
this.Grid1.Columns[9].Hidden = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
#region 判断下周周号是否存在,不存在则新增
|
||
|
||
nextWeek = new Model.JDGL_WeekItem
|
||
{
|
||
WeekId = SQLHelper.GetNewID(typeof(Model.JDGL_WeekItem)),
|
||
ProjectId = this.CurrUser.LoginProjectId,
|
||
WeekNo = this.NextWeekNo,
|
||
StartDate = thisWeek.StartDate.AddDays(7),
|
||
EndDate = thisWeek.EndDate.AddDays(7),
|
||
CompileMan = this.CurrUser.UserId,
|
||
CompileDate = DateTime.Now,
|
||
};
|
||
BLL.WeekItemService.AddWeekItem(nextWeek);
|
||
|
||
#endregion
|
||
}
|
||
|
||
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", thisWeek.StartDate);
|
||
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", thisWeek.EndDate);
|
||
this.txtNextStartDate.Text = string.Format("{0:yyyy-MM-dd}", nextWeek.StartDate);
|
||
this.txtNextEndDate.Text = string.Format("{0:yyyy-MM-dd}", nextWeek.EndDate);
|
||
|
||
|
||
|
||
//var weekPlan = Funs.DB.JDGL_WeekPlan.FirstOrDefault(x => x.WeekNo == this.txtWeekNo.Text);
|
||
//if (weekPlan != null)
|
||
//{
|
||
// //if (weekPlan.StartDate != null)
|
||
// //{
|
||
// // this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", weekPlan.StartDate);
|
||
// //}
|
||
// //if (weekPlan.EndDate != null)
|
||
// //{
|
||
// // this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", weekPlan.EndDate);
|
||
// //}
|
||
// var lastWeekPlan = (from x in Funs.DB.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.StartDate < weekPlan.StartDate orderby x.StartDate descending select x).FirstOrDefault();
|
||
// if (lastWeekPlan != null)
|
||
// {
|
||
// ThisWeekGrid(lastWeekPlan.WeekNo);
|
||
// if (lastWeekPlan.WeekNo != "0")
|
||
// {
|
||
// this.Toolbar1.Hidden = true;
|
||
// this.Grid2.Columns[9].Hidden = true;
|
||
// }
|
||
// }
|
||
// else
|
||
// {
|
||
// this.Toolbar1.Hidden = false;
|
||
// this.Grid2.Columns[9].Hidden = false;
|
||
// }
|
||
//}
|
||
//else
|
||
//{
|
||
// //this.txtStartDate.Text = string.Empty;
|
||
// //this.txtEndDate.Text = string.Empty;
|
||
// var lastWeekPlan = (from x in Funs.DB.JDGL_WeekPlan where x.ProjectId == this.CurrUser.LoginProjectId orderby x.StartDate descending select x).FirstOrDefault();
|
||
// if (lastWeekPlan != null)
|
||
// {
|
||
// ThisWeekGrid(lastWeekPlan.WeekNo);
|
||
// this.Toolbar1.Hidden = true;
|
||
// this.Grid2.Columns[9].Hidden = true;
|
||
// }
|
||
// else
|
||
// {
|
||
// this.Toolbar1.Hidden = false;
|
||
// this.Grid2.Columns[9].Hidden = false;
|
||
// }
|
||
//}
|
||
//NextWeekGrid(NextWeekNo.ToString());
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 加载下周计划
|
||
/// </summary>
|
||
/// <param name="NextWeekNo">下周周号</param>
|
||
private void NextWeekGrid()
|
||
{
|
||
string strSql = @"select wplan.WeekPlanId,wplan.ProjectId,wplan.WeekNo,wplan.StartDate,wplan.EndDate,wplan.WorkContent,wplan.PlanDate,wplan.Remark
|
||
,case wplan.IsOK when 1 then '已完成' when 0 then '未完成' else '' end as IsOK
|
||
,uwork.UnitWorkName as UnitWork,major.ProfessionalName as Major,unit.UnitName as UnitId
|
||
,DutyPerson = STUFF((SELECT ',' + p.UserName FROM dbo.Sys_User as p where PATINDEX('%,' + RTRIM(p.UserId) + ',%', ',' + wplan.DutyPerson + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||
from JDGL_WeekPlan as wplan
|
||
left join WBS_UnitWork as uwork on uwork.UnitWorkId = wplan.UnitWork
|
||
left join Base_CNProfessional as major on major.CNProfessionalId = wplan.Major
|
||
left join Base_Unit as unit on unit.UnitId = wplan.UnitId
|
||
where wplan.ProjectId = @ProjectId ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||
|
||
strSql += " and wplan.WeekNo = @weekNo";
|
||
listStr.Add(new SqlParameter("@weekNo", this.NextWeekNo));
|
||
strSql += " order by wplan.SortIndex ";
|
||
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
Grid1.DataSource = tb;
|
||
Grid1.DataBind();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 本周计划完成情况
|
||
/// </summary>
|
||
/// <param name="weekNo">本周周号</param>
|
||
private void ThisWeekGrid()
|
||
{
|
||
string strSql = @"select wplan.WeekPlanId,wplan.ProjectId,wplan.WeekNo,wplan.StartDate,wplan.EndDate,wplan.WorkContent,wplan.PlanDate,wplan.Remark
|
||
,case wplan.IsOK when 1 then '已完成' when 0 then '未完成' else '' end as IsOK
|
||
,uwork.UnitWorkName as UnitWork,major.ProfessionalName as Major,unit.UnitName as UnitId
|
||
,DutyPerson = STUFF((SELECT ',' + p.UserName FROM dbo.Sys_User as p where PATINDEX('%,' + RTRIM(p.UserId) + ',%', ',' + wplan.DutyPerson + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||
from JDGL_WeekPlan as wplan
|
||
left join WBS_UnitWork as uwork on uwork.UnitWorkId = wplan.UnitWork
|
||
left join Base_CNProfessional as major on major.CNProfessionalId = wplan.Major
|
||
left join Base_Unit as unit on unit.UnitId = wplan.UnitId
|
||
where wplan.ProjectId = @ProjectId ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||
//if (!string.IsNullOrEmpty(weekNo))
|
||
//{
|
||
// strSql += " and wplan.WeekNo = @weekNo";
|
||
// listStr.Add(new SqlParameter("@weekNo", weekNo));
|
||
//}
|
||
strSql += " and wplan.WeekNo = @weekNo";
|
||
listStr.Add(new SqlParameter("@weekNo", this.ThisWeekNo));
|
||
strSql += " order by wplan.SortIndex ";
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
Grid2.RecordCount = tb.Rows.Count;
|
||
Grid2.DataSource = tb;
|
||
Grid2.DataBind();
|
||
}
|
||
|
||
|
||
private string ConvertIsOK(bool? isOK)
|
||
{
|
||
string str = string.Empty;
|
||
if (isOK != null)
|
||
{
|
||
if (isOK == true)
|
||
{
|
||
str = "已完成";
|
||
}
|
||
else
|
||
{
|
||
str = "未完成";
|
||
}
|
||
}
|
||
return str;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
if (string.IsNullOrEmpty(this.txtWeekNo.Text))
|
||
{
|
||
ShowNotify("请输入周号!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
if (string.IsNullOrEmpty(this.txtStartDate.Text))
|
||
{
|
||
ShowNotify("请选择开始日期!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
if (string.IsNullOrEmpty(this.txtEndDate.Text))
|
||
{
|
||
ShowNotify("请选择结束日期!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
SaveData(true);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存周计划
|
||
/// </summary>
|
||
/// <param name="bl"></param>
|
||
private void SaveData(bool bl)
|
||
{
|
||
DateTime startDate = Convert.ToDateTime(this.txtStartDate.Text.Trim());
|
||
DateTime endDate = Convert.ToDateTime(this.txtEndDate.Text.Trim());
|
||
//选择的周号为本周计划周号
|
||
string weekNo = this.txtWeekNo.Text.Trim();
|
||
//下周周号
|
||
string NextWeekNo = (int.Parse(weekNo) + 1).ToString();
|
||
|
||
|
||
Model.SGGLDB db = Funs.DB;
|
||
var unitWorks = from x in db.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId select x;
|
||
var cns = from x in db.Base_CNProfessional select x;
|
||
var units = from x in db.Base_Unit select x;
|
||
var users = from x in db.Sys_User select x;
|
||
|
||
//清理下周计划
|
||
BLL.WeekPlanService.DeleteAllWeekPlan(this.CurrUser.LoginProjectId, NextWeekNo);
|
||
|
||
#region 下周计划
|
||
|
||
int i = 1;
|
||
var list = GetDetails();
|
||
foreach (var item in list)
|
||
{
|
||
Model.JDGL_WeekPlan WeekPlan = new Model.JDGL_WeekPlan();
|
||
WeekPlan.WeekPlanId = SQLHelper.GetNewID(typeof(Model.JDGL_WeekPlan));
|
||
WeekPlan.ProjectId = this.CurrUser.LoginProjectId;
|
||
WeekPlan.WeekNo = NextWeekNo;
|
||
WeekPlan.StartDate = startDate.AddDays(7);
|
||
WeekPlan.EndDate = endDate.AddDays(7);
|
||
//WeekPlan.WeekNo = weekNo;
|
||
//WeekPlan.StartDate = startDate;
|
||
//WeekPlan.EndDate = endDate;
|
||
if (unitWorks.FirstOrDefault(x => x.UnitWorkName == item.UnitWork) != null)
|
||
{
|
||
WeekPlan.UnitWork = unitWorks.FirstOrDefault(x => x.UnitWorkName == item.UnitWork).UnitWorkId;
|
||
}
|
||
if (cns.FirstOrDefault(x => x.ProfessionalName == item.Major) != null)
|
||
{
|
||
WeekPlan.Major = cns.FirstOrDefault(x => x.ProfessionalName == item.Major).CNProfessionalId;
|
||
}
|
||
var unit = units.FirstOrDefault(x => x.UnitName == item.UnitId);
|
||
if (unit != null)
|
||
{
|
||
WeekPlan.UnitId = unit.UnitId;
|
||
}
|
||
WeekPlan.WorkContent = item.WorkContent;
|
||
WeekPlan.PlanDate = item.PlanDate;
|
||
var dutyPersons = item.DutyPerson.Split(',');
|
||
string dutyPersonIds = string.Empty;
|
||
foreach (var dutyPerson in dutyPersons)
|
||
{
|
||
var user = users.FirstOrDefault(x => x.UserName == dutyPerson);
|
||
if (user != null)
|
||
{
|
||
dutyPersonIds = !string.IsNullOrWhiteSpace(dutyPersonIds) ? $"{dutyPersonIds},{user.UserId}" : user.UserId;
|
||
}
|
||
}
|
||
WeekPlan.DutyPerson = dutyPersonIds;
|
||
//var user = users.FirstOrDefault(x => x.UserName == item.DutyPerson);
|
||
//if (user != null)
|
||
//{
|
||
// WeekPlan.DutyPerson = user.UserId;
|
||
//}
|
||
WeekPlan.IsOK = item.IsOK;
|
||
WeekPlan.Remark = item.Remark;
|
||
WeekPlan.CompileMan = this.CurrUser.UserId;
|
||
WeekPlan.CompileDate = DateTime.Now;
|
||
WeekPlan.SortIndex = i;
|
||
BLL.WeekPlanService.AddWeekPlan(WeekPlan);
|
||
i++;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 本周计划
|
||
|
||
int j = 1;
|
||
var list2 = GetDetails2();
|
||
//string lastWeekNo = "0";
|
||
//string lastWeekNo = this.txtWeekNo.Text.Trim();
|
||
foreach (var item in list2)
|
||
{
|
||
Model.JDGL_WeekPlan WeekPlan = new Model.JDGL_WeekPlan();
|
||
WeekPlan.WeekPlanId = item.WeekPlanId;
|
||
WeekPlan.ProjectId = this.CurrUser.LoginProjectId;
|
||
//WeekPlan.WeekNo = lastWeekNo;
|
||
//WeekPlan.StartDate = startDate.AddDays(-7);
|
||
//WeekPlan.EndDate = endDate.AddDays(-7);
|
||
WeekPlan.WeekNo = weekNo;
|
||
WeekPlan.StartDate = startDate;
|
||
WeekPlan.EndDate = endDate;
|
||
if (unitWorks.FirstOrDefault(x => x.UnitWorkName == item.UnitWork) != null)
|
||
{
|
||
WeekPlan.UnitWork = unitWorks.FirstOrDefault(x => x.UnitWorkName == item.UnitWork).UnitWorkId;
|
||
}
|
||
if (cns.FirstOrDefault(x => x.ProfessionalName == item.Major) != null)
|
||
{
|
||
WeekPlan.Major = cns.FirstOrDefault(x => x.ProfessionalName == item.Major).CNProfessionalId;
|
||
}
|
||
var unit = units.FirstOrDefault(x => x.UnitName == item.UnitId);
|
||
if (unit != null)
|
||
{
|
||
WeekPlan.UnitId = unit.UnitId;
|
||
}
|
||
WeekPlan.WorkContent = item.WorkContent;
|
||
WeekPlan.PlanDate = item.PlanDate;
|
||
var dutyPersons = item.DutyPerson.Split(',');
|
||
string dutyPersonIds = string.Empty;
|
||
foreach (var dutyPerson in dutyPersons)
|
||
{
|
||
var user = users.FirstOrDefault(x => x.UserName == dutyPerson);
|
||
if (user != null)
|
||
{
|
||
dutyPersonIds = !string.IsNullOrWhiteSpace(dutyPersonIds) ? $"{dutyPersonIds},{user.UserId}" : user.UserId;
|
||
}
|
||
}
|
||
WeekPlan.DutyPerson = dutyPersonIds;
|
||
//var user = users.FirstOrDefault(x => x.UserName == item.DutyPerson);
|
||
//if (user != null)
|
||
//{
|
||
// WeekPlan.DutyPerson = user.UserId;
|
||
//}
|
||
WeekPlan.IsOK = item.IsOK;
|
||
WeekPlan.Remark = item.Remark;
|
||
WeekPlan.CompileMan = this.CurrUser.UserId;
|
||
WeekPlan.CompileDate = DateTime.Now;
|
||
WeekPlan.SortIndex = j;
|
||
var oldWeekPlan = BLL.WeekPlanService.GetWeekPlanById(WeekPlan.WeekPlanId);
|
||
if (oldWeekPlan == null)
|
||
{
|
||
BLL.WeekPlanService.AddWeekPlan(WeekPlan);
|
||
}
|
||
else
|
||
{
|
||
BLL.WeekPlanService.UpdateWeekPlan(WeekPlan);
|
||
}
|
||
j++;
|
||
}
|
||
|
||
#endregion
|
||
|
||
//foreach (JObject mergedRow in Grid2.GetMergedData())
|
||
//{
|
||
// JObject values = mergedRow.Value<JObject>("values");
|
||
// int a = mergedRow.Value<int>("index");
|
||
// Model.JDGL_WeekPlan ql = BLL.WeekPlanService.GetWeekPlanById(Grid2.Rows[a].RowID);
|
||
// if (!string.IsNullOrEmpty(values.Value<string>("IsOK")))
|
||
// {
|
||
// ql.IsOK = values.Value<string>("IsOK") == "已完成" ? true : false;
|
||
// }
|
||
// ql.Remark = values.Value<string>("Remark");
|
||
// BLL.WeekPlanService.UpdateWeekPlan(ql);
|
||
//}
|
||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
}
|
||
|
||
/// <summary>
|
||
/// 窗口关闭事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Window1_Close(object sender, EventArgs e)
|
||
{
|
||
NextWeekGrid();
|
||
}
|
||
/// <summary>
|
||
/// 窗口关闭事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Window2_Close(object sender, EventArgs e)
|
||
{
|
||
ThisWeekGrid();
|
||
}
|
||
|
||
#region 增加按钮事件
|
||
/// <summary>
|
||
/// 增加按钮事件——下周计划
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnNew_Click(object sender, EventArgs e)
|
||
{
|
||
var list = GetDetails();
|
||
Model.JDGL_WeekPlan ql = new Model.JDGL_WeekPlan();
|
||
ql.WeekPlanId = SQLHelper.GetNewID();
|
||
list.Add(ql);
|
||
Model.SGGLDB db = Funs.DB;
|
||
Grid1.DataSource = from x in list
|
||
select new
|
||
{
|
||
x.WeekPlanId,
|
||
x.ProjectId,
|
||
x.WeekNo,
|
||
x.StartDate,
|
||
x.EndDate,
|
||
x.UnitWork,
|
||
x.Major,
|
||
x.UnitId,
|
||
x.WorkContent,
|
||
x.PlanDate,
|
||
x.DutyPerson,
|
||
IsOK = ConvertIsOK(x.IsOK),
|
||
x.Remark,
|
||
};
|
||
Grid1.DataBind();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 选择其他周计划新增到下周计划
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSelectWeekPlan_Click(object sender, EventArgs e)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeekPlanSelect.aspx?WeekNo={0}", this.NextWeekNo), "选择下周计划"));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 选择其他周计划新增到本周计划
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSelectWeekPlan2_Click(object sender, EventArgs e)
|
||
{
|
||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("WeekPlanSelect.aspx?WeekNo={0}", this.ThisWeekNo), "选择本周计划"));
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 增加按钮事件——本周计划
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnNew2_Click(object sender, EventArgs e)
|
||
{
|
||
var list = GetDetails2();
|
||
Model.JDGL_WeekPlan ql = new Model.JDGL_WeekPlan();
|
||
ql.WeekPlanId = SQLHelper.GetNewID();
|
||
list.Add(ql);
|
||
Model.SGGLDB db = Funs.DB;
|
||
Grid2.DataSource = from x in list
|
||
select new
|
||
{
|
||
x.WeekPlanId,
|
||
x.ProjectId,
|
||
x.WeekNo,
|
||
x.StartDate,
|
||
x.EndDate,
|
||
x.UnitWork,
|
||
x.Major,
|
||
x.UnitId,
|
||
x.WorkContent,
|
||
x.PlanDate,
|
||
x.DutyPerson,
|
||
IsOK = ConvertIsOK(x.IsOK),
|
||
x.Remark,
|
||
};
|
||
Grid2.DataBind();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 下周计划
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private List<Model.JDGL_WeekPlan> GetDetails()
|
||
{
|
||
List<Model.JDGL_WeekPlan> list = new List<Model.JDGL_WeekPlan>();
|
||
foreach (JObject mergedRow in Grid1.GetMergedData())
|
||
{
|
||
JObject values = mergedRow.Value<JObject>("values");
|
||
int i = mergedRow.Value<int>("index");
|
||
Model.JDGL_WeekPlan ql = new Model.JDGL_WeekPlan();
|
||
ql.WeekPlanId = Grid1.Rows[i].RowID;
|
||
ql.UnitWork = values.Value<string>("UnitWork");
|
||
ql.Major = values.Value<string>("Major");
|
||
ql.UnitId = values.Value<string>("UnitId");
|
||
ql.WorkContent = values.Value<string>("WorkContent");
|
||
ql.PlanDate = Funs.GetNewDateTime(values.Value<string>("PlanDate"));
|
||
ql.DutyPerson = values.Value<string>("DutyPerson");
|
||
if (!string.IsNullOrEmpty(values.Value<string>("IsOK")))
|
||
{
|
||
ql.IsOK = values.Value<string>("IsOK") == "已完成" ? true : false;
|
||
}
|
||
ql.Remark = values.Value<string>("Remark");
|
||
list.Add(ql);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 本周计划
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private List<Model.JDGL_WeekPlan> GetDetails2()
|
||
{
|
||
List<Model.JDGL_WeekPlan> list = new List<Model.JDGL_WeekPlan>();
|
||
foreach (JObject mergedRow in Grid2.GetMergedData())
|
||
{
|
||
JObject values = mergedRow.Value<JObject>("values");
|
||
int i = mergedRow.Value<int>("index");
|
||
Model.JDGL_WeekPlan ql = new Model.JDGL_WeekPlan();
|
||
ql.WeekPlanId = Grid2.Rows[i].RowID;
|
||
ql.UnitWork = values.Value<string>("UnitWork");
|
||
ql.Major = values.Value<string>("Major");
|
||
ql.UnitId = values.Value<string>("UnitId");
|
||
ql.WorkContent = values.Value<string>("WorkContent");
|
||
ql.PlanDate = Funs.GetNewDateTime(values.Value<string>("PlanDate"));
|
||
ql.DutyPerson = values.Value<string>("DutyPerson");
|
||
if (!string.IsNullOrEmpty(values.Value<string>("IsOK")))
|
||
{
|
||
ql.IsOK = values.Value<string>("IsOK") == "已完成" ? true : false;
|
||
}
|
||
ql.Remark = values.Value<string>("Remark");
|
||
list.Add(ql);
|
||
}
|
||
return list;
|
||
}
|
||
#endregion
|
||
|
||
#region 行点击事件
|
||
/// <summary>
|
||
/// Grid行点击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||
{
|
||
string WeekPlanId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||
var list = GetDetails();
|
||
if (e.CommandName == "del")//删除
|
||
{
|
||
var Report = list.FirstOrDefault(x => x.WeekPlanId == WeekPlanId);
|
||
if (Report != null)
|
||
{
|
||
list.Remove(Report);
|
||
}
|
||
Model.SGGLDB db = Funs.DB;
|
||
Grid1.DataSource = from x in list
|
||
select new
|
||
{
|
||
x.WeekPlanId,
|
||
x.ProjectId,
|
||
x.WeekNo,
|
||
x.StartDate,
|
||
x.EndDate,
|
||
x.UnitWork,
|
||
x.Major,
|
||
x.UnitId,
|
||
x.WorkContent,
|
||
x.PlanDate,
|
||
x.DutyPerson,
|
||
IsOK = ConvertIsOK(x.IsOK),
|
||
x.Remark,
|
||
};
|
||
this.Grid1.DataBind();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Grid行点击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid2_RowCommand(object sender, GridCommandEventArgs e)
|
||
{
|
||
string WeekPlanId = Grid2.DataKeys[e.RowIndex][0].ToString();
|
||
var list = GetDetails2();
|
||
if (e.CommandName == "del")//删除
|
||
{
|
||
var Report = list.FirstOrDefault(x => x.WeekPlanId == WeekPlanId);
|
||
if (Report != null)
|
||
{
|
||
list.Remove(Report);
|
||
}
|
||
Model.SGGLDB db = Funs.DB;
|
||
Grid2.DataSource = from x in list
|
||
select new
|
||
{
|
||
x.WeekPlanId,
|
||
x.ProjectId,
|
||
x.WeekNo,
|
||
x.StartDate,
|
||
x.EndDate,
|
||
x.UnitWork,
|
||
x.Major,
|
||
x.UnitId,
|
||
x.WorkContent,
|
||
x.PlanDate,
|
||
x.DutyPerson,
|
||
IsOK = ConvertIsOK(x.IsOK),
|
||
x.Remark,
|
||
};
|
||
this.Grid2.DataBind();
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |