Basf_TCC7/HJGL/FineUIPro.Web/HotProcessHard/HotProessFeedback.aspx.cs

351 lines
13 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using BLL;
using System.Data;
using Newtonsoft.Json.Linq;
namespace FineUIPro.Web.HotProcessHard
{
public partial class HotProessFeedback : 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();
this.HotProessTrustId = 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.HotProess_Trust> trustLists = new List<Model.HotProess_Trust>(); ///热处理委托单
if (!string.IsNullOrEmpty(this.txtSearchNo.Text.Trim()))
{
trustLists = (from x in Funs.DB.HotProess_Trust where x.HotProessTrustNo.Contains(this.txtSearchNo.Text.Trim()) orderby x.HotProessTrustNo select x).ToList();
}
else
{
trustLists = (from x in Funs.DB.HotProess_Trust orderby x.HotProessTrustNo select x).ToList();
}
this.BindNodes(rootNode, trustLists);
}
}
#endregion
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.HotProess_Trust> trustList)
{
foreach (var item in trustList)
{
TreeNode newNode = new TreeNode();
newNode.Text = item.HotProessTrustNo;
newNode.NodeID = item.HotProessTrustId;
newNode.ToolTip = item.HotProessTrustNo;
newNode.CommandName = Resources.Lan.RequestSheetNumber;
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
#endregion
#region Tree展开事件
/// <summary>
/// Tree展开事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeExpand(object sender, TreeNodeEventArgs e)
{
if (e.Node.Nodes != null)
{
e.Node.Nodes.Clear();
}
List<Model.HotProess_Trust> trustLists = new List<Model.HotProess_Trust>(); ///热处理委托单
trustLists = (from x in Funs.DB.HotProess_Trust
where x.HotProessTrustNo.Contains(this.txtSearchNo.Text.Trim())
&& x.ProjectId == e.Node.NodeID
orderby x.HotProessTrustNo descending
select x).ToList();
this.BindNodes(e.Node, trustLists);
}
#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.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 (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
var hotProessTrust = BLL.HotProess_TrustService.GetHotProessTrustById(this.tvControlItem.SelectedNodeID);
if (hotProessTrust != null)
{
this.HotProessTrustId = hotProessTrust.HotProessTrustId;
strSql = @"SELECT * "
+ @" FROM dbo.View_HotProess_TrustItem AS Trust"
+ @" WHERE Trust.ProjectId= @ProjectId AND Trust.HotProessTrustId=@HotProessTrustId ";
listStr.Add(new SqlParameter("@ProjectId", hotProessTrust != null ? hotProessTrust.ProjectId : this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@HotProessTrustId", this.HotProessTrustId));
if (!string.IsNullOrEmpty(this.txtIsoNo.Text.Trim()))
{
strSql += @" and Trust.PipelineCode like '%'+@PipelineCode+'%' ";
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();
//是否合格、是否需硬度检测的绑定
for (int i = 0; i < this.Grid1.Rows.Count; i++)
{
string hotProessTrustItemId = this.Grid1.Rows[i].DataKeys[0].ToString();
if (hotProessTrustItemId != null)
{
var hotProessFeedback = BLL.HotProessTrustItemService.GetHotProessTrustItemById(hotProessTrustItemId);
if (hotProessFeedback.IsCompleted == true)
{
this.Grid1.Rows[i].Values[6] = BLL.Const._True;//是否完成
}
}
}
}
}
}
/// <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 = BLL.HotProess_TrustService.GetHotProessTrustById(this.HotProessTrustId);
if (trust != null)
{
this.txtHotProessTrustNo.Text = trust.HotProessTrustNo;
if (trust.ProessDate.HasValue)
{
this.txtProessDate.Text = string.Format("{0:yyyy-MM-dd}", trust.ProessDate);
}
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.txtProessMethod.Text = trust.ProessMethod;
this.txtProessEquipment.Text = trust.ProessEquipment;
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.txtHotProessTrustNo.Text = string.Empty;
this.txtProessDate.Text = string.Empty;
this.txtInstallationName.Text = string.Empty;
this.txtUnitName.Text = string.Empty;
this.txtProessMethod.Text = string.Empty;
this.txtProessEquipment.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
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#endregion
#region
/// <summary>
/// 提交反馈结果
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HotProessFeedbackMenuId, Const.BtnSave))
{
JArray ModifiedData = Grid1.GetMergedData();
foreach (JObject modifiedRow in ModifiedData)
{
int index = modifiedRow.Value<int>("index");
JObject values = modifiedRow.Value<JObject>("values");
CheckBoxField cbIsCompleted = (CheckBoxField)Grid1.FindColumn("IsCompleted");
string hotProessTrustItemId = Grid1.DataKeys[index][0].ToString();
var hotProessFeedback = BLL.HotProessTrustItemService.GetHotProessTrustItemById(hotProessTrustItemId);
if (hotProessFeedback != null)
{
bool newIsPass = cbIsCompleted.GetCheckedState(index);
if (newIsPass)
{
hotProessFeedback.IsCompleted = true;
hotProessFeedback.IsHardness = true;
}
else
{
hotProessFeedback.IsCompleted = false;
hotProessFeedback.IsHardness = false;
}
BLL.HotProessTrustItemService.UpdateHotProessFeedback(hotProessFeedback);
}
}
ShowNotify(Resources.Lan.SubmitSuccessful, MessageBoxIcon.Success);
}
else
{
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
}
}
#endregion
}
}