| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- 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 Infragistics.Win.UltraWinGrid;
- using Infragistics.Win;
- using CoreFS.CA06;
- using Pur.Entity;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm;
- using Core.Mes.Client.Comm.Tool;
- using Pur.Entity.configureEntity;
- using Infragistics.Win.UltraWinTree;
- using Core.Mes.Client.Comm.Server;
- using Pur.Pop_upWindow;
- using com.hnshituo.pur.vo;
- using Pur.configure;
- using System.Collections;
- using Infragistics.Win.UltraWinToolTip;
- using Pur.require_plan;
- using Infragistics.Win.UltraWinEditors;
- namespace Pur.Pop_upWindow
- {
- public partial class frmPopMatSelect : FrmPmsBase
- {
- String selectType = "0";//0:全选,1:单个选
- private void frmPopMatSelect_Load(object sender, EventArgs e)
- {
- //初始化
-
- cmbNum.SelectedIndex = 0;
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { "Check" });
- if (selectType == "1")
- {
- GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], new string[] { "Check" });
- }
- //查询物料分类树
- GetPUR_MAT_Class();
- }
- public frmPopMatSelect(OpeBase ob)
- {
- this.ob = ob;
- InitializeComponent();
- }
- public frmPopMatSelect(OpeBase ob,String strType)
- {
- this.selectType = strType;
- this.ob = ob;
- InitializeComponent();
- }
- Boolean QClickCellOrQuery = false;//是否点击查询按钮或grid数据单元格,控制是否刷新右侧物料数据,true为不刷新
- DataTable dt_Purmatclass = null;
- private string QstrItemUnique = "";
- UltraTreeNode qUltraNode = null;
- public ArrayList List_item=new ArrayList();
- public String selectedItemCode="";
- public String SelectedItemName="";
- public string tips="0";
- /// <summary>
- /// 查询物料分类和物料
- /// </summary>
- public void GetPUR_MAT_Class()
- {
- //查询物料分类
- PurmatclassEntity matclassEntity = new PurmatclassEntity();
- matclassEntity.Validflag="1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatClassService", "getMatClass", new object[] { matclassEntity });
- dt_Purmatclass = dt;
- getultree(dt);//绑定物料分类表
- //查询物料
- MatEntity mat = new MatEntity();
- mat.Validflag = "1";
- //物料分类
- if (checkBox1.Checked)
- {
- mat.UpdateName = txt_ARC_CODE.Text;
- }
- mat.ItemCode = txt_wlbm.Text;
- mat.DeleteName = txt_wlmc.Text;
- getMat(mat);
- }
- /// <summary>
- /// 获取物料分类树形结构
- /// </summary>
- public void getultree(DataTable dt)
- {
- ulTreeMat.Nodes.Clear();
- if (dt == null || dt.Rows.Count < 1)
- {
- return;
- }
- dt_Purmatclass = dt;//保存物料分类全局变量
- DataTable dt_A = new DataTable();//物料分类
- //筛选出根节点
- DataRow[] rows = dt.Select("PARENTCODE='' or PARENTCODE is null");
- dt_A = dt.Clone(); //克隆A的结构
- foreach (DataRow row in rows)
- {
- dt_A.ImportRow(row);//复制行数据
- }
- //添加物料大类
- for (int j = 0; j < dt_A.Rows.Count; j++)
- {
- UltraTreeNode Ultnode = ulTreeMat.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
- getChildNodes(Ultnode);
- }
- }
- /// <summary>
- /// 查询物料
- /// </summary>
- private void getMat(MatEntity mat)
- {
- if (mat != null)
- {
- if (cmbNum.Value != null && cmbNum.Value.ToString() != "")
- {
- mat.ItemUomConefficient = double.Parse(cmbNum.Value.ToString());
- }
- }
- DataTable dt_mat = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatService", "getMat", new object[] { mat });
- dataTable1.Rows.Clear();
- GridHelper.CopyDataToDatatable(ref dt_mat, ref dataTable2, true);//绑定物料分类表
- }
- /// <summary>
- /// 递归查询父节点下的所有子节点
- /// </summary>
- /// <param name="Tnode"></param>
- public void getChildNodes(UltraTreeNode Tnode)
- {
- DataTable dt_A = dt_Purmatclass.Clone();//物料分类
- DataRow[] rows = dt_Purmatclass.Select("PARENTCODE='" + Tnode.Key + "'");
- foreach (DataRow row in rows)
- {
- dt_A.ImportRow(row);//复制行数据
- }
- //添加物料分类
- for (int j = 0; j < dt_A.Rows.Count; j++)
- {
- UltraTreeNode Ultnode = Tnode.Nodes.Add(dt_A.Rows[j]["BASECODE"].ToString(), dt_A.Rows[j]["BASENAME"].ToString());
- getChildNodes(Ultnode);//利用递归将当前节点的子节点添加进去
- }
- }
- private void ulTreeMat_AfterActivate(object sender, NodeEventArgs e)
- {
- if (!QClickCellOrQuery)//如果不是点击查询按钮或单击grig行数据,刷新右侧数据
- {
- MatEntity eMat = new MatEntity();
- ulTreeMat.ActiveNode.Expanded = true;
- qUltraNode = ulTreeMat.ActiveNode;
- eMat.ArcCode = qUltraNode.Key;
- eMat.Validflag = "1";
- getMat(eMat);
- }
- txt_ARC_CODE.Text = ulTreeMat.ActiveNode.Key;
- txt_ARC_ITEM.Text = ulTreeMat.ActiveNode.Text;
- }
- private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key.ToString())
- {
- case "Query":
- {
- QClickCellOrQuery = true;
- GetPUR_MAT_Class();
- if (ultraGrid1.Rows.Count > 0)
- {
- ulTreeMat.CollapseAll();
- UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(ultraGrid1.Rows[0].Cells["ARCCODE"].Value.ToString());
- ulTreeMat.ActiveNode = uttNode;
- if (uttNode == null)
- {
- MessageUtil.ShowTips("物料名称:" + ultraGrid1.Rows[0].Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + ultraGrid1.Rows[0].Cells["ARCCODE"].Value.ToString());
- }
- else
- {
- while (ulTreeMat.ActiveNode != uttNode)
- {
- ulTreeMat.ActiveNode = uttNode;
- }
- uttNode.Expanded = true;
- //展开分类
- while (uttNode.Parent != null)
- {
- uttNode = uttNode.Parent;
- uttNode.Expanded = true;
- }
- }
- QClickCellOrQuery = false;//设置未点击
- }
- }
- break;
- case "conFirmation":
- {
- if (selectType == "1")
- {
- selectedItemCode = ultraGrid1.ActiveRow.GetCellValue("itemCode").ToString().Trim();
- SelectedItemName = ultraGrid1.ActiveRow.GetCellValue("itemName").ToString().Trim();
- tips = "1";
- this.Close();
- return;
- }
- else
- {
- ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> checkRows = ultraGrid1.Rows.AsQueryable().Where("Check = 'True' ");
- if (checkRows.Count() <= 0)
- {
- MessageUtil.ShowTips("请选择物料!");
- return;
- }
- else
- {
- foreach (UltraGridRow row in checkRows)
- {
- MatEntity mat = new MatEntity();
- String itemCode = row.GetCellValue("itemCode").ToString().Trim();
- mat.ItemCode = itemCode;
- String itemName = row.GetCellValue("itemName").ToString().Trim();
- mat.ItemName = itemName;
- List_item.Add(mat);
- }
- }
- if (List_item.Count <= 0)
- {
- MessageUtil.ShowTips("请选择物料!");
- return;
- }
- tips = "1";
- this.Close();
- return;
- }
- }
- case "ESC":
- {
- this.Close();
- }
- break;
- }
- }
-
-
- /// <summary>
- /// 激活物料
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- //激活之前选中项
- string[] strItemUniques = QstrItemUnique.Split('@');
- if (QstrItemUnique != "")
- {
- QClickCellOrQuery = true;//不刷新右侧物料数据
- if (strItemUniques.Length == 4)
- {
- //选中属性
- if (strItemUniques[1].Trim() != "")
- {
- //显示所选属性
- strItemUniques[1] += ";";
- strItemUniques[1] = ";" + strItemUniques[1];
- }
- }
- QstrItemUnique = "";
- QClickCellOrQuery = false;
- }
- }
- /// <summary>
- /// 单击物料单元格
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
- {
- UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(e.Cell.Row.Cells["ARCCODE"].Value.ToString());
- if (ulTreeMat.ActiveNode == uttNode)
- {
- return;
- }
- ulTreeMat.CollapseAll();
- QClickCellOrQuery = true;
- ulTreeMat.ActiveNode = uttNode;
- if (uttNode == null)
- {
- MessageUtil.ShowTips("物料名称:" + e.Cell.Row.Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + e.Cell.Row.Cells["ARCCODE"].Value.ToString());
- }
- else
- {
- while (ulTreeMat.ActiveNode != uttNode)
- {
- ulTreeMat.ActiveNode = uttNode;
- }
- uttNode.Expanded = true;
- //展开分类
- while (uttNode.Parent != null)
- {
- uttNode = uttNode.Parent;
- uttNode.Expanded = true;
- }
- }
- QClickCellOrQuery = false;//设置未点击
- }
- }
- }
|