HJGL_DS/HJGL_DS/FineUIPro.Web/HJGL/HotProessManage/HotProessTrust.aspx.cs

822 lines
38 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.IO;
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)
{
#region 线
Model.SGGLDB db = Funs.DB;
var allJoints = from x in db.HJGL_PW_JointInfo
where (from y in db.HJGL_CH_HotProessTrustItem where y.JOT_ID == x.JOT_ID select y).Count() == 0 && x.IS_Proess == "1"
select x;
var allIsoIds = allJoints.Select(x => x.ISO_ID).Distinct();
var allIsos = from x in db.HJGL_PW_IsoInfo
join y in db.Base_Project on x.ProjectId equals y.ProjectId
where allIsoIds.Contains(x.ISO_ID)
select new { x.ISO_ID, x.ProjectId, x.ISO_IsoNo, x.BSU_ID, y.ProjectName, y.ProjectCode };
var allProjectUser = from x in db.Project_User
join y in db.Sys_User on x.UserId equals y.UserId
select new { x.UserId, x.ProjectId, y.UnitId };
string HotProessTrustId = string.Empty;
List<Model.HJGL_CH_HotProessTrust> trusts = new List<Model.HJGL_CH_HotProessTrust>();
List<Model.HJGL_CH_HotProessTrustItem> trustItems = new List<Model.HJGL_CH_HotProessTrustItem>();
List<Model.HJGL_CH_HotProessResult> hotProessResults = new List<Model.HJGL_CH_HotProessResult>();
foreach (var item in allIsos)
{
Model.HJGL_CH_HotProessTrust newHotProessTrust = new Model.HJGL_CH_HotProessTrust();
newHotProessTrust.ProjectId = item.ProjectId;
newHotProessTrust.HotProessTrustCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCode2ByProjectIdNoR", "dbo.HJGL_CH_HotProessTrust", "HotProessTrustCode", item.ProjectId, item.ProjectCode + "-" + string.Format("{0:MMdd}", DateTime.Now) + "-");
newHotProessTrust.TrustUnitId = item.BSU_ID;
newHotProessTrust.ProjectName = item.ProjectName;
newHotProessTrust.ConstructionNo = item.ProjectCode;
var projectUser = allProjectUser.FirstOrDefault(x => x.ProjectId == item.ProjectId && x.UnitId == item.BSU_ID);
if (projectUser != null)
{
newHotProessTrust.TrstManId = projectUser.UserId;
}
HotProessTrustId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HotProessTrust));
newHotProessTrust.HotProessTrustId = HotProessTrustId;
newHotProessTrust.TrustType = "1"; //正常口
db.HJGL_CH_HotProessTrust.InsertOnSubmit(newHotProessTrust);
db.SubmitChanges();
//trusts.Add(newHotProessTrust);
var joints = allJoints.Where(x => x.ISO_ID == item.ISO_ID);
foreach (var joint in joints)
{
if (!string.IsNullOrEmpty(joint.ProessTypes))
{
string[] proessTypes = joint.ProessTypes.Split('|');
for (int i = 0; i < proessTypes.Length; i++)
{
Model.HJGL_CH_HotProessTrustItem newItem = new Model.HJGL_CH_HotProessTrustItem();
newItem.HotProessTrustId = HotProessTrustId;
newItem.JOT_ID = joint.JOT_ID;
newItem.ProessTypes = proessTypes[i];
//item.TrustDate = Funs.GetNewDateTime(values.Value<string>("TrustDate").ToString());
newItem.TrustDate = DateTime.Now;
newItem.Remark = string.Empty;
newItem.HotProessTrustItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HotProessTrustItem));
trustItems.Add(newItem);
//if (newItem.ProessTypes.Contains("4") || newItem.ProessTypes.Contains("5")) //需要进入热处理报告的记录
//{
// Model.HJGL_HotProessItem hotProessItem = new Model.HJGL_HotProessItem();
// hotProessItem.HotProessItemId = SQLHelper.GetNewID(typeof(Model.HJGL_HotProessItem));
// hotProessItem.JOT_ID = newItem.JOT_ID;
// hotProessItem.HotProessTrustId = HotProessTrustId;
// hotProessItem.ProessTypes = newItem.ProessTypes;
// hotProessItem.SortIndex = BLL.HJGL_HotProessManageEditService.GetSortIndex(HotProessTrustId, newItem.JOT_ID, newItem.ProessTypes);
// Model.HJGL_CH_HotProessTrustItem hotProessTrustItem = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustItemByHotProessTrustIdAndJotId(HotProessTrustId, newItem.JOT_ID);
// if (hotProessTrustItem != null)
// {
// BLL.HJGL_HotProessManageEditService.AddHotProessItem(hotProessItem, "", null);
// }
// //回写焊口热处理委托时间
// BLL.HJGL_PW_JointInfoService.WriteBackHotProessTrustDate(newItem.JOT_ID, newItem.TrustDate);
//}
//进入热处理结果反馈
Model.HJGL_CH_HotProessResult hotProessResult = new Model.HJGL_CH_HotProessResult();
hotProessResult.JOT_ID = newItem.JOT_ID;
hotProessResult.HotProessTrustId = HotProessTrustId;
hotProessResult.ProessTypes = newItem.ProessTypes;
hotProessResult.HotProessResultId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HotProessResult));
hotProessResults.Add(hotProessResult);
}
}
}
}
db.HJGL_CH_HotProessTrust.InsertAllOnSubmit(trusts);
db.SubmitChanges();
db.HJGL_CH_HotProessTrustItem.InsertAllOnSubmit(trustItems);
db.SubmitChanges();
db.HJGL_CH_HotProessResult.InsertAllOnSubmit(hotProessResults);
db.SubmitChanges();
//已焊接口
var allWeldJoints = from x in db.HJGL_PW_JointInfo
where x.DReportID != null && x.IS_Proess == "1" && (x.ProessTypes.Contains("4") || x.ProessTypes.Contains("5"))
&& (from y in db.HJGL_HotProessItem where y.JOT_ID == x.JOT_ID select y).Count() == 0
select x;
foreach (var item in allWeldJoints)
{
BLL.HJGL_HotProessManageEditService.AddHotProessItemByJoint(item);
}
#endregion
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)
{
Model.SGGLDB db = Funs.DB;
foreach (var item in trustList)
{
TreeNode newNode = new TreeNode();
var isoNo = (from x in db.HJGL_PW_IsoInfo
join y in db.HJGL_PW_JointInfo on x.ISO_ID equals y.ISO_ID
join z in db.HJGL_CH_HotProessTrustItem on y.JOT_ID equals z.JOT_ID
where z.HotProessTrustId == item.HotProessTrustId
select x.ISO_IsoNo).FirstOrDefault();
if (item.IsPrint == true)
{
newNode.Text = isoNo;
}
else
{
newNode.Text = "<font color='#FF7575'>" + isoNo + "</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;
}
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
BLL.Common.FastReportService.ResetData();
//传参
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
//keyValuePairs.Add("ProjectName", projectName);
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@HotProessTrustId", this.HotProessTrustId));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_spCH_HotProessTrust", parameter);
DataTable dt = new DataTable();
dt.TableName = "MainData";
dt.Columns.Add("ProjectName");
dt.Columns.Add("ProjectCode");
dt.Columns.Add("UnitName");
dt.Columns.Add("HotProessTrustCode");
dt.Columns.Add("ISO_DesignPress");
//DataView dv = tb.DefaultView;//获取表视图
//dv.Sort = "ISO_IsoNo,JOT_JointNo ASC";//按照ID倒序排序
//tb = dv.ToTable();//转为表
DataRow[] rows = tb.DefaultView.ToTable().Select();
foreach (var row in rows)
{
var newRows = dt.NewRow();
newRows["ProjectName"] = row["ProjectName"].ToString();
newRows["ProjectCode"] = row["ProjectCode"].ToString();
newRows["UnitName"] = row["UnitName"].ToString();
newRows["HotProessTrustCode"] = row["HotProessTrustCode"].ToString();
newRows["ISO_DesignPress"] = row["ISO_DesignPress"].ToString();
dt.Rows.Add(newRows);
}
BLL.Common.FastReportService.AddFastreportTable(dt);
List<SqlParameter> listStr2 = new List<SqlParameter>();
listStr2.Add(new SqlParameter("@HotProessTrustId", this.HotProessTrustId));
SqlParameter[] parameter2 = listStr2.ToArray();
DataTable tb2 = BLL.SQLHelper.GetDataTableRunProc("HJGL_spCH_HotProessTrustItem", parameter2);
DataTable dt2 = new DataTable();
dt2.TableName = "Data";
dt2.Columns.Add("SortNum");
dt2.Columns.Add("ISO_IsoNo");
dt2.Columns.Add("JOT_JointNo");
dt2.Columns.Add("JOT_JointDesc");
dt2.Columns.Add("STE_Code");
dt2.Columns.Add("ProessTypes");
DataView dv = tb2.DefaultView;//获取表视图
dv.Sort = "Number ASC";//按照ID倒序排序
tb2 = dv.ToTable();//转为表
DataRow[] rows2 = tb2.DefaultView.ToTable().Select();
int i = 0;
foreach (var row in rows2)
{
var newRows = dt2.NewRow();
if (i + 1 < rows2.Count())
{
newRows["SortNum"] = i + 1;
}
newRows["ISO_IsoNo"] = row["ISO_IsoNo"].ToString();
newRows["JOT_JointNo"] = row["JOT_JointNo"].ToString();
newRows["JOT_JointDesc"] = row["JOT_JointDesc"].ToString();
newRows["STE_Code"] = row["STE_Code"].ToString();
newRows["ProessTypes"] = row["ProessTypes"].ToString();
dt2.Rows.Add(newRows);
i++;
}
BLL.Common.FastReportService.AddFastreportTable(dt2);
initTemplatePath = "File\\Fastreport\\热处理委托单.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
//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();
}
}
}