ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/HJGL/HotProessManage/HotProessTrust.aspx.cs

636 lines
26 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using BLL;
using Newtonsoft.Json.Linq;
namespace FineUIPro.Web.HJGL.HotProessManage
{
public partial class HotProessTrust : PageBase
{
#region
/// <summary>
/// 热处理委托主键
/// </summary>
public string HotProessTrustId
{
get
{
return (string)ViewState["HotProessTrustId"];
}
set
{
ViewState["HotProessTrustId"] = value;
}
}
#endregion
#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();
List<Model.HandleStep> myList = new List<Model.HandleStep>();
myList = BLL.HJGL_PW_JointInfoService.GetProessTypes();
drpProessTypes.DataTextField = "Name";
drpProessTypes.DataValueField = "Id";
drpProessTypes.DataSource = myList;
drpProessTypes.DataBind();
Funs.FineUIPleaseSelect(drpProessTypes);
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.HotProessTrustId = string.Empty;
this.InitTreeMenu();//加载树
//this.tvControlItem.SelectedNodeID = "0";
//BindGrid();
}
}
#endregion
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "项目";
rootNode.NodeID = "0";
rootNode.Expanded = true;
rootNode.ToolTip = "红色表示施工号下存在未打印的热处理委托记录";
rootNode.EnableClickEvent = true;
this.tvControlItem.Nodes.Add(rootNode);
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
if (this.drpProjectId.SelectedValueArray.Length > 1 || (this.drpProjectId.SelectedValueArray.Length == 1 && this.drpProjectId.SelectedValue != "null"))
{
projects = projects.Where(x => this.drpProjectId.SelectedValueArray.Contains(x.ProjectId)).ToList();
}
List<Model.HJGL_CH_HotProessTrust> trustLists = new List<Model.HJGL_CH_HotProessTrust>(); ///热处理委托单
if (this.rblPrint.SelectedValue == "2") //全部
{
trustLists = (from x in Funs.DB.HJGL_CH_HotProessTrust
where x.HotProessTrustCode.Contains(this.txtSearchNo.Text.Trim())
select x).ToList();
}
else if (this.rblPrint.SelectedValue == "1") //已打印
{
trustLists = (from x in Funs.DB.HJGL_CH_HotProessTrust
where x.HotProessTrustCode.Contains(this.txtSearchNo.Text.Trim()) && x.IsPrint == true
select x).ToList();
}
else if (this.rblPrint.SelectedValue == "0") //未打印
{
trustLists = (from x in Funs.DB.HJGL_CH_HotProessTrust
where x.HotProessTrustCode.Contains(this.txtSearchNo.Text.Trim()) && (x.IsPrint == null || x.IsPrint == false)
select x).ToList();
}
foreach (var item in projects)
{
TreeNode rootUnitNode = new TreeNode();//定义根节点
rootUnitNode.NodeID = item.ProjectId;
if ((from x in trustLists where x.ProjectId == item.ProjectId && (x.IsPrint == null || x.IsPrint == false) select x).Count() > 0) //存在未打印的委托单
{
rootUnitNode.Text = "<font color='#FF7575'>" + item.ProjectCode + "</font>";
}
else
{
rootUnitNode.Text = item.ProjectCode;
}
rootUnitNode.ToolTip = item.ProjectName;
rootUnitNode.CommandName = "项目名称";
rootUnitNode.EnableClickEvent = true;
rootUnitNode.EnableExpandEvent = true;
rootNode.Nodes.Add(rootUnitNode);
if (!string.IsNullOrEmpty(this.txtSearchNo.Text.Trim()))
{
var projectTrustLists = (from x in trustLists
where x.ProjectId == item.ProjectId
orderby x.CreateDate descending
select x).ToList();
if (projectTrustLists.Count > 0)
{
rootUnitNode.Expanded = true;
this.BindNodes(rootUnitNode, projectTrustLists);
}
}
else
{
TreeNode tn = new TreeNode();
tn.NodeID = "temp";
tn.Text = "正在加载...";
rootUnitNode.Nodes.Add(tn);
}
}
}
#endregion
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.HJGL_CH_HotProessTrust> trustList)
{
foreach (var item in trustList)
{
TreeNode newNode = new TreeNode();
if (item.IsPrint == true)
{
newNode.Text = item.HotProessTrustCode;
}
else
{
newNode.Text = "<font color='#FF7575'>" + item.HotProessTrustCode + "</font>";
}
newNode.NodeID = item.HotProessTrustId;
newNode.ToolTip = item.HotProessTrustCode;
newNode.CommandName = "委托单号";
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
#endregion
protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
{
if (e.Node.Nodes != null)
{
e.Node.Nodes.Clear();
}
List<Model.HJGL_CH_HotProessTrust> trustLists = new List<Model.HJGL_CH_HotProessTrust>(); ///热处理委托单
if (this.rblPrint.SelectedValue == "2") //全部
{
trustLists = (from x in Funs.DB.HJGL_CH_HotProessTrust
where x.HotProessTrustCode.Contains(this.txtSearchNo.Text.Trim())
&& x.ProjectId == e.Node.NodeID
orderby x.CreateDate descending
select x).ToList();
}
else if (this.rblPrint.SelectedValue == "1") //已打印
{
trustLists = (from x in Funs.DB.HJGL_CH_HotProessTrust
where x.HotProessTrustCode.Contains(this.txtSearchNo.Text.Trim()) && x.IsPrint == true
&& x.ProjectId == e.Node.NodeID
orderby x.CreateDate descending
select x).ToList();
}
else if (this.rblPrint.SelectedValue == "0") //未打印
{
trustLists = (from x in Funs.DB.HJGL_CH_HotProessTrust
where x.HotProessTrustCode.Contains(this.txtSearchNo.Text.Trim()) && (x.IsPrint == null || x.IsPrint == false)
&& x.ProjectId == e.Node.NodeID
orderby x.CreateDate descending
select x).ToList();
}
this.BindNodes(e.Node, trustLists);
}
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
this.HotProessTrustId = tvControlItem.SelectedNodeID;
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
string strSql = string.Empty;
List<SqlParameter> listStr = new List<SqlParameter>();
this.SetTextTemp();
this.PageInfoLoad(); ///页面输入提交信息
string projectIds = BLL.Base_ProjectService.GetStrOnProjectIds(this.CurrUser.UserId, "1");
if (this.tvControlItem.SelectedNode != null)
{
if (this.tvControlItem.SelectedNode.CommandName == "委托单号")
{
strSql = @"SELECT * "
+ @" FROM dbo.HJGL_View_CH_HotProessTrustItem AS Trust"
+ @" WHERE Trust.ProjectId= @ProjectId AND Trust.HotProessTrustId=@HotProessTrustId ";
var trust = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustByID(this.HotProessTrustId);
listStr.Add(new SqlParameter("@ProjectId", trust != null ? trust.ProjectId : this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@HotProessTrustId", this.HotProessTrustId));
}
else if (this.tvControlItem.SelectedNode.CommandName == "项目名称")
{
strSql = @"SELECT * "
+ @" FROM dbo.HJGL_View_CH_HotProessTrustItem AS Trust"
+ @" WHERE Trust.ProjectId= @ProjectId and Trust.HotProessTrustId is not null ";
listStr.Add(new SqlParameter("@ProjectId", this.HotProessTrustId));
}
else //选择项目根节点或没有选择节点
{
strSql = @"SELECT * "
+ @" FROM dbo.HJGL_View_CH_HotProessTrustItem AS Trust"
+ @" WHERE Trust.HotProessTrustId is not null AND CHARINDEX(Trust.ProjectId,@ProjectId)>0 ";
listStr.Add(new SqlParameter("@ProjectId", projectIds));
}
if (this.drpProessTypes.SelectedValue != BLL.Const._Null)
{
strSql += @" and Trust.ProessTypes=@ProessTypes ";
listStr.Add(new SqlParameter("@ProessTypes", this.drpProessTypes.SelectedValue));
}
if (!string.IsNullOrEmpty(this.txtIsoNo.Text.Trim()))
{
strSql += @" and Trust.ISO_IsoNo like '%'+@ISO_IsoNo+'%' ";
listStr.Add(new SqlParameter("@ISO_IsoNo", this.txtIsoNo.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();
}
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#region
/// <summary>
/// 加载页面输入提交信息
/// </summary>
private void PageInfoLoad()
{
this.btnEdit.Hidden = true;
this.btnDelete.Hidden = true;
this.btnPrint.Hidden = true;
var trust = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustByID(this.HotProessTrustId);
if (trust != null)
{
this.txtHotProessTrustCode.Text = trust.HotProessTrustCode;
if (!string.IsNullOrEmpty(trust.TrustUnitId))
{
var unit = BLL.Base_UnitService.GetUnit(trust.TrustUnitId);
if (unit != null)
{
this.drpCH_TrustUnit.Text = unit.UnitName;
}
}
this.txtProjectName.Text = trust.ProjectName;
this.txtConstructionNo.Text = trust.ConstructionNo;
if (!string.IsNullOrEmpty(trust.TrstManId))
{
var hotHardMan = BLL.Sys_UserService.GetUsersByUserId(trust.TrstManId);
if (hotHardMan != null)
{
this.drpCH_TrustMan.Text = hotHardMan.UserName;
}
}
this.btnEdit.Hidden = false;
if (trust.IsPrint == true)
{
this.cbIsPrint.Checked = true;
this.btnEdit.Hidden = true;
}
else
{
this.cbIsPrint.Checked = false;
}
this.btnPrint.Hidden = false;
this.btnPrintNew.Hidden = false;
this.cbIsPrint.Hidden = false;
this.btnDelete.Hidden = false;
}
}
#endregion
/// <summary>
/// 情况
/// </summary>
private void SetTextTemp()
{
this.txtHotProessTrustCode.Text = string.Empty;
this.drpCH_TrustUnit.Text = string.Empty;
this.txtProjectName.Text = string.Empty;
this.txtConstructionNo.Text = string.Empty;
this.drpCH_TrustMan.Text = string.Empty;
this.cbIsPrint.Checked = false;
}
#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 btnNew_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HotProessTrustMenuId, Const.BtnAdd))
{
if (this.tvControlItem.SelectedNode != null && this.tvControlItem.SelectedNode.CommandName == "项目名称")
{
this.SetTextTemp();
string window = String.Format("HotProessTrustEdit.aspx?HotProessTrustId={0}&ProjectId={1}", string.Empty, this.tvControlItem.SelectedNodeID, "新增 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdTrustID.ClientID)
+ Window1.GetShowReference(window));
}
else
{
ShowNotify("请先选择项目!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#region
/// <summary>
/// 编辑热处理委托
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEdit_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HotProessTrustMenuId, Const.BtnSave))
{
var trustManage = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustByID(this.HotProessTrustId);
if (trustManage != null)
{
//if (trustManage.CH_AuditDate.HasValue)
//{
// Alert.ShowInTop("此热处理委托单已审核!", MessageBoxIcon.Warning);
// return;
//}
string window = String.Format("HotProessTrustEdit.aspx?HotProessTrustId={0}", this.HotProessTrustId, "编辑 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdTrustID.ClientID)
+ Window1.GetShowReference(window));
}
else
{
ShowNotify("请选择要修改的热处理委托记录!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 删除热处理委托
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HotProessTrustMenuId, Const.BtnDelete))
{
var trustManage = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustByID(this.HotProessTrustId);
if (trustManage != null)
{
if (trustManage.IsPrint == true)
{
ShowNotify("热处理委托已打印,无法删除!", MessageBoxIcon.Warning);
return;
}
var hotProessItems = from x in Funs.DB.HJGL_HotProessItem where x.HotProessTrustId == this.HotProessTrustId select x;
foreach (var item in hotProessItems)
{
if (!string.IsNullOrEmpty(item.RecordChartNo))
{
ShowNotify("热处理录入已有数据,无法删除!", MessageBoxIcon.Warning);
return;
}
}
BLL.HJGL_CH_HotProessResultService.DeleteHotProessResultsyHotProessTrustId(this.HotProessTrustId);
BLL.HJGL_HotProessManageEditService.DeleteHotProessItemByHotProessTrustId(this.HotProessTrustId);
BLL.HJGL_CH_HotProessTrustService.DeleteCH_HotProessTrustItemByCH_HotProessTrustID(this.HotProessTrustId);
BLL.HJGL_CH_HotProessTrustService.DeleteCH_HotProessTrustByCH_HotProessTrustID(this.HotProessTrustId);
BLL.Sys_LogService.AddLog(BLL.Const.System_3, trustManage.ProjectId, this.CurrUser.UserId, "删除热处理委托");
Alert.ShowInTop("删除成功!", MessageBoxIcon.Success);
this.InitTreeMenu();
//this.BindGrid();
SetTextTemp();
this.Grid1.DataSource = null;
this.Grid1.DataBind();
}
else
{
ShowNotify("请选择要删除的热处理委托记录!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#endregion
#region
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
this.InitTreeMenu();
this.HotProessTrustId = this.hdTrustID.Text;
this.tvControlItem.SelectedNodeID = this.HotProessTrustId;
this.BindGrid();
this.hdTrustID.Text = string.Empty;
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
//this.BindGrid();
}
#endregion
#region
/// <summary>
/// 热处理委托表打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.HotProessTrustId))
{
string reportId = BLL.Const.HJGL_HotProessTrustReportId; //热处理委托
Model.HJGL_CH_HotProessTrust trust = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustByID(this.HotProessTrustId);
if (trust != null)
{
trust.IsPrint = true;
BLL.HJGL_CH_HotProessTrustService.UpdateCH_HotProessTrust(trust);
this.cbIsPrint.Checked = true;
}
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", reportId, this.HotProessTrustId, string.Empty, "打印 - ")));
}
else
{
ShowNotify("请选择热处理委托记录!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 热处理委托表打印(新)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrintNew_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.HotProessTrustId))
{
string reportId = BLL.Const.HJGL_HotProessTrustNewReportId; //热处理委托
Model.HJGL_CH_HotProessTrust trust = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustByID(this.HotProessTrustId);
if (trust != null)
{
trust.IsPrint = true;
BLL.HJGL_CH_HotProessTrustService.UpdateCH_HotProessTrust(trust);
this.cbIsPrint.Checked = true;
}
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", reportId, this.HotProessTrustId, string.Empty, "打印 - ")));
}
else
{
ShowNotify("请选择热处理委托记录!", MessageBoxIcon.Warning);
return;
}
}
#endregion
/// <summary>
/// 得到热处理类型
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
protected string ConvertProessTypes(object ProessTypes)
{
string proessTypes = string.Empty;
if (ProessTypes != null)
{
proessTypes = BLL.HJGL_PW_JointInfoService.ConvertProessTypes(ProessTypes.ToString());
}
return proessTypes;
}
protected void cbIsPrint_CheckedChanged(object sender, CheckedEventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HotProessTrustMenuId, "是否打印勾选"))
{
if (this.tvControlItem.SelectedNode.CommandName == "委托单号")
{
Model.HJGL_CH_HotProessTrust trust = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustByID(this.HotProessTrustId);
if (trust != null)
{
if (this.cbIsPrint.Checked)
{
trust.IsPrint = true;
}
else
{
trust.IsPrint = false;
}
BLL.HJGL_CH_HotProessTrustService.UpdateCH_HotProessTrust(trust);
}
}
}
}
protected void rblPrint_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
SetTextTemp();
}
}
}