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 定义集合 /// /// 部门人工时设置集合 /// private List setList = new List(); /// /// 人员人工时设置集合 /// private List perSetList = new List(); #endregion #region 加载 /// /// 加载页面 /// /// /// 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 查询 /// /// 每月人工时下拉选择事件 /// /// /// 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 保存 /// /// 保存 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { try { //设置部门每月人工时 List list = new List(); 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 list2 = new List(); 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 格式化字符串 /// /// 获取部门名称 /// /// /// 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 权限设置 /// /// 菜单按钮权限 /// 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 } }