xinjiang/SGGL/FineUIPro.Web/HJGL/HotProcessHard/HotProessReportItem.aspx.cs

419 lines
18 KiB
C#

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using BLL;
using System.Linq;
using Newtonsoft.Json.Linq;
using Model;
namespace FineUIPro.Web.HJGL.HotProcessHard
{
public partial class HotProessReportItem : PageBase
{
#region
public string hotProessTrustItemId
{
get
{
return (string)ViewState["hotProessTrustItemId"];
}
set
{
ViewState["hotProessTrustItemId"] = value;
}
}
public string WeldJointId
{
get
{
return (string)ViewState["WeldJointId"];
}
set
{
ViewState["WeldJointId"] = value;
}
}
/// <summary>
/// 报告集合
/// </summary>
private List<Model.HJGL_HotProess_Report> HotProessReportList = new List<Model.HJGL_HotProess_Report>();
#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 = Grid1.PageSize.ToString();
Funs.FineUIPleaseSelect(this.drpIsCompleted);
this.hotProessTrustItemId = Request.Params["HotProessTrustItemId"];
var hotProessFeedback = BLL.HotProessTrustItemService.GetHotProessTrustItemById(hotProessTrustItemId);
if (hotProessFeedback != null) {
if (!string.IsNullOrEmpty(hotProessFeedback.IsCompleted.ToString())) {
drpIsCompleted.SelectedValue = hotProessFeedback.IsCompleted.Value.ToString();
}
if (!string.IsNullOrEmpty(hotProessFeedback.WeldJointId)) {
var getWeldJoint = PW_JointInfoService.GetJointInfoByJotID(hotProessFeedback.WeldJointId);
if (getWeldJoint != null)
{
this.WeldJointId = getWeldJoint.JOT_ID;
this.lbWeldJointCode.Text = getWeldJoint.JOT_JointNo;
var getPipeline = PW_IsoInfoService.GetIsoInfoByIsoInfoId(getWeldJoint.ISO_ID);
if (getPipeline != null)
{
this.lbPipeLineCode.Text = getPipeline.ISO_IsoNo;
}
}
}
}
//若生成硬度委托,则焊口是否完成状态不可更改
Model.HJGL_Hard_TrustItem hardTrustItem = BLL.Hard_TrustItemService.GetHardTrustItemByHotProessTrustItemId(this.hotProessTrustItemId);
if (hardTrustItem != null)
{
this.drpIsCompleted.Enabled = false;
}
//// 绑定表格
var getReports = HotProessReportService.GetHotProessReportListById(hotProessTrustItemId);
foreach (var item in getReports)
{
Model.HJGL_HotProess_Report NewReport = new Model.HJGL_HotProess_Report();
NewReport.HotProessReportId = item.HotProessReportId;
NewReport.HotProessTrustItemId = item.HotProessTrustItemId;
NewReport.WeldJointId = item.WeldJointId;
NewReport.PointCount = item.PointCount;
NewReport.RequiredT = item.RequiredT;
NewReport.ActualT = item.ActualT;
NewReport.RequestTime = item.RequestTime;
NewReport.ActualTime = item.ActualTime;
NewReport.ProessDate = item.ProessDate;
NewReport.RecordChartNo = item.RecordChartNo;
HotProessReportList.Add(NewReport);
}
if (HotProessReportList.Count == 0)//没有绑定过,初始化
{
var trustItem = Funs.DB.HJGL_HotProess_TrustItem.FirstOrDefault(x => x.HotProessTrustItemId == hotProessTrustItemId);
if (trustItem != null)
{
var jointInfo = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == trustItem.WeldJointId);
if (jointInfo != null && !string.IsNullOrEmpty(jointInfo.MaterialId))
{
var material = Funs.DB.Base_Material.FirstOrDefault(x => x.MaterialId == jointInfo.MaterialId);
if (material != null)
{
var hotProcessTech = Funs.DB.Base_HotProcessTech.Where(x => x.JOT_DiaMin <= jointInfo.JOT_Dia && jointInfo.JOT_Dia < x.JOT_DiaMax && x.Material.Contains(material.MaterialCode)).OrderBy(x => x.PointCount).ToList();
foreach (var item in hotProcessTech)
{
Model.HJGL_HotProess_Report NewReport = new Model.HJGL_HotProess_Report();
NewReport.HotProessReportId = SQLHelper.GetNewID(typeof(Model.HJGL_HotProess_Report));
NewReport.HotProessTrustItemId = hotProessTrustItemId;
NewReport.WeldJointId = WeldJointId;
NewReport.PointCount = int.Parse(item.PointCount);
NewReport.RequiredT = item.RequiredT;
NewReport.ActualT = item.ActualT;
NewReport.RequestTime = item.RequiredTime;
NewReport.ActualTime = item.ActualTime;
HotProessReportList.Add(NewReport);
}
}
}
}
}
Grid1.DataSource = HotProessReportList;
Grid1.DataBind();
}
}
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
var getReports = HotProessReportService.GetHotProessReportListById(hotProessTrustItemId);
foreach (var item in getReports)
{
Model.HJGL_HotProess_Report NewReport = new Model.HJGL_HotProess_Report();
NewReport.HotProessReportId = item.HotProessReportId;
NewReport.HotProessTrustItemId = item.HotProessTrustItemId;
NewReport.WeldJointId = item.WeldJointId;
NewReport.PointCount = item.PointCount;
NewReport.RequiredT = item.RequiredT;
NewReport.ActualT = item.ActualT;
NewReport.RequestTime = item.RequestTime;
NewReport.ActualTime = item.ActualTime;
NewReport.ProessDate = item.ProessDate;
NewReport.RecordChartNo = item.RecordChartNo;
HotProessReportList.Add(NewReport);
}
Grid1.DataSource = HotProessReportList;
Grid1.DataBind();
}
/// <summary>
/// 改变索引事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <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();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, EventArgs e)
{
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_HotProessReportMenuId, Const.BtnAdd))
{
HotProessReportList = GetDetails();
Model.HJGL_HotProess_Report NewReport = new Model.HJGL_HotProess_Report();
NewReport.HotProessReportId = SQLHelper.GetNewID(typeof(Model.HJGL_HotProess_Report));
NewReport.HotProessTrustItemId = hotProessTrustItemId;
NewReport.WeldJointId = WeldJointId;
//Model.HJGL_WeldJoint weldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(WeldJointId);
//if (weldJoint != null)
//{
// Model.WPQ_WPQList wpq = BLL.WPQListServiceService.GetWPQById(weldJoint.WPQId);
// if (wpq != null)
// {
// NewReport.RequiredT = wpq.RequiredT;
// NewReport.RequestTime = wpq.RequestTime;
// }
//}
HotProessReportList.Add(NewReport);
Grid1.DataSource = HotProessReportList;
Grid1.DataBind();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
private List<Model.HJGL_HotProess_Report> GetDetails()
{
HotProessReportList.Clear();
foreach (JObject mergedRow in Grid1.GetMergedData())
{
JObject values = mergedRow.Value<JObject>("values");
int i = mergedRow.Value<int>("index");
string PointCount = values.Value<string>("PointCount");
string RequiredT = values.Value<string>("RequiredT");
string ActualT = values.Value<string>("ActualT");
string RequestTime = values.Value<string>("RequestTime");
string ActualTime = values.Value<string>("ActualTime");
string ProessDate = values.Value<string>("ProessDate");
string RecordChartNo = values.Value<string>("RecordChartNo");
Model.HJGL_HotProess_Report NewReport = new Model.HJGL_HotProess_Report();
NewReport.HotProessReportId = Grid1.Rows[i].DataKeys[0].ToString();
NewReport.HotProessTrustItemId = hotProessTrustItemId;
NewReport.WeldJointId = Grid1.Rows[i].DataKeys[1].ToString();
if (!string.IsNullOrEmpty(PointCount))
{
NewReport.PointCount = Convert.ToInt32(PointCount);
}
NewReport.RequiredT = RequiredT;
NewReport.ActualT = ActualT;
NewReport.RequestTime = RequestTime;
NewReport.ActualTime = ActualTime;
NewReport.ProessDate = Funs.GetNewDateTime(ProessDate);
NewReport.RecordChartNo = RecordChartNo;
HotProessReportList.Add(NewReport);
}
return HotProessReportList;
}
#endregion
#region
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.drpIsCompleted.SelectedValue == BLL.Const._Null)
{
ShowNotify("请选择是否完成!", MessageBoxIcon.Warning);
return;
}
HotProessReportList = GetDetails();
if (this.drpIsCompleted.SelectedValue == "True")
{
if (HotProessReportList.Count == 0)
{
ShowNotify("请添加热处理报告数据后,再点击保存完成!", MessageBoxIcon.Warning);
return;
}
}
string hotProessTrustItemId = Request.Params["HotProessTrustItemId"];
var hotProessFeedback = BLL.HotProessTrustItemService.GetHotProessTrustItemById(hotProessTrustItemId);
if (this.drpIsCompleted.SelectedValue != BLL.Const._Null)
{
hotProessFeedback.IsCompleted = Convert.ToBoolean(drpIsCompleted.SelectedValue);
hotProessFeedback.IsHardness = Convert.ToBoolean(drpIsCompleted.SelectedValue);
}
else
{
hotProessFeedback.IsCompleted = null;
hotProessFeedback.IsHardness = null;
}
BLL.HotProessTrustItemService.UpdateHotProessFeedback(hotProessFeedback);
///保存热处理报告
HotProessReportService.DeleteAllHotProessReportById(hotProessTrustItemId);
foreach (var item in HotProessReportList)
{
Model.HJGL_HotProess_Report NewReport = new Model.HJGL_HotProess_Report();
NewReport.HotProessReportId = item.HotProessReportId;
NewReport.HotProessTrustItemId = item.HotProessTrustItemId;
NewReport.WeldJointId = item.WeldJointId;
NewReport.PointCount = item.PointCount;
NewReport.RequiredT = item.RequiredT;
NewReport.ActualT = item.ActualT;
NewReport.RequestTime = item.RequestTime;
NewReport.ActualTime = item.ActualTime;
NewReport.ProessDate = item.ProessDate;
NewReport.RecordChartNo = item.RecordChartNo;
BLL.HotProessReportService.AddHotProessReport(NewReport);
}
Alert.ShowInTop("保存成功", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
#region
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_HotProessReportMenuId, Const.BtnDelete))
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
string strShowNotify = string.Empty;
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var hotProessReport = BLL.HotProessReportService.GetHotProessReportById(rowID);
if (hotProessReport != null)
{
string cont = judgementDelete(rowID);
if (string.IsNullOrEmpty(cont))
{
BLL.AttachFileService.DeleteAttachFile(Funs.RootPath, rowID, Const.HJGL_HotProessReportMenuId);//删除附件
BLL.HotProessReportService.DeleteHotProessReportById(rowID);
}
}
}
BindGrid();
if (!string.IsNullOrEmpty(strShowNotify))
{
Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
}
else
{
ShowNotify("删除成功!", MessageBoxIcon.Success);
}
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#region
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
private string judgementDelete(string id)
{
string content = string.Empty;
//if (Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.UserId == id) != null)
//{
// content += "已在【项目用户】中使用,不能删除!";
//}
return content;
}
#endregion
#endregion
#region
/// <summary>
/// Grid行点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
{
string hotProessReportId = Grid1.DataKeys[e.RowIndex][0].ToString();
HotProessReportList = GetDetails();
if (e.CommandName == "attchUrl")
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL/HotProcessHard&menuId={1}&edit=0", hotProessReportId, BLL.Const.HJGL_HotProessReportMenuId)));
}
if (e.CommandName == "del")//删除
{
var Report = HotProessReportList.FirstOrDefault(x => x.HotProessReportId == hotProessReportId);
if (Report != null)
{
HotProessReportList.Remove(Report);
}
this.Grid1.DataSource = HotProessReportList;
this.Grid1.DataBind();
}
}
#endregion
}
}