2024-05-08 11:01:54 +08:00
|
|
|
|
using BLL;
|
|
|
|
|
using System;
|
|
|
|
|
using NPOI.XSSF.UserModel;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.EditorManage
|
|
|
|
|
{
|
|
|
|
|
public partial class PunchEditor : PageBase
|
|
|
|
|
{
|
|
|
|
|
#region 加载
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// 表头过滤
|
|
|
|
|
FilterDataRowItem = FilterDataRowItemImplement;
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
GetButtonPower();//权限设置
|
|
|
|
|
|
|
|
|
|
//项目类型
|
|
|
|
|
this.drpJobType.DataTextField = "ConstText";
|
|
|
|
|
this.drpJobType.DataValueField = "ConstValue";
|
|
|
|
|
this.drpJobType.DataSource = BLL.ConstService.GetConstListByGroupId(BLL.Const.ProjectPlanner_JobType);
|
|
|
|
|
this.drpJobType.DataBind();
|
|
|
|
|
Funs.FineUIPleaseSelectJobType(this.drpJobType);
|
|
|
|
|
|
|
|
|
|
//项目状态
|
|
|
|
|
this.drpJobStatus.DataTextField = "ConstText";
|
|
|
|
|
this.drpJobStatus.DataValueField = "ConstValue";
|
|
|
|
|
this.drpJobStatus.DataSource = BLL.ConstService.GetConstListByGroupId(BLL.Const.ProjectPlanner_JobStatus);
|
|
|
|
|
this.drpJobStatus.DataBind();
|
|
|
|
|
Funs.FineUIPleaseSelectJobStatus(this.drpJobStatus);
|
|
|
|
|
|
|
|
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
|
|
|
var f1 = from x in Funs.DB.Editor_Punch where x.PlanedFinishDate < DateTime.Now
|
|
|
|
|
&& !x.CTECheckDate.HasValue
|
|
|
|
|
select x;
|
|
|
|
|
var f2 = from x in Funs.DB.Editor_Punch
|
|
|
|
|
where (x.PlanedFinishDate > DateTime.Now || !x.PlanedFinishDate.HasValue)
|
|
|
|
|
&& !x.CTECheckDate.HasValue
|
|
|
|
|
select x;
|
|
|
|
|
var f3= from x in Funs.DB.Editor_Punch
|
|
|
|
|
where x.CTECheckDate.HasValue
|
|
|
|
|
select x;
|
|
|
|
|
lbNoFinish.Text = f1.Count().ToString();
|
|
|
|
|
lbOnFinish.Text = f2.Count().ToString();
|
|
|
|
|
lbFinished.Text = f3.Count().ToString();
|
|
|
|
|
// 绑定表格
|
|
|
|
|
BindGrid();
|
|
|
|
|
BindGrid2();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绑定数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindGrid()
|
|
|
|
|
{
|
|
|
|
|
string strSql = @"SELECT EProjectId,
|
|
|
|
|
ProjectControl_JobNo,
|
|
|
|
|
ProjectControl_JobType,
|
|
|
|
|
ProjectControl_JobStatus,
|
|
|
|
|
ProjectControl_JobTitle,
|
|
|
|
|
ProjectControl_BUCode,
|
|
|
|
|
PM_General_Priority,
|
|
|
|
|
PM_General_Category
|
|
|
|
|
FROM dbo.Editor_EProject WHERE 1=1 ";
|
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
|
|
|
if (this.drpJobType.SelectedValue != BLL.Const._Null)
|
|
|
|
|
{
|
|
|
|
|
strSql += " AND ProjectControl_JobType=@JobType ";
|
|
|
|
|
listStr.Add(new SqlParameter("@JobType", this.drpJobType.SelectedItem.Text));
|
|
|
|
|
}
|
2024-10-10 15:14:29 +08:00
|
|
|
|
if (this.drpJobStatus.SelectedValue != BLL.Const._Null && this.drpJobStatus.SelectedValue != null)
|
2024-05-08 11:01:54 +08:00
|
|
|
|
{
|
|
|
|
|
strSql += " AND ProjectControl_JobStatus=@Status ";
|
|
|
|
|
listStr.Add(new SqlParameter("@Status", this.drpJobStatus.SelectedItem.Text));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtJobNO.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
strSql += " AND ProjectControl_JobNo LIKE @jobNO ";
|
|
|
|
|
listStr.Add(new SqlParameter("@jobNO", this.txtJobNO.Text.Trim() + "%"));
|
|
|
|
|
}
|
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
|
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
|
// 2.获取当前分页数据
|
|
|
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
|
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
|
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
|
Grid1.DataSource = table;
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Grid1行选择事件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Grid行选择事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_RowSelect(object sender, GridRowSelectEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string eProjectId = this.Grid1.SelectedRowID;
|
|
|
|
|
if (!string.IsNullOrEmpty(eProjectId))
|
|
|
|
|
{
|
|
|
|
|
var eproject = BLL.EProjectService.GeteProjectById(eProjectId);
|
|
|
|
|
var mans = from x in Funs.DB.ManHours_Plan where x.EProjectId == eProjectId && x.Roles.StartsWith("S") select x.EngineerId;
|
|
|
|
|
var ctePunch = from x in Funs.DB.Editor_Punch where x.EProjectId == eProjectId select x.CTECheckerId;
|
|
|
|
|
var ownerPunch = from x in Funs.DB.Editor_Punch where x.EProjectId == eProjectId select x.OwnerCheckerId;
|
|
|
|
|
|
|
|
|
|
if (CurrUser.UserId == Const.GlyId || (mans.Count() > 0 && mans.Distinct().Contains(CurrUser.UserId))
|
|
|
|
|
|| eproject.ProjectControl_ConstManagerId == CurrUser.UserId
|
|
|
|
|
|| (ctePunch.Count() > 0 && ctePunch.Distinct().Contains(CurrUser.UserId))
|
|
|
|
|
|| (ownerPunch.Count() > 0 && ownerPunch.Distinct().Contains(CurrUser.UserId)))
|
|
|
|
|
{
|
|
|
|
|
this.btnEdit.Hidden = false;
|
|
|
|
|
this.btnMenuEdit.Hidden = false;
|
|
|
|
|
this.btnImport.Hidden = false;
|
|
|
|
|
this.Grid1.EnableRowDoubleClickEvent = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.btnEdit.Hidden = true;
|
|
|
|
|
this.btnMenuEdit.Hidden = true;
|
|
|
|
|
this.btnImport.Hidden = true;
|
|
|
|
|
this.Grid1.EnableRowDoubleClickEvent = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 过滤表头
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 过滤表头
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_FilterChange(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据表头信息过滤列表数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sourceObj"></param>
|
|
|
|
|
/// <param name="fillteredOperator"></param>
|
|
|
|
|
/// <param name="fillteredObj"></param>
|
|
|
|
|
/// <param name="column"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool FilterDataRowItemImplement(object sourceObj, string fillteredOperator, object fillteredObj, string column)
|
|
|
|
|
{
|
|
|
|
|
bool valid = false;
|
|
|
|
|
if (column == "ProjectControl_JobNo")
|
|
|
|
|
{
|
|
|
|
|
string sourceValue = sourceObj.ToString();
|
|
|
|
|
string fillteredValue = fillteredObj.ToString();
|
|
|
|
|
if (fillteredOperator == "equal" && sourceValue == fillteredValue)
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (column == "ProjectControl_JobType")
|
|
|
|
|
{
|
|
|
|
|
string sourceValue = sourceObj.ToString();
|
|
|
|
|
string fillteredValue = fillteredObj.ToString();
|
|
|
|
|
if (fillteredOperator == "equal" && sourceValue == fillteredValue)
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (column == "ProjectControl_JobTitle")
|
|
|
|
|
{
|
|
|
|
|
string sourceValue = sourceObj.ToString();
|
|
|
|
|
string fillteredValue = fillteredObj.ToString();
|
|
|
|
|
if (fillteredOperator == "equal" && sourceValue == fillteredValue)
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (column == "ProjectControl_JobStatus")
|
|
|
|
|
{
|
|
|
|
|
string sourceValue = sourceObj.ToString();
|
|
|
|
|
string fillteredValue = fillteredObj.ToString();
|
|
|
|
|
if (fillteredOperator == "equal" && sourceValue == fillteredValue)
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (column == "ProjectControl_BUCode")
|
|
|
|
|
{
|
|
|
|
|
string sourceValue = sourceObj.ToString();
|
|
|
|
|
string fillteredValue = fillteredObj.ToString();
|
|
|
|
|
if (fillteredOperator == "equal" && sourceValue == fillteredValue)
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (column == "PM_General_Priority")
|
|
|
|
|
{
|
|
|
|
|
string sourceValue = sourceObj.ToString();
|
|
|
|
|
string fillteredValue = fillteredObj.ToString();
|
|
|
|
|
if (fillteredOperator == "equal" && sourceValue == fillteredValue)
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (column == "PM_General_Category")
|
|
|
|
|
{
|
|
|
|
|
string sourceValue = sourceObj.ToString();
|
|
|
|
|
string fillteredValue = fillteredObj.ToString();
|
|
|
|
|
if (fillteredOperator == "equal" && sourceValue == fillteredValue)
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
|
|
|
|
|
{
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return valid;
|
|
|
|
|
}
|
|
|
|
|
#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();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 关闭弹出窗口
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭窗口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Window1_Close(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region CM确认
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 确认
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnAccept_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Grid2.SelectedRowIDArray.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
bool isCM = true;
|
|
|
|
|
foreach (string punchId in Grid2.SelectedRowIDArray)
|
|
|
|
|
{
|
|
|
|
|
var punch = BLL.PunchService.GetPunchById(punchId);
|
|
|
|
|
var eproject = BLL.EProjectService.GeteProjectById(punch.EProjectId);
|
|
|
|
|
if (!string.IsNullOrEmpty(eproject.ProjectControl_ConstManagerId))
|
|
|
|
|
{
|
|
|
|
|
if (eproject.ProjectControl_ConstManagerId != this.CurrUser.UserId)
|
|
|
|
|
{
|
|
|
|
|
isCM = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isCM = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (isCM)
|
|
|
|
|
{
|
|
|
|
|
foreach (string punchId in Grid2.SelectedRowIDArray)
|
|
|
|
|
{
|
|
|
|
|
var punch = BLL.PunchService.GetPunchById(punchId);
|
|
|
|
|
var eproject = BLL.EProjectService.GeteProjectById(punch.EProjectId);
|
|
|
|
|
punch.CTECheckDate = DateTime.Now;
|
|
|
|
|
if (string.IsNullOrEmpty(punch.CTECheckerId))
|
|
|
|
|
{
|
|
|
|
|
punch.CTECheckerName = eproject.ProjectControl_ConstManager;
|
|
|
|
|
punch.CTECheckerId = eproject.ProjectControl_ConstManagerId;
|
|
|
|
|
}
|
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
BindGrid2();
|
|
|
|
|
ShowNotify("Accept Successfully!", MessageBoxIcon.Success);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowNotify("只有该项目的CM才能确认,您没有权限,请重新选择需要确认的项!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 编辑
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInParent("Please select at least one record!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string Id = Grid1.SelectedRowID;
|
|
|
|
|
var eproject = BLL.EProjectService.GeteProjectById(Id);
|
|
|
|
|
if (eproject != null)
|
|
|
|
|
{
|
|
|
|
|
Window1.Title = "Punch Editor(Job No. " + eproject.ProjectControl_JobNo + ")";
|
|
|
|
|
}
|
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PunchEditorList.aspx?eProjectId={0}", Id, "编辑 - ")));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 右键编辑事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
btnEdit_Click(null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Grid行双击事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
btnEdit_Click(null, null);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 判断是否可删除
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 判断是否可以删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool judgementDelete(string id, bool isShow)
|
|
|
|
|
{
|
|
|
|
|
string content = string.Empty;
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(content))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (isShow)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop(content);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 查询
|
2024-10-10 15:14:29 +08:00
|
|
|
|
protected void drpJobType_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.drpJobStatus.Items.Clear();
|
|
|
|
|
if (drpJobType.SelectedText == "Other")
|
|
|
|
|
{
|
|
|
|
|
BLL.ConstService.InitConstValueProjectStatus(this.drpJobStatus, BLL.Const.ProjectPlanner_JobStatus, "3", true);
|
|
|
|
|
}
|
|
|
|
|
if (drpJobType.SelectedText != "Other")
|
|
|
|
|
{
|
|
|
|
|
BLL.ConstService.InitConstValueProjectStatus(this.drpJobStatus, BLL.Const.ProjectPlanner_JobStatus, "2", true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-08 11:01:54 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下拉框选择事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 权限设置
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 菜单按钮权限
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void GetButtonPower()
|
|
|
|
|
{
|
|
|
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.PunchMenuId);
|
|
|
|
|
if (buttonList.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
//if (buttonList.Contains(BLL.Const.BtnModify))
|
|
|
|
|
//{
|
|
|
|
|
// this.btnEdit.Hidden = false;
|
|
|
|
|
// this.btnMenuEdit.Hidden = false;
|
|
|
|
|
// this.Grid1.EnableRowDoubleClickEvent = true;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// this.Grid1.EnableRowDoubleClickEvent = false;
|
|
|
|
|
//}
|
|
|
|
|
//if (buttonList.Contains(BLL.Const.BtnIn))
|
|
|
|
|
//{
|
|
|
|
|
// this.btnImport.Hidden = false;
|
|
|
|
|
//}
|
|
|
|
|
if (buttonList.Contains(BLL.Const.BtnOut))
|
|
|
|
|
{
|
|
|
|
|
this.btnExport.Hidden = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 点击Grid1加载Grid2
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绑定数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindGrid2()
|
|
|
|
|
{
|
|
|
|
|
string strSql = @"SELECT * FROM dbo.View_Punch WHERE 1=1";
|
|
|
|
|
|
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
|
|
|
if (!string.IsNullOrEmpty(txtJobNos.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
strSql = strSql + " AND CHARINDEX(ProjectControl_JobNo,@eProjectId)>0";
|
|
|
|
|
listStr.Add(new SqlParameter("@eProjectId", txtJobNos.Text.Trim()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (drpState.SelectedValue != "0")
|
|
|
|
|
{
|
|
|
|
|
strSql = strSql + " AND States = @States";
|
|
|
|
|
listStr.Add(new SqlParameter("@States", drpState.SelectedValue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strSql = strSql + " ORDER BY States,TagNo";
|
|
|
|
|
|
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
|
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
|
// 2.获取当前分页数据
|
|
|
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
|
|
|
Grid2.RecordCount = tb.Rows.Count;
|
|
|
|
|
var table = this.GetPagedDataTable(Grid2, tb);
|
|
|
|
|
Grid2.DataSource = table;
|
|
|
|
|
Grid2.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 分页、排序
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid2.PageIndex = e.NewPageIndex;
|
|
|
|
|
BindGrid2();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页显示条数下拉框
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void ddlPageSize2_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid2.PageSize = Convert.ToInt32(ddlPageSize2.SelectedValue);
|
|
|
|
|
BindGrid2();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 排序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid2_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid2.SortDirection = e.SortDirection;
|
|
|
|
|
Grid2.SortField = e.SortField;
|
|
|
|
|
BindGrid2();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
protected void btnFind_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid2();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Grid2_RowDataBound(object sender, GridRowEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DataRowView row = e.DataItem as DataRowView;
|
|
|
|
|
if (row["CTECheckDate"].ToString() != string.Empty )
|
|
|
|
|
{
|
|
|
|
|
e.RowCssClass = "color1";
|
|
|
|
|
e.RowSelectable = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (row["PlanedFinishDate"].ToString() != string.Empty)
|
|
|
|
|
{
|
|
|
|
|
DateTime p = Convert.ToDateTime(row["PlanedFinishDate"].ToString());
|
|
|
|
|
if (p < DateTime.Now)
|
|
|
|
|
{
|
|
|
|
|
e.RowCssClass = "color2";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 导入
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导入
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnImport_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//string s = "21003-008";
|
|
|
|
|
|
|
|
|
|
//string[] p = s.Split('-');
|
|
|
|
|
//for (int i =1; i < 30; i++)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
// string d = (Convert.ToInt32(p[1]) + i).ToString("000");
|
|
|
|
|
// string t = p[0] + "-" + d;
|
|
|
|
|
//}
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInParent("Please select at least one record!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string Id = Grid1.SelectedRowID;
|
|
|
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PunchEditorIn.aspx?eProjectId={0}", Id, "导入 - ")));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 导出
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导出按钮
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnExport_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
|
|
|
|
//模板文件
|
|
|
|
|
string TempletFileName = rootPath + "PunchReport.xlsx";
|
|
|
|
|
//导出文件
|
|
|
|
|
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
|
|
|
|
if (!Directory.Exists(filePath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(filePath);
|
|
|
|
|
}
|
|
|
|
|
string ReportFileName = filePath + "out.xlsx";
|
|
|
|
|
|
|
|
|
|
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
|
|
|
|
|
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
|
|
|
|
|
|
|
|
|
|
#region Punch_Report
|
|
|
|
|
XSSFSheet reportModel = (XSSFSheet)hssfworkbook.GetSheet("Punch_List");
|
|
|
|
|
|
|
|
|
|
XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体
|
|
|
|
|
cs_content_Font.FontName = "sans-serif";//字体
|
|
|
|
|
cs_content_Font.FontHeightInPoints = 10; //字体大小
|
|
|
|
|
|
|
|
|
|
var list = (from x in Funs.DB.View_Punch orderby x.ProjectControl_JobNo,x.States, x.TagNo select x).ToList();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtJobNos.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
string[] jobs = txtJobNos.Text.Trim().Split(',');
|
|
|
|
|
list = list.Where(x => jobs.Contains(x.ProjectControl_JobNo)).ToList();
|
|
|
|
|
}
|
|
|
|
|
if (drpState.SelectedValue != "0")
|
|
|
|
|
{
|
|
|
|
|
list = list.Where(x => x.States==drpState.SelectedValue).ToList();
|
|
|
|
|
}
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var rowIndex = 4;
|
|
|
|
|
foreach (var itemOver in list)
|
|
|
|
|
{
|
|
|
|
|
if (reportModel.GetRow(rowIndex) == null) reportModel.CreateRow(rowIndex);
|
|
|
|
|
|
|
|
|
|
#region 列赋值
|
|
|
|
|
|
|
|
|
|
//No.
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(0) == null) reportModel.GetRow(rowIndex).CreateCell(0);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(0).SetCellValue((rowIndex-3).ToString());
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式
|
|
|
|
|
// Job No
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(1) == null) reportModel.GetRow(rowIndex).CreateCell(1);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(1).SetCellValue(itemOver.ProjectControl_JobNo);
|
|
|
|
|
//Area
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(2) == null) reportModel.GetRow(rowIndex).CreateCell(2);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(2).SetCellValue(itemOver.Area);
|
|
|
|
|
//Discipline
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(3) == null) reportModel.GetRow(rowIndex).CreateCell(3);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(3).SetCellValue(itemOver.DisciplineName);
|
|
|
|
|
|
|
|
|
|
//Description
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(4) == null) reportModel.GetRow(rowIndex).CreateCell(4);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(4).SetCellValue(itemOver.Description);
|
|
|
|
|
|
|
|
|
|
//ActionType
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(5) == null) reportModel.GetRow(rowIndex).CreateCell(5);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(5).SetCellValue(itemOver.ActionType);
|
|
|
|
|
//string p = string.Empty;
|
|
|
|
|
//if (itemOver.ClassName.Length > 0)
|
|
|
|
|
//{
|
|
|
|
|
// p = itemOver.ClassName.Substring(0, 1);
|
|
|
|
|
//}
|
|
|
|
|
//Priority
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(6) == null) reportModel.GetRow(rowIndex).CreateCell(6);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(6).SetCellValue(itemOver.ClassName);
|
|
|
|
|
//Contractor
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(7) == null) reportModel.GetRow(rowIndex).CreateCell(7);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(7).SetCellValue(itemOver.RespUnitPerson);
|
|
|
|
|
//BYC_Person
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(8) == null) reportModel.GetRow(rowIndex).CreateCell(8);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(8).SetCellValue(itemOver.BYC_Person);
|
|
|
|
|
//InitiatedByName
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(9) == null) reportModel.GetRow(rowIndex).CreateCell(9);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(9).SetCellValue(itemOver.InitiatedByName);
|
|
|
|
|
// InitiatedByDate
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(10) == null) reportModel.GetRow(rowIndex).CreateCell(10);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(10).SetCellValue(itemOver.InitiatedByDate.HasValue ? string.Format("{0:yyyy-MM-dd}", itemOver.InitiatedByDate) : "");
|
|
|
|
|
// Expected Finish Date
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(11) == null) reportModel.GetRow(rowIndex).CreateCell(11);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(11).SetCellValue(itemOver.PlanedFinishDate.HasValue ? string.Format("{0:yyyy-MM-dd}", itemOver.PlanedFinishDate) : "");
|
|
|
|
|
// Writer
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(12) == null) reportModel.GetRow(rowIndex).CreateCell(12);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(12).SetCellValue(itemOver.ResiedByName);
|
|
|
|
|
// CTECheckerName
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(13) == null) reportModel.GetRow(rowIndex).CreateCell(13);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(13).SetCellValue(itemOver.CTECheckerName);
|
|
|
|
|
//CTECheckDate
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(14) == null) reportModel.GetRow(rowIndex).CreateCell(14);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(14).SetCellValue(itemOver.CTECheckDate.HasValue ? string.Format("{0:yyyy-MM-dd}", itemOver.CTECheckDate) : "");
|
|
|
|
|
//OwnerCheckerName
|
|
|
|
|
//if (reportModel.GetRow(rowIndex).GetCell(15) == null) reportModel.GetRow(rowIndex).CreateCell(15);
|
|
|
|
|
//reportModel.GetRow(rowIndex).GetCell(15).SetCellValue(itemOver.OwnerCheckerName);
|
|
|
|
|
// OwnerCheckDate
|
|
|
|
|
//if (reportModel.GetRow(rowIndex).GetCell(16) == null) reportModel.GetRow(rowIndex).CreateCell(16);
|
|
|
|
|
//reportModel.GetRow(rowIndex).GetCell(16).SetCellValue(itemOver.OwnerCheckDate.HasValue ? string.Format("{0:yyyy-MM-dd}", itemOver.OwnerCheckDate) : "");
|
|
|
|
|
|
|
|
|
|
// Remark
|
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(15) == null) reportModel.GetRow(rowIndex).CreateCell(15);
|
|
|
|
|
reportModel.GetRow(rowIndex).GetCell(15).SetCellValue(itemOver.Remark);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
reportModel.ForceFormulaRecalculation = true;
|
|
|
|
|
|
|
|
|
|
using (FileStream filess = File.OpenWrite(ReportFileName))
|
|
|
|
|
{
|
|
|
|
|
hssfworkbook.Write(filess);
|
|
|
|
|
}
|
|
|
|
|
FileInfo filet = new FileInfo(ReportFileName);
|
|
|
|
|
Response.Clear();
|
|
|
|
|
Response.Charset = "GB2312";
|
|
|
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
|
|
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
|
|
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=Punch_Report_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
|
|
|
|
|
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
|
|
|
|
|
Response.AddHeader("Content-Length", filet.Length.ToString());
|
|
|
|
|
// 指定返回的是一个不能被客户端读取的流,必须被下载
|
|
|
|
|
Response.ContentType = "application/ms-excel";
|
|
|
|
|
// 把文件流发送到客户端
|
|
|
|
|
Response.WriteFile(filet.FullName);
|
|
|
|
|
// 停止页面的执行
|
|
|
|
|
Response.End();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导出方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="grid"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string GetGridTableHtml(Grid grid)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
grid.PageSize = 10000;
|
|
|
|
|
BindGrid();
|
|
|
|
|
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
|
|
|
|
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
foreach (GridColumn column in grid.Columns)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
|
|
|
|
}
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
foreach (GridRow row in grid.Rows)
|
|
|
|
|
{
|
|
|
|
|
sb.Append("<tr>");
|
|
|
|
|
foreach (GridColumn column in grid.Columns)
|
|
|
|
|
{
|
|
|
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
|
|
|
//if (column.ColumnID == "tfNumber")
|
|
|
|
|
//{
|
|
|
|
|
// html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
|
|
|
|
//}
|
|
|
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sb.Append("</tr>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sb.Append("</table>");
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 导出全部
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导出全部
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnExportAll_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("PunchEditorOut.aspx", "编辑 - ")));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 查看
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查看
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void btnMenuView_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInParent("Please select at least one record!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string Id = Grid1.SelectedRowID;
|
|
|
|
|
var eproject = BLL.EProjectService.GeteProjectById(Id);
|
|
|
|
|
if (eproject != null)
|
|
|
|
|
{
|
|
|
|
|
Window1.Title = "Punch Editor(Job No. " + eproject.ProjectControl_JobNo + ")";
|
|
|
|
|
}
|
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PunchEditorList.aspx?eProjectId={0}&view=1", Id, "编辑 - ")));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|