Basf_TCC7/HJGL/FineUIPro.Web/WeldingProcess/PMI/PMIDelegation.aspx.cs

389 lines
14 KiB
C#
Raw Normal View History

2024-05-11 15:22:08 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
2024-05-12 15:28:06 +08:00
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
2024-05-11 15:22:08 +08:00
namespace FineUIPro.Web.WeldingProcess.PMI
{
public partial class PMIDelegation : PageBase
{
#region
/// <summary>
/// PMI委托主键
/// </summary>
public string PMIDelegationId
{
get
{
return (string)ViewState["PMIDelegationId"];
}
set
{
ViewState["PMIDelegationId"] = 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();
this.PMIDelegationId = string.Empty;
this.InitTreeMenu();//加载树
}
}
#endregion
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
string projectName = string.Empty;
var pro = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (pro != null)
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "[" + pro.ProjectCode + "]" + pro.ProjectName;
rootNode.NodeID = "0";
rootNode.Expanded = true;
rootNode.EnableClickEvent = true;
this.tvControlItem.Nodes.Add(rootNode);
List<Model.PMI_Delegation> trustLists = new List<Model.PMI_Delegation>(); ///PMI委托单
if (!string.IsNullOrEmpty(this.txtSearchNo.Text.Trim()))
{
trustLists = (from x in Funs.DB.PMI_Delegation where x.ProjectId == CurrUser.LoginProjectId && x.DelegationNo.Contains(this.txtSearchNo.Text.Trim()) orderby x.DelegationNo select x).ToList();
}
else
{
trustLists = (from x in Funs.DB.PMI_Delegation where x.ProjectId == CurrUser.LoginProjectId orderby x.DelegationNo select x).ToList();
}
this.BindNodes(rootNode, trustLists);
}
}
#endregion
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.PMI_Delegation> trustList)
{
foreach (var item in trustList)
{
TreeNode newNode = new TreeNode();
newNode.Text = item.DelegationNo;
newNode.NodeID = item.Id;
newNode.ToolTip = item.DelegationNo;
newNode.CommandName = Resources.Lan.RequestSheetNumber;
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)
{
if (this.tvControlItem.SelectedNodeID != "0")
{
this.PMIDelegationId = tvControlItem.SelectedNodeID;
this.BindGrid();
}
}
#endregion
#region DropDownList下拉选择事件
/// <summary>
/// 项目下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
string strSql = string.Empty;
List<SqlParameter> listStr = new List<SqlParameter>();
this.SetTextTemp();
this.PageInfoLoad(); ///页面输入提交信息
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
var result = Funs.DB.PMI_Delegation.FirstOrDefault(t=>t.Id==this.tvControlItem.SelectedNodeID);
if (result != null)
{
this.PMIDelegationId = result.Id;
2024-05-12 12:05:01 +08:00
strSql = @"SELECT *FROM [View_PMI_DelegationDetails] WHERE ProjectId= @ProjectId AND PMIID=@PMIDelegationId ";
2024-05-11 15:22:08 +08:00
listStr.Add(new SqlParameter("@ProjectId", result != null ? result.ProjectId : this.CurrUser.LoginProjectId));
2024-05-12 12:05:01 +08:00
listStr.Add(new SqlParameter("@PMIDelegationId", this.PMIDelegationId));
2024-05-11 15:22:08 +08:00
if (!string.IsNullOrEmpty(this.txtIsoNo.Text.Trim()))
{
2024-05-12 14:23:37 +08:00
strSql += @" and PipelineCode like '%'+@PipelineCode+'%' ";
2024-05-11 15:22:08 +08:00
listStr.Add(new SqlParameter("@PipelineCode", 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()
{
var trust =Funs.DB.PMI_Delegation.FirstOrDefault(t=>t.Id==this.PMIDelegationId);
if (trust != null)
{
this.txtDelegationNo.Text = trust.DelegationNo;
if (trust.DelegationDate.HasValue)
{
this.txtDelegationDate.Text = string.Format("{0:yyyy-MM-dd}", trust.DelegationDate);
}
if (!string.IsNullOrEmpty(trust.InstallationId))
{
this.txtInstallationName.Text = BLL.Project_InstallationService.GetProject_InstallationNameByInstallationId(trust.InstallationId);
}
if (!string.IsNullOrEmpty(trust.UnitId))
{
this.txtUnitName.Text = BLL.Base_UnitService.GetUnitNameByUnitId(trust.UnitId);
}
this.txtDetectionMethod.Text = "PMI光谱分析";
this.txtDetectionStandard.Text = trust.DetectionStandard;
if (!string.IsNullOrEmpty(trust.Tabler))
{
this.txtTabler.Text = BLL.Sys_UserService.GetUserNameByUserId(trust.Tabler);
}
this.txtRemark.Text = trust.Remark;
}
}
#endregion
#region
/// <summary>
/// 清空文本
/// </summary>
private void SetTextTemp()
{
this.txtDelegationNo.Text = string.Empty;
this.txtDelegationDate.Text = string.Empty;
this.txtInstallationName.Text = string.Empty;
this.txtUnitName.Text = string.Empty;
this.txtDetectionMethod.Text = string.Empty;
this.txtDetectionStandard.Text = string.Empty;
this.txtTabler.Text = string.Empty;
this.txtRemark.Text = string.Empty;
}
#endregion
#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 PMI委托
/// <summary>
/// 增加PMI委托
/// </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.PMIDelegationId, Const.BtnAdd))
{
this.SetTextTemp();
2024-05-12 15:49:21 +08:00
string window = String.Format("PMIDelegationEdit.aspx?PMIDelegationId={0}", string.Empty, "新增 - ") ;
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(this.hdPMIDelegationId.ClientID)
2024-05-12 15:28:06 +08:00
+ Window2.GetShowReference(window));
2024-05-11 15:22:08 +08:00
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
}
}
#region PMI委托
/// <summary>
/// 编辑PMI委托
/// </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.HotProessTrustMenuId, Const.BtnSave))
{
var trustManage = Funs.DB.PMI_Delegation.FirstOrDefault (t=>t.Id==this.PMIDelegationId);
if (trustManage != null)
{
2024-05-12 15:49:21 +08:00
string openUrl = String.Format("PMIDelegationEdit.aspx?PMIDelegationId={0}", this.PMIDelegationId, "编辑 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(this.hdPMIDelegationId.ClientID)
+ Window2.GetShowReference(openUrl));
2024-05-11 15:22:08 +08:00
}
else
{
2024-05-12 22:53:47 +08:00
ShowNotify("请选择要处理的PMI委托", MessageBoxIcon.Warning);
2024-05-11 15:22:08 +08:00
}
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
}
}
#endregion
#region PMI委托
/// <summary>
/// 删除PMI委托
/// </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.PMIDelegationId, Const.BtnDelete))
{
var trustManage =Funs.DB.PMI_Delegation.FirstOrDefault (t=>t.Id==this.PMIDelegationId);
if (trustManage != null)
{
//删除主表数据
Funs.DB.PMI_Delegation.DeleteOnSubmit(trustManage);
//删除 明细表
2024-05-12 22:53:47 +08:00
var details = Funs.DB.PMI_DelegationDetails.Where(t => t.PMIId == trustManage.Id).ToList();
Funs.DB.PMI_DelegationDetails.DeleteAllOnSubmit(details);
2024-05-11 15:22:08 +08:00
Funs.DB.SubmitChanges();
Alert.ShowInTop(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success);
this.InitTreeMenu();
SetTextTemp();
this.Grid1.DataSource = null;
this.Grid1.DataBind();
}
else
{
ShowNotify(Resources.Lan.PleaseSelectDeleteHotProessTrust, MessageBoxIcon.Warning);
}
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
}
#endregion
#endregion
#region
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2024-05-12 15:49:21 +08:00
protected void Window2_Close(object sender, WindowCloseEventArgs e)
2024-05-11 15:22:08 +08:00
{
this.InitTreeMenu();
this.BindGrid();
}
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#endregion
#endregion
2024-05-12 14:23:37 +08:00
2024-05-11 15:22:08 +08:00
}
}