提交代码
This commit is contained in:
@@ -0,0 +1,334 @@
|
||||
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.JDGL.Check
|
||||
{
|
||||
public partial class WeekPlanEdit : PageBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 项目id
|
||||
/// </summary>
|
||||
public string ProjectId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["ProjectId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ProjectId"] = value;
|
||||
}
|
||||
}
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
string weekNo = string.Empty;
|
||||
if (!string.IsNullOrEmpty(Request.Params["WeekNo"]))
|
||||
{
|
||||
weekNo = Request.Params["WeekNo"];
|
||||
}
|
||||
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);
|
||||
this.txtWeekNo.Text = weekNo;
|
||||
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);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
BindGrid2(lastWeekPlan.WeekNo);
|
||||
}
|
||||
}
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载Grid
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string weekNo = this.txtWeekNo.Text.Trim();
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Grid1.DataSource = from x in db.JDGL_WeekPlan
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId && x.WeekNo == weekNo
|
||||
orderby x.SortIndex
|
||||
select new
|
||||
{
|
||||
x.WeekPlanId,
|
||||
x.ProjectId,
|
||||
x.WeekNo,
|
||||
x.StartDate,
|
||||
x.EndDate,
|
||||
UnitWork = (from y in db.WBS_UnitWork where y.UnitWorkId == x.UnitWork select y.UnitWorkName).First(),
|
||||
Major = (from y in db.Base_CNProfessional where y.CNProfessionalId == x.Major select y.ProfessionalName).First(),
|
||||
UnitId = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).First(),
|
||||
x.WorkContent,
|
||||
x.PlanDate,
|
||||
DutyPerson = (from y in db.Sys_User where y.UserId == x.DutyPerson select y.UserName).First(),
|
||||
IsOK = ConvertIsOK(x.IsOK),
|
||||
x.Remark,
|
||||
};
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
private void BindGrid2(string weekNo)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Grid2.DataSource = from x in db.JDGL_WeekPlan
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId && x.WeekNo == weekNo
|
||||
orderby x.SortIndex
|
||||
select new
|
||||
{
|
||||
x.WeekPlanId,
|
||||
x.ProjectId,
|
||||
x.WeekNo,
|
||||
x.StartDate,
|
||||
x.EndDate,
|
||||
UnitWork = (from y in db.WBS_UnitWork where y.UnitWorkId == x.UnitWork select y.UnitWorkName).First(),
|
||||
Major = (from y in db.Base_CNProfessional where y.CNProfessionalId == x.Major select y.ProfessionalName).First(),
|
||||
UnitId = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).First(),
|
||||
x.WorkContent,
|
||||
x.PlanDate,
|
||||
DutyPerson = (from y in db.Sys_User where y.UserId == x.DutyPerson select y.UserName).First(),
|
||||
IsOK = ConvertIsOK(x.IsOK),
|
||||
x.Remark,
|
||||
};
|
||||
Grid2.DataBind();
|
||||
}
|
||||
|
||||
private string ConvertIsOK(bool? isOK)
|
||||
{
|
||||
string str = string.Empty;
|
||||
if (isOK != null)
|
||||
{
|
||||
if (isOK == true)
|
||||
{
|
||||
str = "已完成";
|
||||
}
|
||||
else
|
||||
{
|
||||
str = "未完成";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
#region 月份选择事件
|
||||
/// <summary>
|
||||
/// 月份选择事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void txtMonths_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void SaveData(bool bl)
|
||||
{
|
||||
string weekNo = this.txtWeekNo.Text.Trim();
|
||||
DateTime startDate = Convert.ToDateTime(this.txtStartDate.Text.Trim());
|
||||
DateTime endDate = Convert.ToDateTime(this.txtEndDate.Text.Trim());
|
||||
var list = GetDetails();
|
||||
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, weekNo);
|
||||
int i = 1;
|
||||
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 = 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 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++;
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
#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();
|
||||
}
|
||||
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;
|
||||
}
|
||||
#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();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user