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

460 lines
19 KiB
C#

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 RepairHotProessTrust : 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.HotProessTrustId = string.Empty;
this.InitTreeMenu();//加载树
this.tvControlItem.SelectedNodeID = "0";
BindGrid();
}
}
#endregion
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "项目";
rootNode.NodeID = "0";
rootNode.Expanded = true;
rootNode.EnableClickEvent = true;
this.tvControlItem.Nodes.Add(rootNode);
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetProjectListByUserId(this.CurrUser.UserId, "1");
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.TrustType == "2"
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.TrustType == "2"
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.TrustType == "2"
select x).ToList();
}
foreach (var item in projects)
{
TreeNode rootUnitNode = new TreeNode();//定义根节点
rootUnitNode.Text = item.ProjectCode;
rootUnitNode.NodeID = item.ProjectId;
rootUnitNode.Expanded = true;
rootUnitNode.ToolTip = item.ProjectName;
rootUnitNode.CommandName = "项目名称";
rootUnitNode.EnableClickEvent = true;
rootNode.Nodes.Add(rootUnitNode);
var trustProjectLists = (from x in trustLists where x.ProjectId == item.ProjectId orderby x.HotProessTrustCode descending select x).ToList();
this.BindNodes(rootUnitNode, trustProjectLists);
}
}
#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();
newNode.Text = item.HotProessTrustCode;
newNode.NodeID = item.HotProessTrustId;
newNode.ToolTip = item.HotProessTrustCode;
newNode.CommandName = "委托单号";
newNode.EnableClickEvent = true;
node.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)
{
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(); ///页面输入提交信息
if (this.tvControlItem.SelectedNode.CommandName == "委托单号")
{
strSql = @"SELECT * "
+ @" FROM dbo.HJGL_View_CH_HotProessTrustItem AS Trust"
+ @" WHERE Trust.ProjectId= @ProjectId AND Trust.HotProessTrustId=@HotProessTrustId and Trust.TrustItemID is not null";
listStr.Add(new SqlParameter("@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 and Trust.TrustItemID is not null";
listStr.Add(new SqlParameter("@ProjectId", this.HotProessTrustId));
}
else if (this.tvControlItem.SelectedNodeID == "0") //选择项目根节点
{
strSql = @"SELECT * "
+ @" FROM dbo.HJGL_View_CH_HotProessTrustItem AS Trust"
+ @" WHERE Trust.HotProessTrustId is not null and Trust.TrustItemID is not null";
}
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;
}
}
if (trust.IsPrint == true)
{
this.cbIsPrint.Checked = true;
}
else
{
this.cbIsPrint.Checked = false;
}
this.btnPrint.Hidden = false;
this.cbIsPrint.Hidden = false;
this.btnEdit.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
/// <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_RepairHotProessTrustMenuId, Const.BtnAdd))
{
if (this.tvControlItem.SelectedNode != null && this.tvControlItem.SelectedNode.CommandName == "项目名称")
{
this.SetTextTemp();
string window = String.Format("RepairHotProessTrustEdit.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_RepairHotProessTrustMenuId, 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("RepairHotProessTrustEdit.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_RepairHotProessTrustMenuId, Const.BtnDelete))
{
var trustManage = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustByID(this.HotProessTrustId);
if (trustManage != null)
{
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, this.CurrUser.LoginProjectId, 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
/// <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 (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();
}
}
}