508 lines
19 KiB
C#
508 lines
19 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.SYBData
|
|
{
|
|
public partial class SYBDataList : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 项目Id
|
|
/// </summary>
|
|
private string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 试压包号
|
|
/// </summary>
|
|
private string TestPackageDivisionId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["TestPackageDivisionId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["TestPackageDivisionId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.drpProjectId.DataTextField = "ProjectCode";
|
|
this.drpProjectId.DataValueField = "ProjectId";
|
|
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
this.drpProjectId.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpProjectId);
|
|
|
|
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
|
|
this.InitTreeMenu();//加载树
|
|
//this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
|
|
//this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载树项目
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "项目";
|
|
rootNode.ToolTip = "项目";
|
|
rootNode.NodeID = "0";
|
|
rootNode.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
|
|
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
if (this.drpProjectId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == this.drpProjectId.SelectedValue).ToList();
|
|
}
|
|
foreach (var item in projects)
|
|
{
|
|
TreeNode rootProjectNode = new TreeNode();//定义根节点
|
|
rootProjectNode.Text = item.ProjectCode;
|
|
rootProjectNode.NodeID = item.ProjectId;
|
|
rootProjectNode.EnableClickEvent = true;
|
|
rootProjectNode.Expanded = true;
|
|
rootProjectNode.ToolTip = item.ProjectName;
|
|
rootProjectNode.CommandName = "项目名称";
|
|
rootNode.Nodes.Add(rootProjectNode);
|
|
|
|
var testpackageList = BLL.TestPackageDivisionService.GetTestPackageDivisionListByProjectId(item.ProjectId);
|
|
foreach (var tp in testpackageList)
|
|
{
|
|
TreeNode newNode = new TreeNode();//定义根节点
|
|
newNode.Text = tp.TestPackageCode;
|
|
newNode.NodeID = tp.TestPackageDivisionId;
|
|
newNode.EnableClickEvent = true;
|
|
newNode.Expanded = true;
|
|
newNode.ToolTip = tp.TestPackageCode;
|
|
newNode.CommandName = "试压包号";
|
|
rootProjectNode.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
if (this.tvControlItem.SelectedNodeID != "0")
|
|
{
|
|
if (this.tvControlItem.SelectedNode.CommandName == "项目名称")
|
|
{
|
|
this.ProjectId = this.tvControlItem.SelectedNodeID;
|
|
}
|
|
else if (this.tvControlItem.SelectedNode.CommandName == "试压包号")
|
|
{
|
|
this.TestPackageDivisionId = this.tvControlItem.SelectedNodeID;
|
|
this.ProjectId = this.tvControlItem.SelectedNode.ParentNode.NodeID;
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"select * from SYBData_FileDirectory order by FileCode asc";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
//if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
//{
|
|
// strSql += " AND ProjectId = @ProjectId";
|
|
// listStr.Add(new SqlParameter("@ProjectId", this.tvControlItem.SelectedNodeID));
|
|
//}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
// 2.获取当前分页数据
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页选择下拉改变事件
|
|
/// <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();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 查询
|
|
///<summary>
|
|
///查询
|
|
///</summary>
|
|
///<param name="sender"></param>
|
|
///<param name="e"></param>
|
|
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.ProjectId = this.drpProjectId.SelectedValue;
|
|
//this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
|
|
this.InitTreeMenu();
|
|
//BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.SYBData_FileDirectoryMenuId, Const.BtnDelete))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
bool isShow = true;
|
|
if (Grid1.SelectedRowIndexArray.Length > 1)
|
|
{
|
|
isShow = false;
|
|
}
|
|
bool isDelete = false;
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
if (judgementDelete(rowID, isShow))
|
|
{
|
|
isDelete = true;
|
|
BLL.SYBData_FileDirectoryService.DeleteFileDirectoryById(rowID);
|
|
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除试压包资料目录");
|
|
}
|
|
}
|
|
if (isDelete)
|
|
{
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
}
|
|
this.BindGrid();
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#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, MessageBoxIcon.Error);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 打印
|
|
/// <summary>
|
|
/// 打印
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
string initTemplatePath = "";
|
|
string rootPath = Server.MapPath("~/");
|
|
BLL.Common.FastReportService.ResetData();
|
|
|
|
string strSql = @"SELECT * from SYBData_FileDirectory order by FileCode asc";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
//listStr.Add(new SqlParameter("@ProjectId", projectId));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
DataTable dt = new DataTable();
|
|
dt.TableName = "Data";
|
|
dt.Columns.Add("FileCode");
|
|
dt.Columns.Add("FileName");
|
|
dt.Columns.Add("CompletionStatus");
|
|
|
|
DataRow[] rows = tb.DefaultView.ToTable().Select();
|
|
int i = 0;
|
|
foreach (var row in rows)
|
|
{
|
|
var newRow = dt.NewRow();
|
|
newRow["FileCode"] = row["FileCode"].ToString();
|
|
newRow["FileName"] = row["FileName"].ToString();
|
|
newRow["CompletionStatus"] = row["CompletionStatus"].ToString();
|
|
dt.Rows.Add(newRow);
|
|
i++;
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportTable(dt);
|
|
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
var tp = BLL.TestPackageDivisionService.GetTestPackageDivisionById(this.TestPackageDivisionId);
|
|
if (tp != null)
|
|
{
|
|
keyValuePairs.Add("PressureTestPackageCode", tp.TestPackageCode);
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
|
|
|
initTemplatePath = "File\\Fastreport\\SYBData\\试压包资料目录.frx";
|
|
if (File.Exists(rootPath + initTemplatePath))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowPrint.GetShowReference(String.Format("../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
//protected void btnOut_Click(object sender, EventArgs e)
|
|
//{
|
|
// string rootPath = Server.MapPath("~/");
|
|
// string initTemplatePath = string.Empty;
|
|
// string uploadfilepath = string.Empty;
|
|
// string newUrl = string.Empty;
|
|
// string filePath = string.Empty;
|
|
|
|
// //每页显示的固定数据行数
|
|
// int rowsPerPage = 36;
|
|
|
|
// string projectId = this.tvControlItem.SelectedNodeID;
|
|
// if (!string.IsNullOrEmpty(projectId))
|
|
// {
|
|
// string strSql = @"SELECT * from JGZL_FileDirectory order by SerialNumber asc";
|
|
// List<SqlParameter> listStr = new List<SqlParameter>();
|
|
// //listStr.Add(new SqlParameter("@ProjectId", projectId));
|
|
// SqlParameter[] parameter = listStr.ToArray();
|
|
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// initTemplatePath = Const.JGZL_FileDirectoryUrl;
|
|
// uploadfilepath = rootPath + initTemplatePath;
|
|
|
|
// newUrl = uploadfilepath.Replace("交工技术文件目录导出模板", "交工技术文件目录");
|
|
// if (File.Exists(newUrl))
|
|
// {
|
|
// File.Delete(newUrl);
|
|
// }
|
|
// File.Copy(uploadfilepath, newUrl);
|
|
// //更新书签内容
|
|
// Document doc = new Aspose.Words.Document(newUrl);
|
|
// DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
|
// Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
|
|
|
|
// Bookmark projectName = doc.Range.Bookmarks["ProjectName"];
|
|
// if (projectName != null)
|
|
// {
|
|
// projectName.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName;
|
|
// }
|
|
|
|
// // 设置表头行重复显示
|
|
// table.Rows[0].RowFormat.HeadingFormat = true;
|
|
// table.Rows[1].RowFormat.HeadingFormat = true;
|
|
|
|
// // 先记录页尾行,并从表格中移除
|
|
// Row footerRow = table.Rows[table.Rows.Count - 1];
|
|
// table.Rows.RemoveAt(table.Rows.Count - 1);
|
|
|
|
// for (int i = 0; i < tb.Rows.Count; i++)
|
|
// {
|
|
// //创建行
|
|
// Row row = new Row(doc);
|
|
// row.Cells.Add(CreateCell((i + 1).ToString(), doc, 27, "", ""));
|
|
// row.Cells.Add(CreateCell(tb.Rows[i]["FileCode"].ToString(), doc, 118, "", ""));
|
|
// row.Cells.Add(CreateCell(tb.Rows[i]["FileName"].ToString(), doc, 261.3, "", ""));
|
|
// row.Cells.Add(CreateCell(tb.Rows[i]["Remark"].ToString(), doc, 74, "", ""));
|
|
// table.Rows.Insert(i + 2, row);
|
|
// }
|
|
// // 计算并插入空白行,填满整页
|
|
// // 计算总数据行数
|
|
// int totalDataRows = tb.Rows.Count;
|
|
// // 计算需要补充的空白行数量
|
|
// int remainder = totalDataRows % rowsPerPage;
|
|
// int needBlankRows = remainder == 0 ? 0 : rowsPerPage - remainder;
|
|
|
|
// // 插入空白行(和数据行格式保持一致,仅内容为空)
|
|
// for (int i = 0; i < needBlankRows - 1; i++)
|
|
// {
|
|
// Row blankRow = new Row(doc);
|
|
// // 空白行的单元格宽度和数据行保持一致
|
|
// blankRow.Cells.Add(CreateCell("", doc, 27, "", ""));
|
|
// blankRow.Cells.Add(CreateCell("", doc, 118, "", ""));
|
|
// blankRow.Cells.Add(CreateCell("", doc, 261.3, "", ""));
|
|
// blankRow.Cells.Add(CreateCell("", doc, 74, "", ""));
|
|
// // 插入到表格最后一行
|
|
// table.Rows.Add(blankRow);
|
|
// }
|
|
// //把页尾行重新加回表格最后
|
|
// table.Rows.Add(footerRow);
|
|
|
|
// //自动设置表格样式
|
|
// table.AutoFit(AutoFitBehavior.FixedColumnWidths);
|
|
// table.Alignment = TableAlignment.Center;
|
|
|
|
// doc.Save(newUrl);
|
|
|
|
// string fileName = Path.GetFileName(newUrl);
|
|
// FileInfo info = new FileInfo(newUrl);
|
|
// long fileSize = info.Length;
|
|
// Response.Clear();
|
|
// Response.ContentType = "application/x-zip-compressed";
|
|
// Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
// Response.AddHeader("Content-Length", fileSize.ToString());
|
|
// Response.TransmitFile(newUrl, 0, fileSize);
|
|
// Response.Flush();
|
|
// Response.Close();
|
|
// File.Delete(newUrl);
|
|
// }
|
|
// else
|
|
// {
|
|
// Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
// return;
|
|
// }
|
|
//}
|
|
|
|
//public static Cell CreateCell(String value, Document doc, double cellWidth, string cellMerge = "", string CenterPage = "", string cellUnitLeft = "")
|
|
//{
|
|
// Cell cell = new Cell(doc);
|
|
// Paragraph p = new Paragraph(doc);
|
|
// if (!string.IsNullOrEmpty(cellMerge))
|
|
// {
|
|
// if (cellMerge == "0")
|
|
// {
|
|
// cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.First;//竖直方向合并的第一个单元格
|
|
// }
|
|
// else
|
|
// {
|
|
// cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.Previous;//竖直方向合并的第一个单元格
|
|
// }
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// cell.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
|
|
// }
|
|
// if (!string.IsNullOrEmpty(CenterPage))
|
|
// {
|
|
// //序号
|
|
// value = " " + value;
|
|
// }
|
|
// if (!string.IsNullOrEmpty(cellUnitLeft))
|
|
// {
|
|
// p.ParagraphFormat.Alignment = ParagraphAlignment.Left;//表格中字体居左
|
|
// }
|
|
// else
|
|
// {
|
|
// p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//表格中字体居中
|
|
// }
|
|
|
|
|
|
// p.AppendChild(new Run(doc, value));
|
|
|
|
// cell.CellFormat.Width = cellWidth;
|
|
|
|
// cell.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
|
|
|
|
// cell.CellFormat.Borders.LineWidth = 0.75;
|
|
|
|
// cell.AppendChild(p);
|
|
// return cell;
|
|
//}
|
|
|
|
#endregion
|
|
}
|
|
} |