303 lines
12 KiB
C#
303 lines
12 KiB
C#
|
using BLL;
|
|||
|
using NPOI.SS.Formula.Functions;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace FineUIPro.Web.EditorManage
|
|||
|
{
|
|||
|
public partial class KeyQuantityEditorEdit : PageBase
|
|||
|
{
|
|||
|
#region 定义项
|
|||
|
/// <summary>
|
|||
|
/// 主键
|
|||
|
/// </summary>
|
|||
|
public string KeyQuantityId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["KeyQuantityId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["KeyQuantityId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 项目Id
|
|||
|
/// </summary>
|
|||
|
public string ProjectId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["ProjectId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["ProjectId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 加载
|
|||
|
/// <summary>
|
|||
|
/// 加载
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|||
|
BindGrid();
|
|||
|
string view = Request.Params["view"];
|
|||
|
if (view == "1")
|
|||
|
{
|
|||
|
this.btnSave.Hidden = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GetButtonPower();
|
|||
|
}
|
|||
|
this.ProjectId = Request.Params["eProjectId"];
|
|||
|
this.KeyQuantityId = Request.Params["keyQuantityId"];
|
|||
|
if (!string.IsNullOrEmpty(this.KeyQuantityId))
|
|||
|
{
|
|||
|
Model.Editor_KeyQuantity keyQuantity = BLL.KeyQuantityService.GetKeyQuantityById(this.KeyQuantityId);
|
|||
|
if (keyQuantity != null)
|
|||
|
{
|
|||
|
this.ProjectId = keyQuantity.EProjectId;
|
|||
|
this.drpKeyId.Value = keyQuantity.KeyId;
|
|||
|
var key = BLL.QuantityDesctiptionService.GetQuantityDesctiptionById(this.drpKeyId.Value);
|
|||
|
if (key != null)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(key.DisciplinesWBSId))
|
|||
|
{
|
|||
|
var wbs = BLL.DisciplinesWBSService.GetDisciplinesWBSById(key.DisciplinesWBSId);
|
|||
|
if (wbs != null)
|
|||
|
{
|
|||
|
this.txtIdentifier.Text = wbs.DisciplinesWBSCode;
|
|||
|
this.txtDescipline.Text = wbs.DisciplinesWBSName;
|
|||
|
}
|
|||
|
|
|||
|
this.txtPlanMHRsSummary.Text = BLL.KeyQuantityService.GetSumPlanMHRsByKeyId(this.drpKeyId.Value).ToString();
|
|||
|
double? actualHoursSum = (from x in Funs.DB.ManHours_Actual
|
|||
|
where x.EProjectId == this.ProjectId
|
|||
|
&& x.Discipline == wbs.DisciplinesWBSName
|
|||
|
select x.Hours).Sum();
|
|||
|
this.txtActualMHRs.Text = actualHoursSum.ToString();
|
|||
|
}
|
|||
|
txtQuantityDesctiption.Text = key.QuantityDesctiption;
|
|||
|
txtPlanMHRsUnit.Text = key.PlanMHRsUnit.HasValue ? key.PlanMHRsUnit.ToString() : "";
|
|||
|
}
|
|||
|
this.txtInputQuantity.Text = keyQuantity.InputQuantity.HasValue ? keyQuantity.InputQuantity.ToString() : "";
|
|||
|
this.txtPlanMHRs.Text = keyQuantity.PlanMHRs.HasValue ? keyQuantity.PlanMHRs.ToString() : "";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 绑定数据
|
|||
|
/// <summary>
|
|||
|
/// 数据绑定
|
|||
|
/// </summary>
|
|||
|
private void BindGrid()
|
|||
|
{
|
|||
|
string strSql = @"SELECT qd.KeyId,
|
|||
|
qd.DepartId,
|
|||
|
qd.DisciplinesWBSId,
|
|||
|
qd.QuantityDesctiption,
|
|||
|
qd.PlanMHRsUnit,
|
|||
|
d.DepartName,
|
|||
|
wbs.DisciplinesWBSCode,
|
|||
|
wbs.DisciplinesWBSName
|
|||
|
FROM Base_QuantityDesctiption qd
|
|||
|
left join Base_Depart as d on qd.DepartId = d.DepartId
|
|||
|
left join Base_DisciplinesWBS as wbs on wbs.DisciplinesWBSId = qd.DisciplinesWBSId WHERE 1=1";
|
|||
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
if (!string.IsNullOrEmpty(this.txtSearch.Text.Trim()))
|
|||
|
{
|
|||
|
strSql += " AND d.DepartName like @DepartName ";
|
|||
|
listStr.Add(new SqlParameter("@DepartName", "%" + this.txtSearch.Text.Trim() + "%"));
|
|||
|
}
|
|||
|
SqlParameter[] parameter = listStr.ToArray();
|
|||
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
// 2.获取当前分页数据
|
|||
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|||
|
Grid1.RecordCount = tb.Rows.Count;
|
|||
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|||
|
Grid1.DataSource = table;
|
|||
|
Grid1.DataBind();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 分页、排序
|
|||
|
/// <summary>
|
|||
|
/// 分页
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|||
|
{
|
|||
|
Grid1.PageIndex = e.NewPageIndex;
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 分页显示条数下拉框
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 排序
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|||
|
{
|
|||
|
Grid1.SortDirection = e.SortDirection;
|
|||
|
Grid1.SortField = e.SortField;
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 筛选
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void txtSearch_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 保存
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (this.drpKeyId.Value == BLL.Const._Null || string.IsNullOrEmpty(this.drpKeyId.Value))
|
|||
|
{
|
|||
|
ShowAlert("Please select Type!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
Model.Editor_KeyQuantity newKeyQuantity = new Model.Editor_KeyQuantity();
|
|||
|
newKeyQuantity.KeyId = this.drpKeyId.Value;
|
|||
|
newKeyQuantity.InputQuantity = Funs.GetNewDecimal(this.txtInputQuantity.Text);
|
|||
|
newKeyQuantity.PlanMHRs = Funs.GetNewDecimal(this.txtPlanMHRs.Text);
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(this.KeyQuantityId))
|
|||
|
{
|
|||
|
newKeyQuantity.KeyQuantityId = this.KeyQuantityId;
|
|||
|
BLL.KeyQuantityService.UpdateKeyQuantity(newKeyQuantity);
|
|||
|
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify Key Quantity Editor information!");
|
|||
|
ShowNotify("Save Successfully!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
newKeyQuantity.EProjectId = ProjectId;
|
|||
|
this.KeyQuantityId = SQLHelper.GetNewID(typeof(Model.Editor_KeyQuantity));
|
|||
|
newKeyQuantity.KeyQuantityId = this.KeyQuantityId;
|
|||
|
BLL.KeyQuantityService.AddKeyQuantity(newKeyQuantity);
|
|||
|
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Add Key Quantity Editor information!");
|
|||
|
ShowNotify("Save Successfully!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region DropDownList下拉选择事件
|
|||
|
/// <summary>
|
|||
|
/// 部门下拉选择事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void drpKeyId_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.txtIdentifier.Text = string.Empty;
|
|||
|
this.txtDescipline.Text = string.Empty;
|
|||
|
this.txtQuantityDesctiption.Text = string.Empty;
|
|||
|
this.txtPlanMHRsUnit.Text = string.Empty;
|
|||
|
this.txtPlanMHRsSummary.Text = string.Empty;
|
|||
|
if (!string.IsNullOrEmpty(this.drpKeyId.Value))
|
|||
|
{
|
|||
|
var key = BLL.QuantityDesctiptionService.GetQuantityDesctiptionById(this.drpKeyId.Value);
|
|||
|
if (key != null)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(key.DisciplinesWBSId))
|
|||
|
{
|
|||
|
var wbs = BLL.DisciplinesWBSService.GetDisciplinesWBSById(key.DisciplinesWBSId);
|
|||
|
if (wbs != null)
|
|||
|
{
|
|||
|
this.txtIdentifier.Text = wbs.DisciplinesWBSCode;
|
|||
|
this.txtDescipline.Text = wbs.DisciplinesWBSName;
|
|||
|
}
|
|||
|
|
|||
|
decimal? s = BLL.KeyQuantityService.GetSumPlanMHRsByKeyId(this.drpKeyId.Value);
|
|||
|
this.txtPlanMHRsSummary.Text = (s + Funs.GetNewDecimal(this.txtPlanMHRs.Text)).ToString();
|
|||
|
|
|||
|
double? actualHoursSum = (from x in Funs.DB.ManHours_Actual
|
|||
|
where x.EProjectId == this.ProjectId
|
|||
|
&& x.Discipline == wbs.DisciplinesWBSName
|
|||
|
select x.Hours).Sum();
|
|||
|
this.txtActualMHRs.Text = actualHoursSum.ToString();
|
|||
|
}
|
|||
|
txtQuantityDesctiption.Text = key.QuantityDesctiption;
|
|||
|
txtPlanMHRsUnit.Text = key.PlanMHRsUnit.HasValue ? key.PlanMHRsUnit.ToString() : "";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Input Quantity输入事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void txtInputQuantity_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.txtPlanMHRs.Text = string.Empty;
|
|||
|
this.txtPlanMHRsSummary.Text = string.Empty;
|
|||
|
if (!string.IsNullOrEmpty(this.txtInputQuantity.Text.Trim()))
|
|||
|
{
|
|||
|
this.txtPlanMHRs.Text = (Funs.GetNewDecimal(this.txtInputQuantity.Text) * Funs.GetNewDecimal(this.txtPlanMHRsUnit.Text)).ToString();
|
|||
|
|
|||
|
decimal? s = BLL.KeyQuantityService.GetSumPlanMHRsByKeyId(this.drpKeyId.Value);
|
|||
|
if (s > 0)
|
|||
|
{
|
|||
|
this.txtPlanMHRsSummary.Text = (s + Funs.GetNewDecimal(this.txtPlanMHRs.Text)).ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.txtPlanMHRsSummary.Text = this.txtPlanMHRs.Text;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 权限设置
|
|||
|
/// <summary>
|
|||
|
/// 菜单按钮权限
|
|||
|
/// </summary>
|
|||
|
private void GetButtonPower()
|
|||
|
{
|
|||
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.KeyQuantityMenuId);
|
|||
|
if (buttonList.Count() > 0)
|
|||
|
{
|
|||
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|||
|
{
|
|||
|
this.btnSave.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|