392 lines
14 KiB
C#
392 lines
14 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.CQMS.Foreign
|
|
{
|
|
public partial class ITPListProject : PageBase
|
|
{
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpSponsorUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
|
|
UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true);
|
|
|
|
|
|
|
|
GetButtonPower();
|
|
BindGrid();
|
|
btnNew.OnClientClick = Window1.GetShowReference("ITPListProjectEdit.aspx") + "return false;";
|
|
}
|
|
}
|
|
#endregion
|
|
protected void btnQuery_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT [ITPListId]
|
|
,[ProjectId]
|
|
,[Name]
|
|
,[AttachUrl]
|
|
,[CompileMan]
|
|
,[CompileDate]
|
|
,[UnitId]
|
|
,[InstallationId]
|
|
,[UnitWorkId]
|
|
,[CNProfessionalCode]
|
|
,[DocCode]
|
|
,[CheckLevel]
|
|
,[CheckContent]
|
|
,[Memo]
|
|
,[CheckDate]
|
|
,[FileType]
|
|
FROM CQMS_Foreign_ITPListProject where ProjectId='"+this.CurrUser.LoginProjectId+"' ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(txtStartTime.Text.Trim()))
|
|
{
|
|
strSql += " and CheckDate >='" + txtStartTime.Text.Trim() + " 00:00:00' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(txtEndTime.Text.Trim()))
|
|
{
|
|
strSql += " and CheckDate <='" + txtEndTime.Text.Trim() + " 23:59:59 ' ";
|
|
}
|
|
if (drpSponsorUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND UnitId='" + drpSponsorUnit.SelectedValue+"' ";
|
|
|
|
}
|
|
if (drpUnitWork.SelectedValue != Const._Null)
|
|
{
|
|
strSql += " AND UnitWorkId='" + drpUnitWork.SelectedValue + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(drpLevel.SelectedValue))
|
|
{
|
|
strSql += " AND CheckLevel='" + drpLevel.SelectedValue + "' ";
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
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 btnImport_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("ITPListProjectDataIn.aspx", "导入 - ")));
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtName_TextChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页
|
|
/// <summary>
|
|
/// 分页索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
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, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 右键编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuModify_Click(object sender, EventArgs e)
|
|
{
|
|
EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ITPListProjectEdit.aspx?ITPListId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDel_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var itpList = BLL.ITPListProjectService.GetITPListProjectById(rowID);
|
|
if (itpList != null)
|
|
{
|
|
BLL.ITPListProjectService.DeleteITPListProjectById(rowID);
|
|
}
|
|
}
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 权限设置
|
|
/// <summary>
|
|
/// 权限设置
|
|
/// </summary>
|
|
private void GetButtonPower()
|
|
{
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ITPListProjectMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuModify.Hidden = false;
|
|
this.Grid1.EnableRowDoubleClickEvent = true;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDel.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Grid行点击事件
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
string itpListId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
if (e.CommandName== "AttachUrl")
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/Foreign/ITPListProject&menuId={1}", itpListId, BLL.Const.ITPListProjectMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出
|
|
/// <summary>
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("ITP清单" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
//this.Grid1.PageSize = this.;
|
|
this.Grid1.PageSize = 10000;
|
|
BindGrid();
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
private string GetGridTableHtml(Grid grid)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
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)
|
|
{
|
|
if (column.ColumnID != "AttachUrl" && column.ColumnID != "ITPListId")
|
|
{
|
|
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
|
}
|
|
}
|
|
sb.Append("</tr>");
|
|
foreach (GridRow row in grid.Rows)
|
|
{
|
|
// var datarow = Funs.DB.CQMS_Foreign_ITPListProject.Where(u => u.ITPListId == row.DataKeys[0]).FirstOrDefault();
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
if (column.ColumnID != "AttachUrl" && column.ColumnID != "ITPListId")
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfPageIndex")
|
|
{
|
|
html = (row.FindControl("lblPageIndex") as AspNet.Label).Text;
|
|
}else if (column.ColumnID == "unitId")
|
|
{
|
|
html = (row.FindControl("Label3") as AspNet.Label).Text;
|
|
}
|
|
else if (column.ColumnID == "InstallationId")
|
|
{
|
|
html = (row.FindControl("Label4") as AspNet.Label).Text;
|
|
}
|
|
else if (column.ColumnID == "CNProfessionalCode")
|
|
{
|
|
html = (row.FindControl("Label1") as AspNet.Label).Text;
|
|
}
|
|
else if (column.ColumnID == "UnitWorkId")
|
|
{
|
|
html = (row.FindControl("Label5") as AspNet.Label).Text;
|
|
}
|
|
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
|
}
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
protected string ConvertUnitName(object UnitId)
|
|
{
|
|
if (UnitId != null)
|
|
{
|
|
var unit = Funs.DB.Base_Unit.Where(u => u.UnitId == UnitId.ToString()).FirstOrDefault();
|
|
if (unit != null)
|
|
{
|
|
return unit.UnitName;
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
protected string ConvertInstallationName(object installationId)
|
|
{
|
|
if (installationId != null)
|
|
{
|
|
var installation = Funs.DB.Project_Installation.Where(u => u.InstallationId == installationId.ToString()).FirstOrDefault();
|
|
if (installation != null)
|
|
{
|
|
return installation.InstallationName;
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
protected string ConvertWorkAreaName(object workAreaId)
|
|
{
|
|
if (workAreaId != null)
|
|
{
|
|
var WorkArea = Funs.DB.WBS_UnitWork.Where(u => u.UnitWorkId == workAreaId.ToString()).FirstOrDefault();
|
|
if (WorkArea != null)
|
|
{
|
|
return WorkArea.UnitWorkName;
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
protected string ConvertCNProfessionalName(object CNProfessionalId)
|
|
{
|
|
if (CNProfessionalId != null)
|
|
{
|
|
var CNProfessional = Funs.DB.Base_CNProfessional.Where(u => u.CNProfessionalId == CNProfessionalId.ToString()).FirstOrDefault();
|
|
if (CNProfessional != null)
|
|
{
|
|
return CNProfessional.ProfessionalName;
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
} |