Files
HJGL_DS/HJGL_DS/FineUIPro.Web/Welder/WelderManage.aspx.cs
T
2026-09-22 14:38:37 +08:00

1074 lines
53 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.Welder
{
public partial class WelderManage : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
this.InitTreeMenu();//加载树
}
}
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "单位列表";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
var welders = from x in Funs.DB.HJGL_BS_Welder
join y in Funs.DB.Base_Unit on x.WED_Unit equals y.UnitId
where x.IsOAM == true
select new { x.WED_Unit, x.WED_ID, x.WED_Name, x.WED_Code, y.UnitName, y.UnitCode };
if (!string.IsNullOrEmpty(this.txtUnitName.Text))
{
welders = from x in welders where x.UnitName.Contains(this.txtUnitName.Text.Trim()) select x;
}
if (!string.IsNullOrEmpty(this.txtWelderCodeS.Text.Trim()))
{
welders = from x in welders
where x.WED_Code.Contains(this.txtWelderCodeS.Text.Trim())
select x;
}
if (!string.IsNullOrEmpty(txtWelderNameS.Text.Trim()))
{
welders = from x in welders
where x.WED_Name.Contains(this.txtWelderNameS.Text.Trim())
select x;
}
var units = (from x in welders select new { x.WED_Unit, x.UnitCode, x.UnitName }).Distinct().OrderBy(x => x.UnitCode);
if (units.Count() > 0)
{
foreach (var q in units)
{
TreeNode newNode = new TreeNode();
newNode.NodeID = q.WED_Unit;
newNode.Text = q.UnitName;
newNode.ToolTip = q.UnitName + "【" + q.UnitCode + "】";
newNode.EnableClickEvent = true;
rootNode.Nodes.Add(newNode);
}
}
}
#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 strSql = @"SELECT Welder.WED_ID,Welder.WED_Code,Welder.WED_Name,Welder.WED_Unit,(Unit.UnitCode+'-'+Unit.UnitName) as UnitName,Welder.EDU_ID,Education.TeamGroupName,(CASE WHEN Welder.WED_Sex = '2' THEN '女' ELSE '男' END) AS WED_Sex,"
+ @" Welder.RecordDate,Welder.MaxWeldingWire,Welder.MaxHanTiao, Welder.WED_Birthday,Welder.WED_WorkCode,Welder.WED_Class,(CASE WHEN Welder.WED_IfOnGuard = 1 THEN '是' ELSE '否' END) AS WED_IfOnGuard,Welder.WED_Remark"
+ @" FROM HJGL_BS_Welder AS Welder "
+ @" LEFT JOIN Base_Unit AS Unit ON Welder.WED_Unit = Unit.UnitId"
+ @" LEFT JOIN Base_TeamGroup AS Education ON Welder.EDU_ID = Education.TeamGroupId"
+ @" where Welder.WED_Unit=@unitId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@unitId", this.tvControlItem.SelectedNodeID));
if (!string.IsNullOrEmpty(this.txtWelderNameS.Text.Trim()))
{
strSql += " AND Welder.WED_Name LIKE @WED_Name";
listStr.Add(new SqlParameter("@WED_Name", "%" + this.txtWelderNameS.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtWelderCodeS.Text.Trim()))
{
strSql += " AND Welder.WED_Code LIKE @WED_Code";
listStr.Add(new SqlParameter("@WED_Code", "%" + this.txtWelderCodeS.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtWorkCodeS.Text.Trim()))
{
strSql += " AND Welder.WED_WorkCode LIKE @WED_WorkCode";
listStr.Add(new SqlParameter("@WED_WorkCode", "%" + this.txtWorkCodeS.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtClassS.Text.Trim()))
{
strSql += " AND Welder.WED_Class LIKE @WED_Class";
listStr.Add(new SqlParameter("@WED_Class", "%" + this.txtClassS.Text.Trim() + "%"));
}
if (this.rblIsSelfCreate.SelectedValue != "2")
{
strSql += " AND Welder.IsSelfCreate = @IsSelfCreate";
listStr.Add(new SqlParameter("@IsSelfCreate", this.rblIsSelfCreate.SelectedValue));
}
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 双击事件
/// <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.UserId, Const.Welder_WelderMenuId, Const.BtnSync))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../common/WelderManage/WelderSave.aspx?WED_ID={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
protected void btnSync2_Click(object sender, EventArgs e)
{
var welders = from x in Funs.DB.OAM_User select x;
foreach (var q in welders)
{
var s = from x in Funs.DB.HJGL_BS_Welder where x.IdentityCard == q.MID_IdentityCard select x;
var u = BLL.Base_UnitService.GetUnit2(q.MID_Unit);
if (u != null)
{
Model.HJGL_BS_Welder newWelder = new Model.HJGL_BS_Welder();
newWelder.WED_Code = q.MID_Code;
newWelder.WED_Name = q.MID_Name;
newWelder.WED_Unit = u.UnitId;
newWelder.WED_Sex = q.MID_Sex;
newWelder.IdentityCard = q.MID_IdentityCard;
newWelder.WED_WorkCode = q.MID_WordCode;
newWelder.WED_IfOnGuard = q.MID_IfOnGuard;
newWelder.WED_Remark = q.MID_Remark;
newWelder.MaxHanTiao = q.MID_HanTiao;
newWelder.MaxWeldingWire = q.MID_WeldingWire;
newWelder.IsOAM = true;
newWelder.IsSelfCreate = q.IsSelfCreate;
if (s.Count() > 0)
{
newWelder.WED_ID = s.First().WED_ID;
BLL.HJGL_PersonManageService.UpdateBSWelder(newWelder);
}
else
{
BLL.HJGL_PersonManageService.AddBSWelder(newWelder);
}
}
}
}
protected void btnSync_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.Welder_WelderMenuId, Const.BtnSync))
{
var welders = from x in Funs.DB.OAM_User where (x.IsSync == null || x.IsSync == false) && x.MID_Code != null && x.MID_Code != string.Empty select x;
var quas = from x in Funs.DB.OAM_UesrQualified where (x.IsSync == null || x.IsSync == false) && (x.IsDelete == false || x.IsDelete == null) select x;
var units = (from x in Funs.DB.OAM_User where !x.MID_Unit.Contains("-") select x.MID_Unit).Distinct().ToList();
var allUnits = from x in Funs.DB.Base_Unit select x;
foreach (var unit in units)
{
if (!allUnits.Any(x => x.UnitId == unit || x.UnitName == unit))
{
Model.Base_Unit u = new Model.Base_Unit();
u.UnitId = SQLHelper.GetNewID();
u.UnitName = unit;
u.IsMain = true;
u.IsSubUnit = false;
BLL.Base_UnitService.AddUnit(u);
}
}
int a = 0;
int b = 0;
int m = 0;
int n = 0;
int k = 0;
int l = 0;
foreach (var q in welders)
{
var s = from x in Funs.DB.HJGL_BS_Welder where x.IdentityCard == q.MID_IdentityCard select x;
var u = BLL.Base_UnitService.GetUnit2(q.MID_Unit);
if (u != null)
{
Model.HJGL_BS_Welder newWelder = new Model.HJGL_BS_Welder();
newWelder.WED_Code = q.MID_Code;
newWelder.WED_Name = q.MID_Name;
newWelder.WED_Unit = u.UnitId;
newWelder.WED_Sex = q.MID_Sex;
newWelder.IdentityCard = q.MID_IdentityCard;
newWelder.WED_WorkCode = q.MID_WordCode;
newWelder.WED_IfOnGuard = q.MID_IfOnGuard;
newWelder.WED_Remark = q.MID_Remark;
newWelder.MaxHanTiao = q.MID_HanTiao;
newWelder.MaxWeldingWire = q.MID_WeldingWire;
newWelder.IsOAM = true;
newWelder.IsSelfCreate = q.IsSelfCreate;
if (s.Count() > 0)
{
a++;
newWelder.WED_ID = s.First().WED_ID;
BLL.HJGL_PersonManageService.UpdateBSWelder(newWelder);
}
else
{
b++;
BLL.HJGL_PersonManageService.AddBSWelder(newWelder);
}
// 回写表OAM_User
string identityCard = q.MID_IdentityCard;
bool isSync = true;
BLL.HJGL_WelderQualifiedProjectService.UpdateOAWelder(identityCard, isSync);
}
}
//更新单位变更情况
var allWelders = from x in Funs.DB.OAM_User select x;
foreach (var q in allWelders)
{
var u = BLL.Base_UnitService.GetUnit2(q.MID_Unit);
var w = BLL.HJGL_PersonManageService.GetWelderByIdentityCard(q.MID_IdentityCard);
if (u != null && w != null)
{
w.WED_Unit = u.UnitId;
w.WED_IfOnGuard = q.IsUsed;
BLL.HJGL_PersonManageService.UpdateBSWelder(w);
}
}
foreach (var q in quas)
{
var s = from x in Funs.DB.HJGL_BS_Welder where x.WED_Code == q.MIDWelder_Code select x;
if (s.Count() > 0)
{
if (!string.IsNullOrEmpty(q.MIDWelder_QualifiedProjectCode))
{
if (q.MIDWelder_QualifiedProjectCode.Contains("+") || q.MIDWelder_QualifiedProjectCode.Contains("+") || q.MIDWelder_QualifiedProjectCode.Contains("和"))
{
string[] codes = null;
if (q.MIDWelder_QualifiedProjectCode.Contains("+"))
{
codes = q.MIDWelder_QualifiedProjectCode.Split('+');
}
if (q.MIDWelder_QualifiedProjectCode.Contains("+"))
{
codes = q.MIDWelder_QualifiedProjectCode.Split('+');
}
if (q.MIDWelder_QualifiedProjectCode.Contains("和"))
{
codes = q.MIDWelder_QualifiedProjectCode.Split('和');
}
foreach (string c in codes)
{
var oldCode = from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == s.First().WED_ID && x.QualifiedProjectCode == c && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x;
if (oldCode.Count() == 0)
{
m++;
Model.HJGL_BS_WelderQualifiedProject welderQualifiedProject = new Model.HJGL_BS_WelderQualifiedProject();
welderQualifiedProject.WelderQualifiedProjectId = SQLHelper.GetNewID(typeof(Model.HJGL_BS_WelderQualifiedProject));
welderQualifiedProject.WED_ID = s.First().WED_ID;
welderQualifiedProject.QualifiedProjectCode = c;
welderQualifiedProject.LimitDate = q.MIDWelder_LimitDate;
welderQualifiedProject.IsSteelStru = q.MIDWelder_sfxgjgbl;
welderQualifiedProject.IsDemoteUse = q.MIDWelder_jjsybl;
welderQualifiedProject.DemoteUseSteelType = q.MIDWelder_jjsy;
BLL.HJGL_WelderQualifiedProjectService.AddWelderQualifiedProject(welderQualifiedProject);
}
else
{
k++;
string welderQualifiedProjectId = oldCode.First().WelderQualifiedProjectId;
DateTime? limitDate = q.MIDWelder_LimitDate;
BLL.HJGL_WelderQualifiedProjectService.UpdateWelderQualifiedLimitDate(welderQualifiedProjectId, limitDate, q.MIDWelder_sfxgjgbl, q.MIDWelder_jjsybl, q.MIDWelder_jjsy);
}
}
}
else
{
var oldCode = from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == s.First().WED_ID && x.QualifiedProjectCode == q.MIDWelder_QualifiedProjectCode && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x;
if (oldCode.Count() == 0)
{
n++;
Model.HJGL_BS_WelderQualifiedProject welderQualifiedProject = new Model.HJGL_BS_WelderQualifiedProject();
welderQualifiedProject.WelderQualifiedProjectId = SQLHelper.GetNewID(typeof(Model.HJGL_BS_WelderQualifiedProject));
welderQualifiedProject.WED_ID = s.First().WED_ID;
welderQualifiedProject.QualifiedProjectCode = q.MIDWelder_QualifiedProjectCode;
welderQualifiedProject.LimitDate = q.MIDWelder_LimitDate;
welderQualifiedProject.IsSteelStru = q.MIDWelder_sfxgjgbl;
welderQualifiedProject.IsDemoteUse = q.MIDWelder_jjsybl;
welderQualifiedProject.DemoteUseSteelType = q.MIDWelder_jjsy;
BLL.HJGL_WelderQualifiedProjectService.AddWelderQualifiedProject(welderQualifiedProject);
}
else
{
l++;
string welderQualifiedProjectId = oldCode.First().WelderQualifiedProjectId;
DateTime? limitDate = q.MIDWelder_LimitDate;
BLL.HJGL_WelderQualifiedProjectService.UpdateWelderQualifiedLimitDate(welderQualifiedProjectId, limitDate, q.MIDWelder_sfxgjgbl, q.MIDWelder_jjsybl, q.MIDWelder_jjsy);
}
}
// 回写表OAM_UesrQualified
long welder_ID = q.MIDWelder_ID;
bool isSync = true;
BLL.HJGL_WelderQualifiedProjectService.UpdateOAWelderQue(welder_ID, isSync);
//List<SqlParameter> listStr = new List<SqlParameter>();
//listStr.Add(new SqlParameter("@MIDWelder_ID", q.MIDWelder_ID));
//SqlParameter[] parameter = listStr.ToArray();
//BLL.SQLHelper.ExecutSql("UPDATE dbo.OAM_UesrQualified SET IsSync=1 WHERE MIDWelder_ID=@MIDWelder_ID", parameter);
}
}
}
//更新资质删除情况
var allDeleteQuas = from x in Funs.DB.OAM_UesrQualified where x.IsDelete == true select x;
var allWelders2 = from x in Funs.DB.HJGL_BS_Welder select x;
foreach (var q in allDeleteQuas)
{
var s = allWelders2.FirstOrDefault(x => x.WED_Code == q.MIDWelder_Code);
if (s != null)
{
if (!string.IsNullOrEmpty(q.MIDWelder_QualifiedProjectCode))
{
if (q.MIDWelder_QualifiedProjectCode.Contains("+"))
{
string[] codes = q.MIDWelder_QualifiedProjectCode.Split('+');
foreach (string c in codes)
{
var oldCode = (from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == s.WED_ID && x.QualifiedProjectCode == c && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x).FirstOrDefault();
if (oldCode != null)
{
BLL.HJGL_WelderQualifiedProjectService.DeleteWelderQualifiedProjectByWelderQualifiedProjectId(oldCode.WelderQualifiedProjectId);
}
}
}
else
{
var oldCode = (from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == s.WED_ID && x.QualifiedProjectCode == q.MIDWelder_QualifiedProjectCode && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x).FirstOrDefault();
if (oldCode != null)
{
BLL.HJGL_WelderQualifiedProjectService.DeleteWelderQualifiedProjectByWelderQualifiedProjectId(oldCode.WelderQualifiedProjectId);
}
}
}
}
}
var que = from x in Funs.DB.HJGL_BS_WelderQualifiedProject select x;
if (que.Count() > 0)
{
foreach (var q in que)
{
string weldMethod = string.Empty;
string materialType = string.Empty;
string location = string.Empty;
string weldType = string.Empty;
decimal thicknessMax = 0; // 0表示不限
decimal sizesMin = 0; // 0表示不限
string materialTypeName = string.Empty;
string[] queProject = q.QualifiedProjectCode.Split('-');
// 焊接方法和钢材类型
weldMethod = queProject[0].Trim();
if (queProject.Count() > 1)
{
if (q.IsDemoteUse == true)
{
string[] demoteUseSteelType = q.DemoteUseSteelType.Split(',');
if (demoteUseSteelType.Count() > 0)
{
foreach (string type in demoteUseSteelType)
{
if (type == "FeIV" || type == "FeⅣ")
{
materialType = materialType + "FeⅣ" + ",";
materialTypeName = materialTypeName + "铬钼钢" + ",";
}
if (type == "FeIII" || type == "FeⅢ")
{
materialType = materialType + "FeⅢ" + ",";
materialTypeName = materialTypeName + "合金钢" + ",";
}
if (type == "FeII" || type == "FeⅡ")
{
materialType = materialType + "FeⅡ" + ",";
materialTypeName = materialTypeName + "不锈钢" + ",";
}
if (type == "FeI" || type == "FeⅠ")
{
materialType = materialType + "FeⅠ" + ",";
materialTypeName = materialTypeName + "碳钢" + ",";
}
}
if (materialType.Length > 0 && materialTypeName.Length > 0)
{
materialType = materialType.Substring(0, materialType.Length - 1);
materialTypeName = materialTypeName.Substring(0, materialTypeName.Length - 1);
}
}
}
else
{
if (weldMethod.Contains("GTAW") || weldMethod.Contains("SAW"))
{
if (queProject[1].Trim() == ("FeI") || queProject[1].Trim() == ("FeⅠ"))
{
materialType = "FeⅠ";
materialTypeName = "碳钢";
}
else if (queProject[1].Trim() == ("FeII") || queProject[1].Trim() == ("FeⅡ"))
{
materialType = "FeⅡ,FeⅠ";
materialTypeName = "不锈钢,碳钢";
}
else if (queProject[1].Trim() == ("FeIII") || queProject[1].Trim() == ("FeⅢ"))
{
materialType = "FeⅢ";
materialTypeName = "合金钢";
}
else if (queProject[1].Trim() == ("FeIV") || queProject[1].Trim() == ("FeⅣ"))
{
materialType = "FeⅣ";
materialTypeName = "铬钼钢";
}
else if (queProject[1].Trim().Contains("Ni"))
{
materialType = "NiⅤ,NiⅣ,NiⅢ,NiⅡ,NiⅠ";
materialTypeName = "镍基合金";
}
else if (queProject[1].Trim().Contains("P61"))
{
materialType = "Zr3";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("P62"))
{
materialType = "Zr5";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("TiⅡ"))
{
materialType = "TiⅡ,TiⅠ";
materialTypeName = "钛合金";
}
else if (queProject[1].Trim().Contains("TiⅠ"))
{
materialType = "TiⅠ";
materialTypeName = "钛合金";
}
else
{
materialType = "FeⅣ,FeⅢ,FeⅡ,FeⅠ";
materialTypeName = "其它";
}
}
else if (weldMethod.Contains("SMAW") || weldMethod.Contains("GMAW") || weldMethod.Contains("FCAW"))
{
if (queProject[1].Trim() == ("FeI") || queProject[1].Trim() == ("FeⅠ"))
{
materialType = "FeⅠ";
materialTypeName = "碳钢";
}
else if (queProject[1].Trim() == ("FeII") || queProject[1].Trim() == ("FeⅡ"))
{
materialType = "FeⅡ,FeⅠ";
materialTypeName = "不锈钢,碳钢";
}
else if (queProject[1].Trim() == ("FeIII") || queProject[1].Trim() == ("FeⅢ"))
{
materialType = "FeⅢ,FeⅡ,FeⅠ";
materialTypeName = "合金钢,不锈钢,碳钢";
}
else if (queProject[1].Trim() == ("FeIV") || queProject[1].Trim() == ("FeⅣ"))
{
materialType = "FeⅣ";
materialTypeName = "铬钼钢";
}
else if (queProject[1].Trim().Contains("Ni"))
{
materialType = "NiⅤ,NiⅣ,NiⅢ,NiⅡ,NiⅠ";
materialTypeName = "镍基合金";
}
else if (queProject[1].Trim().Contains("P61"))
{
materialType = "Zr3";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("P62"))
{
materialType = "Zr5";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("TiⅡ"))
{
materialType = "TiⅡ,TiⅠ";
materialTypeName = "钛合金";
}
else if (queProject[1].Trim().Contains("TiⅠ"))
{
materialType = "TiⅠ";
materialTypeName = "钛合金";
}
else
{
materialType = queProject[1].Trim();
materialTypeName = "其它";
}
}
else
{
if (queProject[1].Trim().Contains("Ni"))
{
materialType = "NiⅤ,NiⅣ,NiⅢ,NiⅡ,NiⅠ";
materialTypeName = "镍基合金";
}
else if (queProject[1].Trim().Contains("P61"))
{
materialType = "Zr3";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("P62"))
{
materialType = "Zr5";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("TiⅡ"))
{
materialType = "TiⅡ,TiⅠ";
materialTypeName = "钛合金";
}
else if (queProject[1].Trim().Contains("TiⅠ"))
{
materialType = "TiⅠ";
materialTypeName = "钛合金";
}
else
{
materialType = queProject[1].Trim();
materialTypeName = "其它";
}
}
}
}
if (queProject.Count() > 2)
{
// 焊接位置
if (queProject[2].Contains("6G"))
{
location = "ALL";
}
else if (queProject[2].Contains("2G"))
{
location = "1G,2G";
}
else if (queProject[2].Contains("3G"))
{
location = "1G,2G,3G";
}
else if (queProject[2].Contains("4G"))
{
location = "1G,3G,4G";
}
else if (queProject[2].Contains("5G"))
{
location = "1G,2G,3G,5G";
}
else if (queProject[2].Contains("6FG"))
{
location = "ALL";
}
else if (queProject[2].Contains("5FG"))
{
location = "2FG,5FG";
}
else if (queProject[2].Contains("4FG"))
{
location = "2FG,4FG";
}
else
{
location = queProject[2].Trim();
if (weldMethod.Contains("GTAW") || weldMethod.Contains("SAW"))
{
location = queProject[1].Trim();
}
}
// 1-对接,2-角焊缝,3-支管连接焊缝
if (queProject[2].Contains("FG"))
{
weldType = "2,3";
}
else
{
weldType = "1,2";
}
}
if (queProject.Count() > 3)
{
// 壁厚和外径
string[] thickSize = queProject[3].Split('/');
if (thickSize.Count() == 2)
{
double t = 0.0;
double s = 0.0;
if (double.TryParse(thickSize[0], out t))
{
decimal thick = Convert.ToDecimal(t);
if (thick < 12)
{
//thicknessMax = "≤" + thick * 2;
thicknessMax = thick * 2;
}
else
{
thicknessMax = 0;
}
}
if (double.TryParse(thickSize[1], out s))
{
decimal size = Convert.ToDecimal(s);
if (size < 25)
{
//sizesMin = "≥" + size;
sizesMin = size;
}
else if (size >= 25 && size < 76)
{
//sizesMin = "≥25";
sizesMin = 25;
}
else
{
//sizesMin = "≥76";
sizesMin = 76;
}
}
}
else if (thickSize.Count() == 1)
{
thicknessMax = 0;
//sizesMin = "≥76";
sizesMin = 76;
}
}
if (queProject.Count() > 4)
{
if (queProject[4].Contains("Ni"))
{
materialType = "NiⅤ,NiⅣ,NiⅢ,NiⅡ,NiⅠ";
materialTypeName = "镍基合金";
}
}
Model.HJGL_BS_WelderQualifiedProject updateQue = new Model.HJGL_BS_WelderQualifiedProject();
updateQue.WelderQualifiedProjectId = q.WelderQualifiedProjectId;
updateQue.WED_ID = q.WED_ID;
updateQue.QualifiedProjectCode = q.QualifiedProjectCode;
updateQue.LimitDate = q.LimitDate;
updateQue.WeldingMethodId = weldMethod;
updateQue.MaterialType = materialType;
updateQue.WeldingLocationId = location;
updateQue.WeldType = weldType;
updateQue.ThicknessMax = thicknessMax;
updateQue.SizesMin = sizesMin;
updateQue.MaterialTypeName = materialTypeName;
BLL.HJGL_WelderQualifiedProjectService.UpdateWelderQualifiedProject(updateQue);
}
}
int d = m + n;
int f = k + l;
BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "同步焊工及其合格项目信息");
ShowNotify("插入焊工记录" + b + "条,更新焊工记录" + a + "条,插入焊工合格项" + d + "条,更新焊工合格项" + f + "条", MessageBoxIcon.Success);
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 右键一个焊工同步
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuSync_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
string wederId = Grid1.SelectedRowID;
string wederCode = string.Empty;
var welder = from x in Funs.DB.HJGL_BS_Welder where x.WED_ID == wederId select x;
if (welder.Count() > 0)
{
wederCode = welder.First().WED_Code;
}
// 焊工同步
var welders = from x in Funs.DB.OAM_User where x.MID_Code == wederCode select x;
if (welders.Count() > 0)
{
var u = BLL.Base_UnitService.GetUnit2(welders.First().MID_Unit);
if (u != null)
{
Model.HJGL_BS_Welder newWelder = new Model.HJGL_BS_Welder();
newWelder.WED_ID = wederId;
newWelder.WED_Code = welders.First().MID_Code;
newWelder.WED_Name = welders.First().MID_Name;
newWelder.WED_Unit = welders.First().MID_Unit;
newWelder.WED_Sex = welders.First().MID_Sex;
newWelder.IdentityCard = welders.First().MID_IdentityCard;
newWelder.WED_WorkCode = welders.First().MID_WordCode;
newWelder.WED_IfOnGuard = welders.First().MID_IfOnGuard;
newWelder.WED_Remark = welders.First().MID_Remark;
newWelder.MaxHanTiao = welders.First().MID_HanTiao;
newWelder.MaxWeldingWire = welders.First().MID_WeldingWire;
newWelder.IsOAM = true;
BLL.HJGL_PersonManageService.UpdateBSWelder(newWelder);
}
}
//资质同步
var quas = from x in Funs.DB.OAM_UesrQualified where x.MIDWelder_Code == wederCode select x;
if (quas.Count() > 0)
{
foreach (var q in quas)
{
if (q.MIDWelder_QualifiedProjectCode.Contains("+") || q.MIDWelder_QualifiedProjectCode.Contains("+") || q.MIDWelder_QualifiedProjectCode.Contains("和"))
{
string[] codes = null;
if (q.MIDWelder_QualifiedProjectCode.Contains("+"))
{
codes = q.MIDWelder_QualifiedProjectCode.Split('+');
}
if (q.MIDWelder_QualifiedProjectCode.Contains("+"))
{
codes = q.MIDWelder_QualifiedProjectCode.Split('+');
}
if (q.MIDWelder_QualifiedProjectCode.Contains("和"))
{
codes = q.MIDWelder_QualifiedProjectCode.Split('和');
}
foreach (string c in codes)
{
var oldCode = from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == wederId && x.QualifiedProjectCode == c && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x;
if (oldCode.Count() == 0)
{
Model.HJGL_BS_WelderQualifiedProject welderQualifiedProject = new Model.HJGL_BS_WelderQualifiedProject();
welderQualifiedProject.WelderQualifiedProjectId = SQLHelper.GetNewID(typeof(Model.HJGL_BS_WelderQualifiedProject));
welderQualifiedProject.WED_ID = wederId;
welderQualifiedProject.QualifiedProjectCode = c;
welderQualifiedProject.LimitDate = q.MIDWelder_LimitDate;
welderQualifiedProject.IsSteelStru = q.MIDWelder_sfxgjgbl;
welderQualifiedProject.IsDemoteUse = q.MIDWelder_jjsybl;
welderQualifiedProject.DemoteUseSteelType = q.MIDWelder_jjsy;
BLL.HJGL_WelderQualifiedProjectService.AddWelderQualifiedProject(welderQualifiedProject);
}
else
{
string welderQualifiedProjectId = oldCode.First().WelderQualifiedProjectId;
DateTime? limitDate = q.MIDWelder_LimitDate;
BLL.HJGL_WelderQualifiedProjectService.UpdateWelderQualifiedLimitDate(welderQualifiedProjectId, limitDate, q.MIDWelder_sfxgjgbl, q.MIDWelder_jjsybl, q.MIDWelder_jjsy);
}
}
}
else
{
var oldCode = from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == wederId && x.QualifiedProjectCode == q.MIDWelder_QualifiedProjectCode && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x;
if (oldCode.Count() == 0)
{
Model.HJGL_BS_WelderQualifiedProject welderQualifiedProject = new Model.HJGL_BS_WelderQualifiedProject();
welderQualifiedProject.WelderQualifiedProjectId = SQLHelper.GetNewID(typeof(Model.HJGL_BS_WelderQualifiedProject));
welderQualifiedProject.WED_ID = wederId;
welderQualifiedProject.QualifiedProjectCode = q.MIDWelder_QualifiedProjectCode;
welderQualifiedProject.LimitDate = q.MIDWelder_LimitDate;
welderQualifiedProject.IsSteelStru = q.MIDWelder_sfxgjgbl;
welderQualifiedProject.IsDemoteUse = q.MIDWelder_jjsybl;
welderQualifiedProject.DemoteUseSteelType = q.MIDWelder_jjsy;
BLL.HJGL_WelderQualifiedProjectService.AddWelderQualifiedProject(welderQualifiedProject);
}
else
{
string welderQualifiedProjectId = oldCode.First().WelderQualifiedProjectId;
DateTime? limitDate = q.MIDWelder_LimitDate;
BLL.HJGL_WelderQualifiedProjectService.UpdateWelderQualifiedLimitDate(welderQualifiedProjectId, limitDate, q.MIDWelder_sfxgjgbl, q.MIDWelder_jjsybl, q.MIDWelder_jjsy);
}
}
}
}
ShowNotify("同步成功!", MessageBoxIcon.Success);
}
/// <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.Welder_WelderMenuId, Const.BtnSync))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../common/WelderManage/WelderSave.aspx?WED_ID={0}", String.Empty, "新增 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <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.UserId, BLL.Const.Welder_WelderMenuId, BLL.Const.BtnModify))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../common/WelderManage/WelderSave.aspx?WED_ID={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.UserId, Const.Welder_WelderMenuId, Const.BtnDelete))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
bool isShow = true;
if (Grid1.SelectedRowIndexArray.Length > 1)
{
isShow = false;
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
if (judgementDelete(rowID, isShow))
{
BLL.HJGL_WelderQualifiedProjectService.DeleteWelderQualifiedProjectByWED_ID(rowID);
BLL.HJGL_PersonManageService.DeleteBSWelder(rowID);
BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊工信息");
}
}
ShowNotify("删除成功!", MessageBoxIcon.Success);
this.BindGrid();
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#region 判断是否可删除
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
private bool judgementDelete(string id, bool isShow)
{
string content = string.Empty;
if (BLL.HJGL_PW_JointInfoService.GetJointInfoByCellWelder(id) > 0 || BLL.HJGL_PW_JointInfoService.GetJointInfoByFloorWelder(id) > 0)
{
content = "焊口中已使用了该人员,不能删除!";
}
if (string.IsNullOrEmpty(content))
{
return true;
}
else
{
if (isShow)
{
Alert.ShowInTop(content, MessageBoxIcon.Error);
}
return false;
}
}
#endregion
#region 打印
/// <summary>
/// 打印合格焊工
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrint_Click(object sender, EventArgs e)
{
var project = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (project != null)
{
string varValue = project.ProjectName;
if (string.IsNullOrEmpty(varValue))
{
varValue = Microsoft.JScript.GlobalObject.escape(varValue.Replace("/", ","));
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_WelderRecordReportId, this.CurrUser.LoginProjectId, varValue, "打印 - ")));
}
}
#endregion
#region 导入
/// <summary>
/// 导入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnIn_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.Welder_WelderMenuId, Const.BtnIn))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../common/WelderManage/WelderIn.aspx", "导入 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region 弹出编辑窗口关闭事件
/// <summary>
/// 弹出编辑窗体关闭事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
this.BindGrid();
}
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
protected void drpUnitS_SelectedIndexChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#region 分页 排序
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
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)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#endregion
}
}