378 lines
20 KiB
C#
378 lines
20 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.SysManage
|
|
{
|
|
public partial class ActualManHourMonthSet : PageBase
|
|
{
|
|
#region 定义集合
|
|
/// <summary>
|
|
/// 部门人工时设置集合
|
|
/// </summary>
|
|
private List<Model.Sys_ActualManHourMonthSet> setList = new List<Model.Sys_ActualManHourMonthSet>();
|
|
|
|
/// <summary>
|
|
/// 人员人工时设置集合
|
|
/// </summary>
|
|
private List<Model.Sys_ActualManHourMonthSet> perSetList = new List<Model.Sys_ActualManHourMonthSet>();
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
GetButtonPower();//权限设置
|
|
this.txtYearS.Text = DateTime.Now.ToString("yyyy");
|
|
|
|
#region 部门人工时设置
|
|
setList.Clear();
|
|
var departments = BLL.DepartService.GetDepartManMonthHourList();
|
|
foreach (var item in departments)
|
|
{
|
|
var actualManHourMonthSet = BLL.Sys_ActualManHourMonthSetService.GetActualManHourMonthSetByDepAndYear(item.DepartId, this.txtYearS.Text.Trim());
|
|
if (actualManHourMonthSet != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(actualManHourMonthSet.ActualManHourMonthId))
|
|
{
|
|
var newSet = BLL.Sys_ActualManHourMonthSetService.GetActualManHourMonthSetById(actualManHourMonthSet.ActualManHourMonthId);
|
|
if (newSet != null)
|
|
{
|
|
newSet.ActualManHourMonthId = actualManHourMonthSet.ActualManHourMonthId;
|
|
newSet.DepartId = actualManHourMonthSet.DepartId;
|
|
//newSet.HeadCount = actualManHourMonthSet.HeadCount;
|
|
newSet.Years = actualManHourMonthSet.Years;
|
|
newSet.Month1 = actualManHourMonthSet.Month1;
|
|
newSet.Month2 = actualManHourMonthSet.Month2;
|
|
newSet.Month3 = actualManHourMonthSet.Month3;
|
|
newSet.Month4 = actualManHourMonthSet.Month4;
|
|
newSet.Month5 = actualManHourMonthSet.Month5;
|
|
newSet.Month6 = actualManHourMonthSet.Month6;
|
|
newSet.Month7 = actualManHourMonthSet.Month7;
|
|
newSet.Month8 = actualManHourMonthSet.Month8;
|
|
newSet.Month9 = actualManHourMonthSet.Month9;
|
|
newSet.Month10 = actualManHourMonthSet.Month10;
|
|
newSet.Month11 = actualManHourMonthSet.Month11;
|
|
newSet.Month12 = actualManHourMonthSet.Month12;
|
|
setList.Add(newSet);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Model.Sys_ActualManHourMonthSet set = new Model.Sys_ActualManHourMonthSet();
|
|
set.ActualManHourMonthId = SQLHelper.GetNewID(typeof(Model.Sys_ActualManHourMonthSet));
|
|
set.DepartId = item.DepartId;
|
|
set.Years = this.txtYearS.Text.Trim();
|
|
setList.Add(set);
|
|
}
|
|
}
|
|
this.Grid1.DataSource = setList;
|
|
this.Grid1.DataBind();
|
|
#endregion
|
|
|
|
#region 人员人工时设置
|
|
perSetList.Clear();
|
|
var actualManHour = BLL.Sys_ActualManHourMonthSetService.GetActualManHourMonthSetByYear(this.txtYearS.Text.Trim());
|
|
if (actualManHour != null)
|
|
{
|
|
var newPer = BLL.Sys_ActualManHourMonthSetService.GetActualManHourMonthSetById(actualManHour.ActualManHourMonthId);
|
|
if (newPer!=null)
|
|
{
|
|
newPer.ActualManHourMonthId = actualManHour.ActualManHourMonthId;
|
|
newPer.Person = actualManHour.Person;
|
|
newPer.Years = actualManHour.Years;
|
|
newPer.Month1 = actualManHour.Month1;
|
|
newPer.Month2 = actualManHour.Month2;
|
|
newPer.Month3 = actualManHour.Month3;
|
|
newPer.Month4 = actualManHour.Month4;
|
|
newPer.Month5 = actualManHour.Month5;
|
|
newPer.Month6 = actualManHour.Month6;
|
|
newPer.Month7 = actualManHour.Month7;
|
|
newPer.Month8 = actualManHour.Month8;
|
|
newPer.Month9 = actualManHour.Month9;
|
|
newPer.Month10 = actualManHour.Month10;
|
|
newPer.Month11 = actualManHour.Month11;
|
|
newPer.Month12 = actualManHour.Month12;
|
|
|
|
this.hdMonth1.Text = actualManHour.Month1.HasValue ? actualManHour.Month1.ToString() : "0";
|
|
this.hdMonth2.Text = actualManHour.Month2.HasValue ? actualManHour.Month2.ToString() : "0";
|
|
this.hdMonth3.Text = actualManHour.Month3.HasValue ? actualManHour.Month3.ToString() : "0";
|
|
this.hdMonth4.Text = actualManHour.Month4.HasValue ? actualManHour.Month4.ToString() : "0";
|
|
this.hdMonth5.Text = actualManHour.Month5.HasValue ? actualManHour.Month5.ToString() : "0";
|
|
this.hdMonth6.Text = actualManHour.Month6.HasValue ? actualManHour.Month6.ToString() : "0";
|
|
this.hdMonth7.Text = actualManHour.Month7.HasValue ? actualManHour.Month7.ToString() : "0";
|
|
this.hdMonth8.Text = actualManHour.Month8.HasValue ? actualManHour.Month8.ToString() : "0";
|
|
this.hdMonth9.Text = actualManHour.Month9.HasValue ? actualManHour.Month9.ToString() : "0";
|
|
this.hdMonth10.Text = actualManHour.Month10.HasValue ? actualManHour.Month10.ToString() : "0";
|
|
this.hdMonth11.Text = actualManHour.Month11.HasValue ? actualManHour.Month11.ToString() : "0";
|
|
this.hdMonth12.Text = actualManHour.Month12.HasValue ? actualManHour.Month12.ToString() : "0";
|
|
|
|
perSetList.Add(newPer);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Model.Sys_ActualManHourMonthSet perSet = new Model.Sys_ActualManHourMonthSet();
|
|
perSet.ActualManHourMonthId = SQLHelper.GetNewID(typeof(Model.Sys_ActualManHourMonthSet));
|
|
perSet.Person = "0";
|
|
perSet.Years = this.txtYearS.Text.Trim();
|
|
perSetList.Add(perSet);
|
|
}
|
|
this.Grid2.DataSource = perSetList;
|
|
this.Grid2.DataBind();
|
|
#endregion
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 每月人工时下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Text_OnText(object sender, EventArgs e)
|
|
{
|
|
#region 部门人工时设置
|
|
setList.Clear();
|
|
var departments = BLL.DepartService.GetDepartManMonthHourList();
|
|
foreach (var item in departments)
|
|
{
|
|
var actualManHourMonthSet = BLL.Sys_ActualManHourMonthSetService.GetActualManHourMonthSetByDepAndYear(item.DepartId, this.txtYearS.Text.Trim());
|
|
if (actualManHourMonthSet != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(actualManHourMonthSet.ActualManHourMonthId))
|
|
{
|
|
var newSet = BLL.Sys_ActualManHourMonthSetService.GetActualManHourMonthSetById(actualManHourMonthSet.ActualManHourMonthId);
|
|
if (newSet != null)
|
|
{
|
|
newSet.ActualManHourMonthId = actualManHourMonthSet.ActualManHourMonthId;
|
|
newSet.DepartId = actualManHourMonthSet.DepartId;
|
|
//newSet.HeadCount = actualManHourMonthSet.HeadCount;
|
|
newSet.Years = actualManHourMonthSet.Years;
|
|
newSet.Month1 = actualManHourMonthSet.Month1;
|
|
newSet.Month2 = actualManHourMonthSet.Month2;
|
|
newSet.Month3 = actualManHourMonthSet.Month3;
|
|
newSet.Month4 = actualManHourMonthSet.Month4;
|
|
newSet.Month5 = actualManHourMonthSet.Month5;
|
|
newSet.Month6 = actualManHourMonthSet.Month6;
|
|
newSet.Month7 = actualManHourMonthSet.Month7;
|
|
newSet.Month8 = actualManHourMonthSet.Month8;
|
|
newSet.Month9 = actualManHourMonthSet.Month9;
|
|
newSet.Month10 = actualManHourMonthSet.Month10;
|
|
newSet.Month11 = actualManHourMonthSet.Month11;
|
|
newSet.Month12 = actualManHourMonthSet.Month12;
|
|
setList.Add(newSet);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Model.Sys_ActualManHourMonthSet set = new Model.Sys_ActualManHourMonthSet();
|
|
set.ActualManHourMonthId = SQLHelper.GetNewID(typeof(Model.Sys_ActualManHourMonthSet));
|
|
set.DepartId = item.DepartId;
|
|
set.Years = this.txtYearS.Text.Trim();
|
|
setList.Add(set);
|
|
}
|
|
}
|
|
this.Grid1.DataSource = setList;
|
|
this.Grid1.DataBind();
|
|
#endregion
|
|
|
|
#region 人员人工时设置
|
|
perSetList.Clear();
|
|
var actualManHour = BLL.Sys_ActualManHourMonthSetService.GetActualManHourMonthSetByYear(this.txtYearS.Text.Trim());
|
|
if (actualManHour != null)
|
|
{
|
|
var newPer = BLL.Sys_ActualManHourMonthSetService.GetActualManHourMonthSetById(actualManHour.ActualManHourMonthId);
|
|
if (newPer != null)
|
|
{
|
|
newPer.ActualManHourMonthId = actualManHour.ActualManHourMonthId;
|
|
newPer.Person = actualManHour.Person;
|
|
newPer.Years = actualManHour.Years;
|
|
newPer.Month1 = actualManHour.Month1;
|
|
newPer.Month2 = actualManHour.Month2;
|
|
newPer.Month3 = actualManHour.Month3;
|
|
newPer.Month4 = actualManHour.Month4;
|
|
newPer.Month5 = actualManHour.Month5;
|
|
newPer.Month6 = actualManHour.Month6;
|
|
newPer.Month7 = actualManHour.Month7;
|
|
newPer.Month8 = actualManHour.Month8;
|
|
newPer.Month9 = actualManHour.Month9;
|
|
newPer.Month10 = actualManHour.Month10;
|
|
newPer.Month11 = actualManHour.Month11;
|
|
newPer.Month12 = actualManHour.Month12;
|
|
|
|
this.hdMonth1.Text = actualManHour.Month1.HasValue ? actualManHour.Month1.ToString() : "0";
|
|
this.hdMonth2.Text = actualManHour.Month2.HasValue ? actualManHour.Month2.ToString() : "0";
|
|
this.hdMonth3.Text = actualManHour.Month3.HasValue ? actualManHour.Month3.ToString() : "0";
|
|
this.hdMonth4.Text = actualManHour.Month4.HasValue ? actualManHour.Month4.ToString() : "0";
|
|
this.hdMonth5.Text = actualManHour.Month5.HasValue ? actualManHour.Month5.ToString() : "0";
|
|
this.hdMonth6.Text = actualManHour.Month6.HasValue ? actualManHour.Month6.ToString() : "0";
|
|
this.hdMonth7.Text = actualManHour.Month7.HasValue ? actualManHour.Month7.ToString() : "0";
|
|
this.hdMonth8.Text = actualManHour.Month8.HasValue ? actualManHour.Month8.ToString() : "0";
|
|
this.hdMonth9.Text = actualManHour.Month9.HasValue ? actualManHour.Month9.ToString() : "0";
|
|
this.hdMonth10.Text = actualManHour.Month10.HasValue ? actualManHour.Month10.ToString() : "0";
|
|
this.hdMonth11.Text = actualManHour.Month11.HasValue ? actualManHour.Month11.ToString() : "0";
|
|
this.hdMonth12.Text = actualManHour.Month12.HasValue ? actualManHour.Month12.ToString() : "0";
|
|
|
|
perSetList.Add(newPer);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Model.Sys_ActualManHourMonthSet perSet = new Model.Sys_ActualManHourMonthSet();
|
|
perSet.ActualManHourMonthId = SQLHelper.GetNewID(typeof(Model.Sys_ActualManHourMonthSet));
|
|
perSet.Person = "0";
|
|
perSet.Years = this.txtYearS.Text.Trim();
|
|
perSetList.Add(perSet);
|
|
}
|
|
this.Grid2.DataSource = perSetList;
|
|
this.Grid2.DataBind();
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//设置部门每月人工时
|
|
List<Model.Sys_ActualManHourMonthSet> list = new List<Model.Sys_ActualManHourMonthSet>();
|
|
JArray EditorTDCArr = Grid1.GetMergedData();
|
|
if (EditorTDCArr.Count > 0)
|
|
{
|
|
Model.Sys_ActualManHourMonthSet newSet = null;
|
|
for (int i = 0; i < EditorTDCArr.Count; i++)
|
|
{
|
|
JObject objects = (JObject)EditorTDCArr[i];
|
|
newSet = new Model.Sys_ActualManHourMonthSet();
|
|
newSet.ActualManHourMonthId = Guid.NewGuid().ToString();
|
|
newSet.DepartId = objects["values"]["DepartId"].ToString();
|
|
newSet.Years = objects["values"]["Years"].ToString();
|
|
//newSet.HeadCount = Funs.GetNewInt(objects["values"]["HeadCount"].ToString());
|
|
newSet.Month1 = Funs.GetNewDecimal(objects["values"]["Month1"].ToString());
|
|
newSet.Month2 = Funs.GetNewDecimal(objects["values"]["Month2"].ToString());
|
|
newSet.Month3 = Funs.GetNewDecimal(objects["values"]["Month3"].ToString());
|
|
newSet.Month4 = Funs.GetNewDecimal(objects["values"]["Month4"].ToString());
|
|
newSet.Month5 = Funs.GetNewDecimal(objects["values"]["Month5"].ToString());
|
|
newSet.Month6 = Funs.GetNewDecimal(objects["values"]["Month6"].ToString());
|
|
newSet.Month7 = Funs.GetNewDecimal(objects["values"]["Month7"].ToString());
|
|
newSet.Month8 = Funs.GetNewDecimal(objects["values"]["Month8"].ToString());
|
|
newSet.Month9 = Funs.GetNewDecimal(objects["values"]["Month9"].ToString());
|
|
newSet.Month10 = Funs.GetNewDecimal(objects["values"]["Month10"].ToString());
|
|
newSet.Month11 = Funs.GetNewDecimal(objects["values"]["Month11"].ToString());
|
|
newSet.Month12 = Funs.GetNewDecimal(objects["values"]["Month12"].ToString());
|
|
list.Add(newSet);
|
|
}
|
|
if (list.Count > 0)
|
|
{
|
|
BLL.Sys_ActualManHourMonthSetService.DeleteActualManHourMonthSetList("1", this.txtYearS.Text.Trim());
|
|
}
|
|
}
|
|
BLL.Sys_ActualManHourMonthSetService.AddActualManHourMonthSet(list);
|
|
|
|
//设置人员每月人工时
|
|
List<Model.Sys_ActualManHourMonthSet> list2 = new List<Model.Sys_ActualManHourMonthSet>();
|
|
JArray EditorTDCArr2 = Grid2.GetMergedData();
|
|
if (EditorTDCArr2.Count > 0)
|
|
{
|
|
Model.Sys_ActualManHourMonthSet newSet = null;
|
|
for (int i = 0; i < EditorTDCArr2.Count; i++)
|
|
{
|
|
JObject objects = (JObject)EditorTDCArr2[i];
|
|
newSet = new Model.Sys_ActualManHourMonthSet();
|
|
newSet.ActualManHourMonthId = Guid.NewGuid().ToString();
|
|
newSet.Person = "0";
|
|
newSet.Years = objects["values"]["Years"].ToString();
|
|
newSet.Month1 = Funs.GetNewDecimal(objects["values"]["Month1"].ToString());
|
|
newSet.Month2 = Funs.GetNewDecimal(objects["values"]["Month2"].ToString());
|
|
newSet.Month3 = Funs.GetNewDecimal(objects["values"]["Month3"].ToString());
|
|
newSet.Month4 = Funs.GetNewDecimal(objects["values"]["Month4"].ToString());
|
|
newSet.Month5 = Funs.GetNewDecimal(objects["values"]["Month5"].ToString());
|
|
newSet.Month6 = Funs.GetNewDecimal(objects["values"]["Month6"].ToString());
|
|
newSet.Month7 = Funs.GetNewDecimal(objects["values"]["Month7"].ToString());
|
|
newSet.Month8 = Funs.GetNewDecimal(objects["values"]["Month8"].ToString());
|
|
newSet.Month9 = Funs.GetNewDecimal(objects["values"]["Month9"].ToString());
|
|
newSet.Month10 = Funs.GetNewDecimal(objects["values"]["Month10"].ToString());
|
|
newSet.Month11 = Funs.GetNewDecimal(objects["values"]["Month11"].ToString());
|
|
newSet.Month12 = Funs.GetNewDecimal(objects["values"]["Month12"].ToString());
|
|
list2.Add(newSet);
|
|
}
|
|
if (list2.Count > 0)
|
|
{
|
|
BLL.Sys_ActualManHourMonthSetService.DeleteActualManHourMonthSetList("0", this.txtYearS.Text.Trim());
|
|
}
|
|
}
|
|
BLL.Sys_ActualManHourMonthSetService.AddActualManHourMonthSet(list2);
|
|
|
|
this.Grid1.DataSource = list;
|
|
this.Grid1.DataBind();
|
|
this.Grid2.DataSource = list2;
|
|
this.Grid2.DataBind();
|
|
ShowNotify("Save Successfully!", MessageBoxIcon.Success);
|
|
//PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Alert.ShowInParent(ex.ToString());
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 格式化字符串
|
|
/// <summary>
|
|
/// 获取部门名称
|
|
/// </summary>
|
|
/// <param name="departId"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertDepart(object departId)
|
|
{
|
|
string department = string.Empty;
|
|
if (departId != null)
|
|
{
|
|
var depart = BLL.DepartService.GetDepartById(departId.ToString());
|
|
if (depart != null)
|
|
{
|
|
department = depart.DepartName;
|
|
}
|
|
}
|
|
return department;
|
|
}
|
|
#endregion
|
|
|
|
#region 权限设置
|
|
/// <summary>
|
|
/// 菜单按钮权限
|
|
/// </summary>
|
|
private void GetButtonPower()
|
|
{
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.ActualManHourMonthSetMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |