You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
189 lines
6.7 KiB
189 lines
6.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using QMAPP.MD.Entity;
|
|
using QMAPP.Entity;
|
|
|
|
namespace QMAPP.WinForm.Forms.Injection
|
|
{
|
|
public partial class MaterialTreeForm : Form
|
|
{
|
|
public MaterialTreeForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MaterialTreeForm_Load(object sender, EventArgs e)
|
|
{
|
|
GetMaterialTree();
|
|
}
|
|
|
|
#region 物料类型-树
|
|
public void GetMaterialClassTree()
|
|
{
|
|
QMAPP.ServicesAgent.ServiceAgent wcfAgent = ClientContext.GetServiceAgent();
|
|
try
|
|
{
|
|
var classresult = wcfAgent.InvokeServiceFunction<DataResult<List<MaterialClass>>>
|
|
("MaterialBLL_GetMaterialClassList", new MaterialClass()).Result;
|
|
foreach (MaterialClass item in classresult.Where(p => string.IsNullOrWhiteSpace(p.UP_MATERIAL_TYPE_CODE)).OrderBy(p => p.SEQ_NUM))
|
|
{
|
|
var subnode = new TreeNode { Name = item.MATERIAL_TYPE_CODE, Text = item.MATERIAL_TYPE_NAME };
|
|
AppendTree(subnode, classresult);
|
|
treeView1.Nodes.Add(subnode);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
private void AppendTree(TreeNode node, List<MaterialClass> mclasslist)
|
|
{
|
|
foreach (var mclass in mclasslist.Where(p => string.Equals(node.Name, p.UP_MATERIAL_TYPE_CODE)).OrderBy(p => p.SEQ_NUM))
|
|
{
|
|
var subnode = new TreeNode { Name = mclass.MATERIAL_TYPE_CODE, Text = mclass.MATERIAL_TYPE_NAME };
|
|
AppendTree(subnode, mclasslist);
|
|
node.Nodes.Add(subnode);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 物料号-树
|
|
public void GetMaterialTree()
|
|
{
|
|
QMAPP.ServicesAgent.ServiceAgent wcfAgent = ClientContext.GetServiceAgent();
|
|
try
|
|
{
|
|
var materialResult = wcfAgent.InvokeServiceFunction<List<Material>>
|
|
("MaterialBLL_GetMaterialList", new Material());
|
|
|
|
MaterialClass materialclass = new MaterialClass();
|
|
materialclass.MaterialAttributes = "('1','')";
|
|
var classresult = wcfAgent.InvokeServiceFunction<DataResult<List<MaterialClass>>>
|
|
("MaterialBLL_GetMaterialClassList", materialclass).Result;
|
|
foreach (MaterialClass item in classresult.Where(p => string.IsNullOrWhiteSpace(p.UP_MATERIAL_TYPE_CODE)).OrderBy(p => p.SEQ_NUM))
|
|
{
|
|
var subnode = new TreeNode { Name = item.MATERIAL_TYPE_CODE, Text = item.MATERIAL_TYPE_NAME };
|
|
AppendTree(subnode, classresult, materialResult);
|
|
if (subnode.Nodes.Count > 0)
|
|
{
|
|
treeView1.Nodes.Add(subnode);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 追加树节点
|
|
/// </summary>
|
|
/// <param name="node"></param>
|
|
/// <param name="mclasslist"></param>
|
|
/// <param name="materiallist"></param>
|
|
private void AppendTree(TreeNode node, List<MaterialClass> mclasslist, List<Material> materiallist)
|
|
{
|
|
foreach (var mclass in mclasslist.Where(p => string.Equals(node.Name, p.UP_MATERIAL_TYPE_CODE)).OrderBy(p => p.SEQ_NUM))
|
|
{
|
|
var subnode = new TreeNode { Name = mclass.MATERIAL_TYPE_CODE, Text = mclass.MATERIAL_TYPE_NAME };
|
|
AppendTree(subnode, mclasslist, materiallist);
|
|
if (subnode.Nodes.Count > 0)
|
|
{
|
|
node.Nodes.Add(subnode);
|
|
}
|
|
}
|
|
foreach (var material in materiallist.Where(p => string.Equals(node.Name, p.MATERIAL_TYPE_CODE)).OrderBy(p => p.MATERIAL_CODE))
|
|
{
|
|
var subnode = new TreeNode { Name = material.MATERIAL_CODE, Text = material.MATERIAL_CODE + "/" + material.MATERIAL_NAME };
|
|
node.Nodes.Add(subnode);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 选中节点
|
|
/// <summary>
|
|
/// 选中节点
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
//private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
|
//{
|
|
// if (treeView1.SelectedNode != null)
|
|
// {
|
|
// if (treeView1.SelectedNode.Nodes.Count == 0)
|
|
// {
|
|
// txtMaterialCode.Text = treeView1.SelectedNode.Name;
|
|
// textMaterialName.Text = treeView1.SelectedNode.Text.Substring(treeView1.SelectedNode.Text.LastIndexOf("/") + 1);
|
|
// this.treeView1.Visible = false;
|
|
// this.DGView.Visible = true;
|
|
// }
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 取消
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 确认
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
if (treeView1.SelectedNode != null)
|
|
{
|
|
if (treeView1.SelectedNode.Nodes.Count == 0)
|
|
{
|
|
MaterialCode = treeView1.SelectedNode.Name;
|
|
MaterialName = treeView1.SelectedNode.Text.Substring(treeView1.SelectedNode.Text.LastIndexOf("/") + 1);
|
|
string info= treeView1.SelectedNode.FullPath;
|
|
MainType = info.Contains("门板");
|
|
if (!MainType)
|
|
{
|
|
MainType = info.Contains("左");
|
|
if (!MainType)
|
|
{
|
|
MainType = info.Contains("右");
|
|
}
|
|
}
|
|
//提示
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public bool MainType { get; set; }
|
|
|
|
public string MaterialCode { get; set; }
|
|
|
|
public string MaterialName { get; set; }
|
|
}
|
|
}
|
|
|