487 lines
20 KiB
C#
487 lines
20 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.IO;
|
|
namespace FineUIPro.Web.JGZL
|
|
{
|
|
public partial class SteelPipeCheckRecord : PageBase
|
|
{
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
|
|
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);
|
|
// 默认显示选中的项目
|
|
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
|
|
}
|
|
|
|
this.InitTreeMenu();//加载树
|
|
}
|
|
}
|
|
#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");
|
|
|
|
// 默认显示选中的项目
|
|
string selectedProjectId = this.drpProjectId.SelectedValue;
|
|
if (!string.IsNullOrEmpty(selectedProjectId) && selectedProjectId != BLL.Const._Null)
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == selectedProjectId).ToList();
|
|
|
|
// 如果项目存在,则选中该节点
|
|
if (projects.Any())
|
|
{
|
|
this.tvControlItem.SelectedNodeID = selectedProjectId;
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
if (this.tvControlItem.SelectedNodeID != "0")
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#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")
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT * from JGZL_SteelPipeCheckRecord where 1=1 ";
|
|
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);
|
|
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.InitTreeMenu();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 打印
|
|
/// <summary>
|
|
/// 打印
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
string projectId = this.tvControlItem.SelectedNodeID;
|
|
|
|
if (projectId != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID))
|
|
{
|
|
string initTemplatePath = "";
|
|
string rootPath = Server.MapPath("~/");
|
|
BLL.Common.FastReportService.ResetData();
|
|
|
|
var report = BLL.SteelPipeCheckRecordService.GetSteelPipeReportById(this.Grid1.SelectedRowID);
|
|
if (report != null)
|
|
{
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName);
|
|
keyValuePairs.Add("ContractCode", report.ContractCode);
|
|
keyValuePairs.Add("ArrivalDate", string.Format("{0:yyyy.MM.dd}", report.ArrivalDate));
|
|
keyValuePairs.Add("ExecutionStandard", report.ExecutionStandard);
|
|
keyValuePairs.Add("Crack", report.Crack);
|
|
keyValuePairs.Add("SlagInclusion", report.SlagInclusion);
|
|
keyValuePairs.Add("ShrinkageHole", report.ShrinkageHole);
|
|
keyValuePairs.Add("HeavyLeather", report.HeavyLeather);
|
|
keyValuePairs.Add("Other", report.Other);
|
|
keyValuePairs.Add("Remark", report.Remark);
|
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
|
|
|
//加载图片
|
|
var imageUrl = (from x in Funs.DB.AttachFile where x.ToKeyId == report.RecordId && x.MenuId == BLL.Const.JGZL_SteelPipeCheckRecordMenuId select x).FirstOrDefault();
|
|
if (imageUrl != null)
|
|
{
|
|
DataTable imagedt = new DataTable();
|
|
imagedt.TableName = "ImageData";
|
|
imagedt.Columns.Add("ImageUrl");
|
|
var newRowsImage = imagedt.NewRow();
|
|
newRowsImage["ImageUrl"] = Funs.RootPath + imageUrl.AttachUrl;
|
|
imagedt.Rows.Add(newRowsImage);
|
|
BLL.Common.FastReportService.AddFastreportTable(imagedt);
|
|
}
|
|
|
|
//明细表1
|
|
string strSql = @"SELECT * from JGZL_SteelPipeCheckRecordItem1 where RecordId=@recordId ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@recordId", this.Grid1.SelectedRowID));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
DataTable dt = new DataTable();
|
|
dt.TableName = "Data";
|
|
dt.Columns.Add("Name");
|
|
dt.Columns.Add("Material");
|
|
dt.Columns.Add("Specifications");
|
|
dt.Columns.Add("Quantity");
|
|
dt.Columns.Add("MaterialCertificateCode");
|
|
dt.Columns.Add("HeatCode");
|
|
dt.Columns.Add("MaterialCertificateSelfNumber");
|
|
|
|
DataRow[] rows = tb.DefaultView.ToTable().Select();
|
|
foreach (var row in rows)
|
|
{
|
|
var newRows = dt.NewRow();
|
|
newRows["Name"] = row["Name"].ToString();
|
|
newRows["Material"] = row["Material"].ToString();
|
|
newRows["Specifications"] = row["Specifications"].ToString();
|
|
newRows["Quantity"] = row["Quantity"].ToString();
|
|
newRows["MaterialCertificateCode"] = row["MaterialCertificateCode"].ToString();
|
|
newRows["HeatCode"] = row["HeatCode"].ToString();
|
|
newRows["MaterialCertificateSelfNumber"] = row["MaterialCertificateSelfNumber"].ToString();
|
|
|
|
dt.Rows.Add(newRows);
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportTable(dt);
|
|
|
|
//明细表2
|
|
string strSql2 = @"SELECT * from JGZL_SteelPipeCheckRecordItem2 where RecordId=@recordId ";
|
|
List<SqlParameter> listStr2 = new List<SqlParameter>();
|
|
listStr2.Add(new SqlParameter("@recordId", this.Grid1.SelectedRowID));
|
|
SqlParameter[] parameter2 = listStr2.ToArray();
|
|
DataTable tb2 = SQLHelper.GetDataTableRunText(strSql2, parameter2);
|
|
|
|
DataTable dt2 = new DataTable();
|
|
dt2.TableName = "ItemData";
|
|
dt2.Columns.Add("Num");
|
|
dt2.Columns.Add("Part1");
|
|
dt2.Columns.Add("Part2");
|
|
dt2.Columns.Add("Part3");
|
|
dt2.Columns.Add("Part4");
|
|
dt2.Columns.Add("InnerDiameter");
|
|
dt2.Columns.Add("OuterDiameter");
|
|
dt2.Columns.Add("Lengths");
|
|
|
|
DataRow[] rows2 = tb2.DefaultView.ToTable().Select();
|
|
int i = 0;
|
|
foreach (var row in rows2)
|
|
{
|
|
var newRows = dt2.NewRow();
|
|
newRows["Num"] = (i + 1).ToString();
|
|
newRows["Part1"] = row["Part1"].ToString();
|
|
newRows["Part2"] = row["Part2"].ToString();
|
|
newRows["Part3"] = row["Part3"].ToString();
|
|
newRows["Part4"] = row["Part4"].ToString();
|
|
newRows["InnerDiameter"] = row["InnerDiameter"].ToString();
|
|
newRows["OuterDiameter"] = row["OuterDiameter"].ToString();
|
|
newRows["Lengths"] = row["Lengths"].ToString();
|
|
|
|
dt2.Rows.Add(newRows);
|
|
i++;
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportTable(dt2);
|
|
}
|
|
initTemplatePath = "File\\Fastreport\\JGZL\\钢管检查验收记录.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;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 维护
|
|
/// <summary>
|
|
/// 增加
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SteelPipeCheckRecordEdit.aspx?projectId={0}", this.tvControlItem.SelectedNodeID, "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 双击编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.JGZL_SteelPipeCheckRecordMenuId, BLL.Const.BtnModify))
|
|
{
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SteelPipeCheckRecordEdit.aspx?recordId={0}", this.Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.JGZL_SteelPipeCheckRecordMenuId, BLL.Const.BtnModify))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SteelPipeCheckRecordEdit.aspx?recordId={0}", Grid1.SelectedRowID, "维护 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <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.JGZL_SteelPipeCheckRecordMenuId, 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;
|
|
//删除附件
|
|
AttachFileService.GetAttachFile(rowID, BLL.Const.JGZL_SteelPipeCheckRecordMenuId);
|
|
BLL.SteelPipeCheckRecordItem1Service.DeleteSteelPipeItem1ByRecordId(rowID);
|
|
BLL.SteelPipeCheckRecordItem2Service.DeleteSteelPipeItem2ByRecordId(rowID);
|
|
BLL.SteelPipeCheckRecordService.DeleteSteelPipeReportById(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 Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.InitTreeMenu();//加载树
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
}
|
|
} |