SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/JoinMarking/PDFMarking.aspx.cs

320 lines
10 KiB
C#

using BLL;
using BLL.Common;
using Newtonsoft.Json.Linq;
using NPOI.POIFS.Properties;
using Org.BouncyCastle.Asn1.Tsp;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading;
namespace FineUIPro.Web.HJGL.JoinMarking
{
public partial class PDFMarking : PageBase
{
public List<Model.HJGL_WeldJoint> WeldJointlist
{
get
{
return (List<Model.HJGL_WeldJoint>)ViewState["ISO_ID"];
}
set
{
ViewState["ISO_ID"] = value;
}
}
private string ISO_ID
{
get
{
return (string)ViewState["ISO_ID"];
}
set
{
ViewState["ISO_ID"] = value;
}
}
private string FileId
{
get
{
return (string)ViewState["FileId"];
}
set
{
ViewState["FileId"] = value;
}
}
public string URL
{
get
{
return (string)ViewState["URL"];
}
set
{
ViewState["URL"] = value;
}
}
#region
/// <summary>
/// 是否PDMS
/// </summary>
private string IsPDMS
{
get
{
return (string)ViewState["IsPDMS"];
}
set
{
ViewState["IsPDMS"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ISO_ID = Request.Params["ISO_ID"];
FileId = Request.Params["FileId"];
URL = Funs.SGGLUrl + Request.Params["pdfurl"];
this.IsPDMS = "0";
WeldJointlist = new List<Model.HJGL_WeldJoint>();
}
}
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
Grid1.RecordCount = WeldJointlist.Count;
Grid1.DataSource = WeldJointlist;
Grid1.DataBind();
}
#endregion
#region
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录", MessageBoxIcon.Warning);
return;
}
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_DataInMenuId, Const.BtnIn))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DataInEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 导入信息编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_DataInMenuId, BLL.Const.BtnIn))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录", MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DataInEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <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.PersonId, Const.HJGL_DataInMenuId, Const.BtnIn))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var WeldJoint = WeldJointlist.FirstOrDefault(x => x.WeldJointId == rowID);
WeldJointlist.Remove(WeldJoint);
}
ShowNotify("删除成功!", MessageBoxIcon.Success);
this.BindGrid();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <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 Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 保存审核事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
btnSaveMethod(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, this.IsPDMS);
this.BindGrid();
}
protected void btnRefresh_Click(object sender, EventArgs e)
{
this.BindGrid();
}
protected void btnSaveMethod(string LoginProjectId, string UserId, string IsPDMS)
{
//beginProgress();
Funs.DB.HJGL_WeldJoint.InsertAllOnSubmit(WeldJointlist);
Funs.DB.SubmitChanges();
}
#endregion
protected void btnNext_Click(object sender, EventArgs e)
{
btnImport.Hidden = false;
Grid1.Hidden = false;
contentPanel.Hidden = true;
btnNext.Hidden = true;
btnClear.Hidden = false;
var json = hdworkRecord.Value;
if (json != "{}")
{
var jsonObc = JObject.Parse(json);
var jsonArray = jsonObc.Value<JObject>("annotations").Value<JArray>("1");
var iso = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineId == ISO_ID);
if (iso != null)
{
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == iso.UnitId);
WeldJointlist = new List<Model.HJGL_WeldJoint>();
for (int i = 0; i < jsonArray.Count; i++)
{
JObject item = jsonArray[i] as JObject;
Model.HJGL_WeldJoint newDataInTemp = new Model.HJGL_WeldJoint();
newDataInTemp.WeldJointId = SQLHelper.GetNewID(typeof(Model.HJGL_WeldJoint));
newDataInTemp.ProjectId = this.CurrUser.LoginProjectId;
newDataInTemp.PipelineId = iso.PipelineId;
newDataInTemp.PipelineCode = iso.PipelineCode;
newDataInTemp.WeldJointCode = item.Value<string>("label");
newDataInTemp.X = item.Value<string>("x");
newDataInTemp.Y = item.Value<string>("y");
newDataInTemp.X2 = item.Value<string>("x2");
newDataInTemp.Y2 = item.Value<string>("y2");
newDataInTemp.AttachSourceId = FileId;
newDataInTemp.WeldingMode = "手动";
WeldJointlist.Add(newDataInTemp);
}
}
}
BindGrid();
}
public static string ConvertMaterial(object MaterialId)
{
if (MaterialId != null)
{
var material = Funs.DB.Base_Material.FirstOrDefault(x => x.MaterialId == MaterialId.ToString());
if (material != null)
{
return material.MaterialCode;
}
}
return null;
}
public static string ConvertWeldType(object WeldTypeId)
{
if (WeldTypeId != null)
{
var weldType = Funs.DB.Base_WeldType.FirstOrDefault(x => x.WeldTypeId == WeldTypeId.ToString());
if (weldType != null)
{
return weldType.WeldTypeCode;
}
}
return null;
}
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
protected void btnClear_Click(object sender, EventArgs e)
{ ////先删除临时表中 该人员以前导入的数据
WeldJointlist.Clear();
this.BindGrid();
ShowNotify("删除成功!", MessageBoxIcon.Success);
}
}
}