388 lines
15 KiB
C#
388 lines
15 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.HJGL.RepairManage
|
|
{
|
|
public partial class NonRTQualityRating : PageBase
|
|
{
|
|
#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.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.drpState.DataTextField = "Text";
|
|
this.drpState.DataValueField = "Value";
|
|
this.drpState.DataSource = BLL.DropListService.CheckStatesList();
|
|
this.drpState.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpState);
|
|
|
|
this.InitTreeMenu();//加载树
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载树项目
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "项目";
|
|
rootNode.ToolTip = "项目";
|
|
rootNode.NodeID = "0";
|
|
rootNode.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
|
|
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
if (this.drpProjectId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == this.drpProjectId.SelectedValue).ToList();
|
|
}
|
|
foreach (var item in projects)
|
|
{
|
|
TreeNode rootProjectNode = new TreeNode();//定义根节点
|
|
rootProjectNode.Text = item.ProjectCode;
|
|
rootProjectNode.NodeID = item.ProjectId;
|
|
rootProjectNode.EnableClickEvent = true;
|
|
rootProjectNode.Expanded = true;
|
|
rootProjectNode.ToolTip = "项目名称";
|
|
rootNode.Nodes.Add(rootProjectNode);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string projectIds = BLL.Base_ProjectService.GetStrOnProjectIds(this.CurrUser.UserId, "1");
|
|
string strSql = @"SELECT distinct Repair.BatchId+Repair.ISO_ID+Repair.NDT_ID as NEWID,Repair.BatchId,Repair.ISO_ID,Repair.NDT_ID,
|
|
ndtType.NDT_Code AS NDT,Batch.BatchCode,Unit.UnitName,
|
|
IsoInfo.ISO_IsoNo,Project.ProjectCode,Project.ProjectName
|
|
FROM dbo.HJGL_CH_RepairItem repairItem
|
|
LEFT JOIN dbo.HJGL_CH_Repair AS Repair ON Repair.CH_RepairID = repairItem.CH_RepairID
|
|
LEFT JOIN dbo.HJGL_BO_Batch AS Batch ON Repair.BatchId = Batch.BatchId
|
|
LEFT JOIN dbo.HJGL_BO_BatchDetail BatchDetail ON repairItem.JOT_ID = BatchDetail.JOT_ID
|
|
LEFT JOIN dbo.HJGL_PW_IsoInfo AS IsoInfo ON IsoInfo.ISO_ID = Repair.ISO_ID
|
|
LEFT JOIN dbo.HJGL_BS_NDTType ndtType on ndtType.NDT_ID=Repair.NDT_ID
|
|
LEFT JOIN dbo.Base_Unit AS Unit ON Unit.UnitId = IsoInfo.BSU_ID
|
|
LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId = Repair.ProjectId
|
|
WHERE ndtType.NDT_Code NOT LIKE '%RT%' ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
strSql += " AND Repair.ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.tvControlItem.SelectedNodeID));
|
|
}
|
|
else
|
|
{
|
|
if (this.GetCookiesProjectId != string.Empty)
|
|
{
|
|
strSql += " AND Repair.ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.GetCookiesProjectId));
|
|
}
|
|
else
|
|
{
|
|
strSql += " AND Repair.ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtBatchCode.Text.Trim()))
|
|
{
|
|
strSql += " AND Batch.BatchCode LIKE @BatchCode";
|
|
listStr.Add(new SqlParameter("@BatchCode", "%" + this.txtBatchCode.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtIsoNo.Text.Trim()))
|
|
{
|
|
strSql += " AND IsoInfo.ISO_IsoNo LIKE @IsoNo";
|
|
listStr.Add(new SqlParameter("@IsoNo", "%" + this.txtIsoNo.Text.Trim() + "%"));
|
|
}
|
|
if (this.ckbShowAll.Checked) //显示全部
|
|
{
|
|
|
|
}
|
|
else //显示需要拍片的记录
|
|
{
|
|
strSql += " AND (select count(*) from HJGL_CH_RepairItem ti left join HJGL_CH_Repair t on ti.CH_RepairID=t.CH_RepairID where t.BatchId=Repair.BatchId and t.ISO_ID=Repair.ISO_ID and (select count(*) from HJGL_BO_QualityRatingRepair q where q.CH_RepairItemId=ti.CH_RepairItemId)=0 )>0 ";
|
|
}
|
|
//if (this.drpState.SelectedValue != "null")
|
|
//{
|
|
// strSql += " AND repairItem.States = @States";
|
|
// listStr.Add(new SqlParameter("@States", this.drpState.SelectedValue));
|
|
//}
|
|
//if (this.ckbIsExp.Checked)
|
|
//{
|
|
// strSql += " AND BatchDetail.PointType = @PointType";
|
|
// listStr.Add(new SqlParameter("@PointType", "2"));
|
|
//}
|
|
//if (this.ckbIsFilm.Checked)
|
|
//{
|
|
// strSql += " AND (select count(*) from dbo.HJGL_BO_QualityRatingRepair qua where qua.CH_RepairItemId =repairItem.CH_RepairItemId)>0";
|
|
//}
|
|
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();
|
|
}
|
|
|
|
#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 drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
}
|
|
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void ckbShowAll_OnCheckedChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void drpNdtType_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void drpState_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void ckbIsExp_OnCheckedChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void ckbIsFilm_OnCheckedChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Grid绑定事件
|
|
/// <summary>
|
|
/// Grid1绑定事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
|
{
|
|
//string repairItemId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
//System.Web.UI.WebControls.RadioButtonList cblCheckState = (System.Web.UI.WebControls.RadioButtonList)(this.Grid1.Rows[e.RowIndex].FindControl("cblCheckState"));//检测状态
|
|
|
|
//cblCheckState.Items.AddRange(BLL.DropListService.CheckStatesList());
|
|
|
|
//var repairItem = BLL.HJGL_RepairItemService.GetRepairItemByID(repairItemId);
|
|
//if (repairItem != null)
|
|
//{
|
|
// if (!string.IsNullOrEmpty(repairItem.States))
|
|
// {
|
|
// for (int i = 0; i < cblCheckState.Items.Count; i++)
|
|
// {
|
|
// if (cblCheckState.Items[i].Value == repairItem.States)
|
|
// {
|
|
// cblCheckState.Items[i].Selected = true;
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 提交
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
//Dictionary<int, Dictionary<string, object>> modifiedDict = Grid1.GetModifiedDict();
|
|
//foreach (int rowIndex in modifiedDict.Keys)
|
|
//{
|
|
// int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
|
|
// DataRow row = FindRowByID(rowID);
|
|
|
|
// UpdateDataRow(modifiedDict[rowIndex], row);
|
|
//}
|
|
|
|
//string ss=Grid1.GetModifiedData().ToString(Newtonsoft.Json.Formatting.Indented);
|
|
|
|
JArray MergedData = Grid1.GetMergedData();
|
|
foreach (JObject modifiedRow in MergedData)
|
|
{
|
|
int index = modifiedRow.Value<int>("index");
|
|
JObject values = modifiedRow.Value<JObject>("values");
|
|
string feedbackMan = values.Value<string>("FeedbackMan");
|
|
string feedbackDate = values.Value<string>("FeedbackDate");
|
|
|
|
string repairItemId = Grid1.DataKeys[index][0].ToString();
|
|
System.Web.UI.WebControls.RadioButtonList cblCheckState = (System.Web.UI.WebControls.RadioButtonList)(this.Grid1.Rows[index].FindControl("cblCheckState"));//检测状态
|
|
string state = cblCheckState.SelectedValue.Trim();
|
|
var repairItem = BLL.HJGL_RepairItemService.GetRepairItemByID(repairItemId);
|
|
if (state == "2") //检测合格,允许手动选择改变状态,因为有时现场需要提前知道检测结果
|
|
{
|
|
repairItem.States = state;
|
|
}
|
|
repairItem.FeedbackMan = feedbackMan;
|
|
if (!string.IsNullOrEmpty(feedbackDate))
|
|
{
|
|
repairItem.FeedbackDate = Convert.ToDateTime(feedbackDate);
|
|
}
|
|
else
|
|
{
|
|
repairItem.FeedbackDate = null;
|
|
}
|
|
BLL.HJGL_RepairItemService.UpdateCH_TrustItem(repairItem);
|
|
}
|
|
|
|
BindGrid();
|
|
}
|
|
|
|
#region 查看质量等级评定
|
|
/// <summary>
|
|
/// 查看质量等级评定
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSee_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条信息", MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityRatingView.aspx?repairItemId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑质量等级评定
|
|
/// <summary>
|
|
/// 查看质量等级评定
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条信息", MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
|
|
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_CheckMenuId, BLL.Const.BtnSave))
|
|
{
|
|
//string window = String.Format("QualityRating.aspx?trustItemID={0}", Grid1.SelectedRowID, "编辑 - ");
|
|
//PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdItemsString.ClientID) + Window1.GetShowReference(window));
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityRating.aspx?BatchId={0}&ISO_ID={1}&NDT={2}", Grid1.SelectedRow.DataKeys[0].ToString(), Grid1.SelectedRow.DataKeys[1].ToString(), Grid1.SelectedRow.DataKeys[2].ToString(), "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Grid 双击事件
|
|
/// <summary>
|
|
/// Grid双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
btnEdit_Click(null, null);
|
|
}
|
|
#endregion
|
|
}
|
|
} |