2025-10-10 14:33:21 +08:00
using BLL ;
2022-12-09 18:08:25 +08:00
using Model ;
2022-09-05 16:36:31 +08:00
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Linq ;
using System.Web.UI.WebControls ;
2022-12-09 18:08:25 +08:00
2022-09-05 16:36:31 +08:00
namespace FineUIPro.Web.HJGL.WeldingManage
{
public partial class SelectTaskWeldJoint : PageBase
{
#region 定 义 项
/// <summary>
/// 单位主键
/// </summary>
2023-10-25 19:44:10 +08:00
//public string UnitId
//{
// get
// {
// return (string)ViewState["UnitId"];
// }
// set
// {
// ViewState["UnitId"] = value;
// }
//}
2022-09-05 16:36:31 +08:00
/// <summary>
/// 单位工程主键
/// </summary>
public string UnitWorkId
{
get
{
return ( string ) ViewState [ "UnitWorkId" ] ;
}
set
{
ViewState [ "UnitWorkId" ] = value ;
}
}
2024-12-26 14:42:15 +08:00
public string SerialNumber
{
get
{
return ( string ) ViewState [ "SerialNumber" ] ;
}
set
{
ViewState [ "SerialNumber" ] = value ;
}
}
2022-09-05 16:36:31 +08:00
// 任务日期
public string TaskDate
{
get
{
return ( string ) ViewState [ "TaskDate" ] ;
}
set
{
ViewState [ "TaskDate" ] = value ;
}
}
/// <summary>
/// 日报主键
/// </summary>
public string WeldingDailyId
{
get
{
return ( string ) ViewState [ "WeldingDailyId" ] ;
}
set
{
ViewState [ "WeldingDailyId" ] = value ;
}
}
/// <summary>
/// 被选择项列表
/// </summary>
public List < string > SelectedList
{
get
{
return ( List < string > ) ViewState [ "SelectedList" ] ;
}
set
{
ViewState [ "SelectedList" ] = value ;
}
}
2022-12-09 18:08:25 +08:00
public List < HJGL_Pipeline > Tree_hJGL_Pipelines ;
2023-02-17 15:30:04 +08:00
public int pageSize = PipelineService . pageSize ;
2023-11-29 10:46:42 +08:00
2022-09-05 16:36:31 +08:00
#endregion
#region 加 载 页 面
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
2022-11-25 14:08:03 +08:00
HJGL_MaterialService . materialStockItems_FIELD = new List < Model . MaterialStockItem > ( ) ;
HJGL_MaterialService . materialStockItems_SHOP = new List < Model . MaterialStockItem > ( ) ;
2023-02-17 15:30:04 +08:00
2023-11-29 10:46:42 +08:00
Tree_hJGL_Pipelines = new List < HJGL_Pipeline > ( ) ;
2022-09-05 16:36:31 +08:00
this . txtTaskDate . Text = string . Format ( "{0:yyyy-MM-dd}" , DateTime . Now . AddDays ( 1 ) ) ;
BLL . Base_WeldingLocationServie . InitWeldingLocationDropDownList ( drpWeldingLocation , true ) ;
///焊接属性
this . drpJointAttribute . DataTextField = "Text" ;
this . drpJointAttribute . DataValueField = "Value" ;
this . drpJointAttribute . DataSource = BLL . DropListService . HJGL_JointAttribute ( ) ;
this . drpJointAttribute . DataBind ( ) ;
///机动化程度
this . drpWeldingMode . DataTextField = "Text" ;
this . drpWeldingMode . DataValueField = "Value" ;
this . drpWeldingMode . DataSource = BLL . DropListService . HJGL_WeldingMode ( ) ;
this . drpWeldingMode . DataBind ( ) ;
//this.SelectedList = new List<string>();
//this.NoSelectedList = new List<string>();
2023-10-27 18:07:01 +08:00
2022-09-05 16:36:31 +08:00
string strList = Request . Params [ "strList" ] ;
List < string > list = Funs . GetStrListByStr ( strList , '|' ) ;
2024-09-18 10:48:34 +08:00
2024-12-26 14:42:15 +08:00
if ( list . Count ( ) = = 4 )
2022-09-05 16:36:31 +08:00
{
this . UnitWorkId = list [ 0 ] ;
2023-12-04 12:11:39 +08:00
string unitId = list [ 1 ] ;
TaskDate = list [ 2 ] ;
2024-12-26 14:42:15 +08:00
SerialNumber = list [ 3 ] ;
2023-10-27 18:07:01 +08:00
InitDropList ( ) ;
2023-10-25 19:44:10 +08:00
Model . WBS_UnitWork UnitWork = BLL . UnitWorkService . getUnitWorkByUnitWorkId ( this . UnitWorkId ) ;
BLL . UnitService . InitUnitDropDownListByUnitIds ( this . drpUnit , UnitWork . UnitId , false ) ; //单位
2023-12-04 12:11:39 +08:00
this . drpUnit . SelectedValue = unitId ;
2024-09-18 10:48:34 +08:00
this . txtTaskCode . Text = BLL . WeldTaskService . GetTaskCodeByDate ( this . CurrUser . LoginProjectId , this . txtTaskDate . Text , list [ 0 ] , drpUnit . SelectedValue ) ;
2023-12-04 12:11:39 +08:00
if ( ! string . IsNullOrEmpty ( TaskDate ) )
{
txtTaskDate . Text = TaskDate ;
txtTaskDate . Enabled = false ;
var task = ( from x in Funs . DB . HJGL_WeldTask
where x . UnitWorkId = = UnitWorkId & & x . UnitId = = unitId
2025-10-10 14:33:21 +08:00
& & x . TaskDate . Value . Date . ToString ( ) = = Convert . ToDateTime ( txtTaskDate . Text . Trim ( ) ) . ToString ( "yyyy-MM-dd" ) & & x . SerialNumber = = SerialNumber
2023-12-04 12:11:39 +08:00
select x ) . FirstOrDefault ( ) ;
if ( task ! = null )
{
txtTaskCode . Text = task . TaskCode ;
//drpUnit.SelectedValue = task.UnitId;
}
txtTaskCode . Enabled = false ;
}
string projectId = string . Empty ;
2023-10-25 19:44:10 +08:00
2023-12-04 12:11:39 +08:00
if ( UnitWorkId ! = null )
{
projectId = UnitWork . ProjectId ;
this . txtUnitWorkName . Text = UnitWork . UnitWorkName ;
}
}
else
{
this . UnitWorkId = list [ 0 ] ;
TaskDate = list [ 1 ] ;
InitDropList ( ) ;
Model . WBS_UnitWork UnitWork = BLL . UnitWorkService . getUnitWorkByUnitWorkId ( this . UnitWorkId ) ;
BLL . UnitService . InitUnitDropDownListByUnitIds ( this . drpUnit , UnitWork . UnitId , false ) ; //单位
2024-09-18 10:48:34 +08:00
this . txtTaskCode . Text = BLL . WeldTaskService . GetTaskCodeByDate ( this . CurrUser . LoginProjectId , this . txtTaskDate . Text , list [ 0 ] , drpUnit . SelectedValue ) ;
2025-10-10 14:33:21 +08:00
SerialNumber = BLL . WeldTaskService . GetSerialNumberByDate ( this . CurrUser . LoginProjectId , this . txtTaskDate . Text , list [ 0 ] , drpUnit . SelectedValue ) ;
2022-09-05 16:36:31 +08:00
if ( ! string . IsNullOrEmpty ( TaskDate ) )
{
txtTaskDate . Text = TaskDate ;
txtTaskDate . Enabled = false ;
var task = ( from x in Funs . DB . HJGL_WeldTask
where x . UnitWorkId = = UnitWorkId
2024-12-26 14:42:15 +08:00
& & x . TaskDate . Value . Date . ToString ( ) = = Convert . ToDateTime ( txtTaskDate . Text . Trim ( ) ) . ToString ( "yyyy-MM-dd" ) & & x . SerialNumber = = SerialNumber
2022-09-05 16:36:31 +08:00
select x ) . FirstOrDefault ( ) ;
if ( task ! = null )
{
txtTaskCode . Text = task . TaskCode ;
2023-12-04 12:11:39 +08:00
//drpUnit.SelectedValue = task.UnitId;
2022-09-05 16:36:31 +08:00
}
txtTaskCode . Enabled = false ;
}
string projectId = string . Empty ;
2023-11-29 10:46:42 +08:00
2022-09-05 16:36:31 +08:00
if ( UnitWorkId ! = null )
2023-11-29 10:46:42 +08:00
{
2022-09-05 16:36:31 +08:00
projectId = UnitWork . ProjectId ;
this . txtUnitWorkName . Text = UnitWork . UnitWorkName ;
}
}
this . InitTreeMenu ( ) ; //加载树
}
}
#endregion
#region 加 载 树
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu ( )
{
this . tvControlItem . Nodes . Clear ( ) ;
2023-11-29 10:46:42 +08:00
int a = ( from x in Funs . DB . HJGL_Pipeline where x . ProjectId = = this . CurrUser . LoginProjectId & & x . UnitWorkId = = this . UnitWorkId & & x . PipeArea = = PipelineService . PipeArea_SHOP & & x . PipelineCode . Contains ( this . txtPipelineCode . Text . Trim ( ) ) select x ) . Count ( ) ;
int b = ( from x in Funs . DB . HJGL_Pipeline where x . ProjectId = = this . CurrUser . LoginProjectId & & x . UnitWorkId = = this . UnitWorkId & & x . PipeArea = = PipelineService . PipeArea_FIELD & & x . PipelineCode . Contains ( this . txtPipelineCode . Text . Trim ( ) ) select x ) . Count ( ) ;
2023-02-17 15:30:04 +08:00
2022-09-05 16:36:31 +08:00
TreeNode rootNode1 = new TreeNode ( ) ;
rootNode1 . NodeID = BLL . PipelineService . PipeArea_SHOP ;
rootNode1 . Text = "工厂预制" ;
2023-02-17 15:30:04 +08:00
rootNode1 . CommandName = 1 + "|" + Funs . GetEndPageNumber ( a , pageSize ) ; //页码|总页
2022-09-05 16:36:31 +08:00
rootNode1 . EnableClickEvent = true ;
2023-11-29 10:46:42 +08:00
rootNode1 . EnableExpandEvent = true ;
2022-09-05 16:36:31 +08:00
this . tvControlItem . Nodes . Add ( rootNode1 ) ;
2022-11-25 14:08:03 +08:00
if ( a > 0 )
{
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = "加载管线..." ;
newNode . NodeID = "加载管线..." ;
rootNode1 . Nodes . Add ( newNode ) ;
}
2022-09-05 16:36:31 +08:00
TreeNode rootNode2 = new TreeNode ( ) ;
rootNode2 . NodeID = BLL . PipelineService . PipeArea_FIELD ;
2023-12-01 12:56:11 +08:00
rootNode2 . Text = "现场施工" ;
2023-11-20 18:51:03 +08:00
rootNode2 . CommandName = 1 + "|" + Funs . GetEndPageNumber ( b , pageSize ) ;
2022-09-05 16:36:31 +08:00
rootNode2 . EnableClickEvent = true ;
2022-11-25 14:08:03 +08:00
rootNode2 . EnableExpandEvent = true ;
2022-09-05 16:36:31 +08:00
this . tvControlItem . Nodes . Add ( rootNode2 ) ;
2022-11-25 14:08:03 +08:00
if ( b > 0 )
{
2023-11-29 10:46:42 +08:00
TreeNode newNode = new TreeNode ( ) ;
2022-11-25 14:08:03 +08:00
newNode . Text = "加载管线..." ;
newNode . NodeID = "加载管线..." ;
rootNode2 . Nodes . Add ( newNode ) ;
}
2022-09-05 16:36:31 +08:00
}
2023-11-29 10:46:42 +08:00
void AddTreeNode ( string PipeArea , TreeNode node )
{
2023-02-17 15:30:04 +08:00
var pipeline = ( from x in Funs . DB . HJGL_Pipeline
2023-11-29 10:46:42 +08:00
where x . ProjectId = = this . CurrUser . LoginProjectId
& & x . UnitWorkId = = this . UnitWorkId
& & x . PipeArea = = PipeArea
& & x . PipelineCode . Contains ( this . txtPipelineCode . Text . Trim ( ) )
orderby x . PipelineCode
select x ) . ToList ( ) ;
if ( ! string . IsNullOrEmpty ( drpFlowingSection . SelectedValue ) & & drpFlowingSection . SelectedValue ! = Const . _Null )
2023-10-27 18:07:01 +08:00
{
pipeline = pipeline . Where ( x = > x . FlowingSection = = drpFlowingSection . SelectedValue ) . ToList ( ) ;
}
2023-02-17 15:30:04 +08:00
var joints = ( from x in Funs . DB . HJGL_WeldJoint where x . ProjectId = = this . CurrUser . LoginProjectId select x ) . ToList ( ) ;
2023-11-29 10:46:42 +08:00
int pageindex = int . Parse ( node . CommandName . Split ( '|' ) [ 0 ] ) ;
2023-02-17 15:30:04 +08:00
int pageCount = int . Parse ( node . CommandName . Split ( '|' ) [ 1 ] ) ;
if ( pageindex < = pageCount )
2022-12-09 18:08:25 +08:00
{
2023-02-17 15:30:04 +08:00
pipeline = pipeline . Skip ( pageSize * ( pageindex - 1 ) ) . Take ( pageSize ) . ToList ( ) ; ;
foreach ( var item in pipeline )
2022-12-12 14:08:35 +08:00
{
TreeNode newNode = new TreeNode ( ) ;
int totalJointNum = joints . Count ( x = > x . PipelineId = = item . PipelineId ) ;
int weldJointNum = joints . Count ( x = > x . PipelineId = = item . PipelineId & & x . WeldingDailyId ! = null ) ;
2023-02-17 15:58:13 +08:00
//bool istrue = BLL.HJGL_MaterialService.isInStockByPipeline(item.PipelineId, this.CurrUser.LoginProjectId);
//if (istrue)
//{
// newNode.CssClass = "tn-color-green";
//}
2022-12-12 14:08:35 +08:00
newNode . Text = item . PipelineCode + "(" + ( totalJointNum - weldJointNum ) . ToString ( ) + ")" ;
newNode . NodeID = item . PipelineId ;
newNode . ToolTip = item . PipelineCode ;
newNode . EnableClickEvent = true ;
node . Nodes . Add ( newNode ) ;
2022-12-09 18:08:25 +08:00
2022-12-12 14:08:35 +08:00
}
2023-02-17 15:30:04 +08:00
if ( pageindex < pageCount )
2022-10-24 00:57:03 +08:00
{
2022-12-12 14:08:35 +08:00
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = "加载" ;
newNode . NodeID = SQLHelper . GetNewID ( ) ;
newNode . Icon = Icon . ArrowDown ;
newNode . CommandName = PipeArea ;
newNode . EnableClickEvent = true ;
node . Nodes . Add ( newNode ) ;
2022-10-24 00:57:03 +08:00
}
2022-09-05 16:36:31 +08:00
}
2023-11-29 10:46:42 +08:00
2022-09-05 16:36:31 +08:00
}
2022-11-25 14:08:03 +08:00
protected void tvControlItem_TreeNodeExpanded ( object sender , TreeNodeEventArgs e )
{
if ( e . Node . Nodes [ 0 ] . NodeID = = "加载管线..." )
{
e . Node . Nodes . Clear ( ) ;
2023-02-17 15:30:04 +08:00
if ( e . Node . Text = = "工厂预制" )
2022-11-25 14:08:03 +08:00
{
AddTreeNode ( BLL . PipelineService . PipeArea_SHOP , e . Node ) ;
2022-09-05 16:36:31 +08:00
2022-11-25 14:08:03 +08:00
}
2023-12-01 12:56:11 +08:00
else if ( e . Node . Text = = "现场施工" )
2022-11-25 14:08:03 +08:00
{
AddTreeNode ( BLL . PipelineService . PipeArea_FIELD , e . Node ) ;
2022-09-05 16:36:31 +08:00
2022-11-25 14:08:03 +08:00
}
}
2023-11-29 10:46:42 +08:00
2022-11-25 14:08:03 +08:00
}
2023-02-17 15:30:04 +08:00
#endregion
#region 点 击 TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand ( object sender , TreeCommandEventArgs e )
{
if ( e . Node . Text = = "加载" )
{
string CommandName = e . Node . ParentNode . CommandName ;
e . Node . ParentNode . CommandName = ( int . Parse ( CommandName . Split ( '|' ) [ 0 ] ) + 1 ) + "|" + int . Parse ( CommandName . Split ( '|' ) [ 1 ] ) ;
TreeNode treeNode = e . Node . ParentNode ;
treeNode . Nodes . Remove ( e . Node ) ;
if ( e . Node . CommandName = = "1" )
{
AddTreeNode ( BLL . PipelineService . PipeArea_SHOP , e . Node . ParentNode ) ;
}
2023-11-29 10:46:42 +08:00
else if ( e . Node . CommandName = = "2" )
{
2023-02-17 15:30:04 +08:00
AddTreeNode ( BLL . PipelineService . PipeArea_FIELD , e . Node . ParentNode ) ;
}
}
else
{
this . BindGrid ( ) ;
}
}
#endregion
2022-11-25 14:08:03 +08:00
2023-02-17 15:30:04 +08:00
#region 数 据 绑 定
/// <summary>
/// 数据绑定
/// </summary>
2022-12-09 18:08:25 +08:00
private void BindGrid ( )
2022-09-05 16:36:31 +08:00
{
string pipelineId = this . tvControlItem . SelectedNodeID ;
var toDoMatterList = ( from x in Funs . DB . View_HJGL_NoWeldJointFind
2023-11-29 10:46:42 +08:00
where x . PipelineId = = pipelineId & & x . WeldingDailyId = = null & & x . JointAttribute = = drpJointAttribute . SelectedValue
2023-12-02 18:32:27 +08:00
& & ( string . IsNullOrEmpty ( drpWeldTypeCode . SelectedValue ) | | x . WeldTypeCode . Contains ( drpWeldTypeCode . SelectedValue ) ) & & x . WeldTaskId = = null
2022-09-05 16:36:31 +08:00
select x ) . ToList ( ) ;
//去除任务表已存在的焊口
2023-12-02 18:32:27 +08:00
//if (!string.IsNullOrEmpty(TaskDate))
//{
// var task = from x in Funs.DB.HJGL_WeldTask where x.UnitWorkId == UnitWorkId && x.TaskDate.Value.Date.ToString() == Convert.ToDateTime(txtTaskDate.Text.Trim()).ToString("yyyy-MM-dd") select x;
// if (task.Count() > 0)
// {
// foreach (var item in task)
// {
// Model.View_HJGL_NoWeldJointFind jot = toDoMatterList.FirstOrDefault(e => e.WeldJointId == item.WeldJointId);
// if (jot != null)
// {
// toDoMatterList.Remove(jot);
// }
// }
// }
//}
2022-09-05 16:36:31 +08:00
DataTable tb = this . LINQToDataTable ( toDoMatterList ) ;
// 2.获取当前分页数据
Grid1 . RecordCount = tb . Rows . Count ;
tb = GetFilteredTable ( Grid1 . FilteredData , tb ) ;
var table = this . GetPagedDataTable ( Grid1 , tb ) ;
Grid1 . DataSource = table ;
Grid1 . DataBind ( ) ;
//string[] arr = new string[this.Grid1.Rows.Count];
//int a = 0;
//for (int i = 0; i < this.Grid1.Rows.Count; i++)
//{
// string rowId = this.Grid1.Rows[i].DataKeys[0].ToString();
// if (weldJointIds.Contains(rowId))
// {
// arr[a] = rowId;
// }
// a++;
//}
//Grid1.SelectedRowIDArray = arr;
}
2023-10-27 18:07:01 +08:00
private void InitDropList ( )
{
var pipeline = ( from x in Funs . DB . HJGL_Pipeline
2023-11-29 10:46:42 +08:00
where x . ProjectId = = this . CurrUser . LoginProjectId
& & x . UnitWorkId = = this . UnitWorkId
select x . FlowingSection ) . Distinct ( ) . ToList ( ) ;
2023-10-27 18:07:01 +08:00
this . drpFlowingSection . DataTextField = "Value" ;
this . drpFlowingSection . DataValueField = "Value" ;
this . drpFlowingSection . DataSource = pipeline ;
this . drpFlowingSection . DataBind ( ) ;
2023-10-31 10:02:54 +08:00
Funs . FineUIPleaseSelect ( drpFlowingSection ) ;
2023-10-27 18:07:01 +08:00
}
2022-09-05 16:36:31 +08:00
#endregion
#region 管 线 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnQuery_Click ( object sender , EventArgs e )
{
this . InitTreeMenu ( ) ;
this . BindGrid ( ) ;
}
#endregion
#region 排 序
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort ( object sender , GridSortEventArgs e )
{
this . BindGrid ( ) ;
}
#endregion
#region 提 交 按 钮
/// <summary>
/// 提交按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAccept_Click ( object sender , EventArgs e )
2022-12-12 14:08:35 +08:00
{
PageContext . RegisterStartupScript ( ActiveWindow . GetWriteBackValueReference ( txtTaskDate . Text ) + ActiveWindow . GetHidePostBackReference ( ) ) ;
//if (string.IsNullOrEmpty(this.txtTaskCode.Text.Trim()))
//{
// ShowNotify("请输入焊接任务单编号", MessageBoxIcon.Warning);
// return;
//}
//if (!string.IsNullOrEmpty(txtTaskDate.Text))
//{
// if (!string.IsNullOrEmpty(TaskDate))
// {
// SaveTask(true);
// }
// else
// {
// var task = from x in Funs.DB.HJGL_WeldTask
// where x.UnitWorkId == UnitWorkId
// && x.TaskDate.Value.Date.ToString() == Convert.ToDateTime(txtTaskDate.Text.Trim()).ToString("yyyy-MM-dd")
// select x;
// if (task.Count() > 0)
// {
// ShowNotify("所选预计焊接日期已存在,请重新选择!", MessageBoxIcon.Warning);
// return;
// }
// else
// {
// SaveTask(true);
// }
// }
//}
//else
//{
// ShowNotify("请选择预计焊接日期", MessageBoxIcon.Warning);
// return;
//}
}
protected void btnSave_Click ( object sender , EventArgs e )
2022-09-05 16:36:31 +08:00
{
if ( string . IsNullOrEmpty ( this . txtTaskCode . Text . Trim ( ) ) )
{
ShowNotify ( "请输入焊接任务单编号" , MessageBoxIcon . Warning ) ;
return ;
}
if ( ! string . IsNullOrEmpty ( txtTaskDate . Text ) )
{
if ( ! string . IsNullOrEmpty ( TaskDate ) )
{
2022-12-12 14:08:35 +08:00
SaveTask ( false ) ;
BindGrid ( ) ;
2022-09-05 16:36:31 +08:00
}
else
{
var task = from x in Funs . DB . HJGL_WeldTask
2023-12-04 12:11:39 +08:00
where x . UnitWorkId = = UnitWorkId & & x . UnitId = = this . drpUnit . SelectedValue
2022-09-05 16:36:31 +08:00
& & x . TaskDate . Value . Date . ToString ( ) = = Convert . ToDateTime ( txtTaskDate . Text . Trim ( ) ) . ToString ( "yyyy-MM-dd" )
select x ;
if ( task . Count ( ) > 0 )
{
ShowNotify ( "所选预计焊接日期已存在,请重新选择!" , MessageBoxIcon . Warning ) ;
return ;
}
else
{
2022-12-12 14:08:35 +08:00
SaveTask ( false ) ;
TaskDate = txtTaskDate . Text ;
BindGrid ( ) ;
2022-09-05 16:36:31 +08:00
}
}
}
else
{
ShowNotify ( "请选择预计焊接日期" , MessageBoxIcon . Warning ) ;
return ;
}
2022-12-12 14:08:35 +08:00
}
private void SaveTask ( bool IsCloseForm )
2022-09-05 16:36:31 +08:00
{
var weldingRods = from x in Funs . DB . Base_Consumables where x . ConsumablesType = = "2" select x ;
var weldingWires = from x in Funs . DB . Base_Consumables where x . ConsumablesType = = "1" select x ;
string [ ] selectRowId = Grid1 . SelectedRowIDArray ;
for ( int i = 0 ; i < selectRowId . Count ( ) ; i + + )
{
string canWeldingRodName = string . Empty ;
string canWeldingWireName = string . Empty ;
Model . HJGL_WeldTask NewTask = new Model . HJGL_WeldTask ( ) ;
NewTask . ProjectId = this . CurrUser . LoginProjectId ;
NewTask . UnitWorkId = this . UnitWorkId ;
2023-10-25 19:44:10 +08:00
NewTask . UnitId = drpUnit . SelectedValue ;
2022-09-05 16:36:31 +08:00
NewTask . TaskCode = this . txtTaskCode . Text . Trim ( ) ;
2024-12-26 14:42:15 +08:00
NewTask . SerialNumber = SerialNumber ;
2022-09-05 16:36:31 +08:00
NewTask . WeldTaskId = SQLHelper . GetNewID ( ) ;
NewTask . WeldJointId = selectRowId [ i ] ;
2023-12-01 12:11:50 +08:00
var oldWeldTask = BLL . WeldTaskService . GetWeldTaskByWeldJointId ( NewTask . WeldJointId ) ;
if ( oldWeldTask ! = null )
{
2023-12-02 18:32:27 +08:00
ShowNotify ( "所选焊口已存在任务单,无法保存!" , MessageBoxIcon . Warning ) ;
2023-12-01 12:11:50 +08:00
return ;
}
2022-09-05 16:36:31 +08:00
Model . HJGL_WeldJoint weldJoint = BLL . WeldJointService . GetWeldJointByWeldJointId ( NewTask . WeldJointId ) ;
if ( weldJoint ! = null )
{
NewTask . WeldingRod = weldJoint . WeldingRod ;
NewTask . WeldingWire = weldJoint . WeldingWire ;
//获取可替代焊丝焊条
var mat = BLL . Base_MaterialService . GetMaterialByMaterialId ( weldJoint . Material1Id ) ;
string matClass = mat . MaterialClass ;
var matRod = weldingRods . FirstOrDefault ( x = > x . ConsumablesId = = weldJoint . WeldingRod ) ;
if ( matRod ! = null )
{
foreach ( var item in weldingRods )
{
if ( matClass = = "Fe-1" | | matClass = = "Fe-3" )
{
if ( IsCoverClass ( matRod . SteelType , item . SteelType ) )
{
canWeldingRodName = canWeldingRodName + item . ConsumablesName + "," ;
}
}
else
{
if ( matRod . SteelType = = item . SteelType )
{
canWeldingRodName = canWeldingRodName + item . ConsumablesName + "," ;
}
}
}
if ( ! string . IsNullOrEmpty ( canWeldingRodName ) )
{
NewTask . CanWeldingRodName = canWeldingRodName . Substring ( 0 , canWeldingRodName . Length - 1 ) ;
}
}
var matWire = weldingWires . FirstOrDefault ( x = > x . ConsumablesId = = weldJoint . WeldingWire ) ;
if ( matWire ! = null )
{
foreach ( var item in weldingWires )
{
if ( matClass = = "Fe-1" | | matClass = = "Fe-3" )
{
if ( IsCoverClass ( matWire . SteelType , item . SteelType ) )
{
canWeldingWireName = canWeldingWireName + item . ConsumablesName + "," ;
}
}
else
{
if ( matWire . SteelType = = item . SteelType )
{
canWeldingWireName = canWeldingWireName + item . ConsumablesName + "," ;
}
}
}
if ( ! string . IsNullOrEmpty ( canWeldingWireName ) )
{
NewTask . CanWeldingWireName = canWeldingWireName . Substring ( 0 , canWeldingWireName . Length - 1 ) ;
}
}
}
//NewTask.JointAttribute = drpJointAttribute.SelectedValue;
NewTask . JointAttribute = weldJoint . JointAttribute ;
NewTask . WeldingMode = drpWeldingMode . SelectedValue ;
NewTask . TaskDate = Convert . ToDateTime ( txtTaskDate . Text ) ;
NewTask . Tabler = this . CurrUser . PersonId ;
NewTask . TableDate = DateTime . Now ;
2023-11-29 10:46:42 +08:00
weldJoint . WeldingMode = drpWeldingMode . SelectedValue ;
2023-02-20 10:49:51 +08:00
BLL . WeldJointService . UpdateWeldJoint ( weldJoint ) ;
2022-09-05 16:36:31 +08:00
BLL . WeldTaskService . AddWeldTask ( NewTask ) ;
}
2022-11-16 19:48:03 +08:00
//string pipelineId = this.tvControlItem.SelectedNodeID;
//var model = BLL.PipelineService.GetPipelineByPipelineId(pipelineId);
//model.State = 1;
//PipelineService.UpdatePipeline(model);
2022-09-05 16:36:31 +08:00
ShowNotify ( "保存成功!" , MessageBoxIcon . Success ) ;
2022-12-12 14:08:35 +08:00
if ( IsCloseForm )
{
PageContext . RegisterStartupScript ( ActiveWindow . GetWriteBackValueReference ( txtTaskDate . Text ) + ActiveWindow . GetHidePostBackReference ( ) ) ;
}
2022-09-05 16:36:31 +08:00
//PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
/// <summary>
/// 判断耗材强度是否大于WPS耗材强度, 如是为true,否则为false
/// </summary>
/// <param name="wpsClass"></param>
/// <param name="matClass"></param>
/// <returns></returns>
private bool IsCoverClass ( string wpsClass , string matClass )
{
bool isCover = false ;
int wpsSn = 0 ;
int matSn = 0 ;
if ( wpsClass . Length > 2 & & matClass . Length > 2 )
{
string wpsPre = wpsClass . Substring ( 0 , wpsClass . Length - 2 ) ;
string matPre = matClass . Substring ( 0 , matClass . Length - 2 ) ;
string wps = wpsClass . Substring ( wpsClass . Length - 1 , 1 ) ;
wpsSn = Funs . GetNewInt ( wps ) . HasValue ? Funs . GetNewInt ( wps ) . Value : 0 ;
string mat = matClass . Substring ( matClass . Length - 1 , 1 ) ;
matSn = Funs . GetNewInt ( mat ) . HasValue ? Funs . GetNewInt ( mat ) . Value : 0 ;
if ( wpsPre = = matPre & & matSn > = wpsSn )
{
return true ;
}
}
return isCover ;
}
#endregion
protected void txtTaskDate_TextChanged ( object sender , EventArgs e )
{
2024-09-18 10:48:34 +08:00
this . txtTaskCode . Text = BLL . WeldTaskService . GetTaskCodeByDate ( this . CurrUser . LoginProjectId , this . txtTaskDate . Text , UnitWorkId , drpUnit . SelectedValue ) ;
2022-09-05 16:36:31 +08:00
}
2024-09-18 10:48:34 +08:00
protected void drpUnit_SelectedIndexChanged ( object sender , EventArgs e )
{
this . txtTaskCode . Text = BLL . WeldTaskService . GetTaskCodeByDate ( this . CurrUser . LoginProjectId , this . txtTaskDate . Text , UnitWorkId , drpUnit . SelectedValue ) ;
2022-09-05 16:36:31 +08:00
2024-09-18 10:48:34 +08:00
}
2022-09-05 16:36:31 +08:00
protected void drpJointAttribute_SelectedIndexChanged ( object sender , EventArgs e )
{
BindGrid ( ) ;
}
2022-10-24 00:57:03 +08:00
/// <summary>
/// 行绑定事件(没有焊接方法无法选择)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDataBound ( object sender , GridRowEventArgs e )
{
DataRowView row = e . DataItem as DataRowView ;
if ( string . IsNullOrEmpty ( row [ "WeldingMethodCode" ] . ToString ( ) ) )
{
e . RowSelectable = false ;
2025-10-10 14:33:21 +08:00
}
;
2022-10-24 00:57:03 +08:00
}
2023-10-27 17:46:32 +08:00
protected void Grid1_RowCommand ( object sender , GridCommandEventArgs e )
{
if ( e . CommandName = = "ResetWpq" )
{
var weldJointId = e . RowID ;
var model = WeldJointService . GetWeldJointByWeldJointId ( weldJointId ) ;
if ( model ! = null )
{
model . WPQId = null ;
WeldJointService . UpdateWeldJoint ( model ) ;
List < Model . View_HJGL_WPQ > wpqList = BLL . WPQListServiceService . GetMatchWPQ ( model , this . CurrUser . LoginProjectId , drpUnit . SelectedValue ) ;
if ( wpqList ! = null )
{
Model . HJGL_WeldJoint newJot = new Model . HJGL_WeldJoint ( ) ;
Model . WPQ_WPQList wps = BLL . WPQListServiceService . GetWPQById ( wpqList . First ( ) . WPQId ) ;
newJot . WPQId = wps . WPQId ;
newJot . WeldJointId = model . WeldJointId ;
newJot . WeldingRod = wps . WeldingRod ;
newJot . WeldingWire = wps . WeldingWire ;
newJot . WeldingMethodId = wps . WeldingMethodId ;
newJot . GrooveTypeId = wps . GrooveType ;
newJot . PreTemperature = wps . PreTemperature ;
newJot . IsHotProess = wps . IsHotProess ;
newJot . MatchableWPQ = string . Join ( "," , wpqList . Select ( x = > x . WPQCode ) ) ;
BLL . WeldJointService . UpdateConWeldJoint ( newJot ) ;
}
BindGrid ( ) ;
ShowNotify ( "焊评已重置!" , MessageBoxIcon . Success ) ;
}
}
}
2024-09-18 10:48:34 +08:00
2022-09-05 16:36:31 +08:00
}
}