| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248 |
- 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;
- namespace Pur.require_plan
- {
- public partial class FrmPurPlanMat : FrmPmsBase
- {
- Boolean QClickCellOrQuery = false;//是否点击查询按钮或grid数据单元格,控制是否刷新右侧物料数据,true为不刷新
- DataTable dt_Purmatclass = null;
- private string QstrItemUnique = "";
- UltraTreeNode qUltraNode = null;
- public FrmPurPlanMat()
- {
- InitializeComponent();
- }
- public FrmPurPlanMat(OpeBase ob)
- {
- this.ob = ob;
- InitializeComponent();
- }
- public FrmPurPlanMat(OpeBase ob,string strUniQue)
- {
- this.ob = ob;
- QstrItemUnique = strUniQue;
- InitializeComponent();
- }
- /** 物料编码 */
- //Column("ITEM_CODE")
- private String itemCode;
- /** 物料描述 */
- //Column("ITEM_DESC")
- private String itemDesc;
- /** 物料名称 */
- //Column("ITEM_NAME")
- private String itemName;
- /** 物料英文名称 */
- //Column("ITEM_DESC_E")
- private String itemDescE;
- /** 物料检索(拼音助记码) */
- //Column("ITEM_IDX")
- private String itemIdx;
- /** 物料型号规格 */
- //Column("ITEM_SPEC")
- private String itemSpec;
- /** 物料材质 */
- //Column("ITEM_MODEL")
- private String itemModel;
- /** 采购单位(个、袋、桶) */
- //Column("ITEM_UOM")
- private String itemUom;
- /** 转换公式 */
- //Column("ITEM_UOM_FORMULA")
- private String itemUomFormula;
- /** 转换系数 */
- //Column("ITEM_UOM_CONEFFICIENT")
- private String itemUomConefficient;
- /** 库存单位 */
- //Column("WEIGHT_UNIT")
- private String weightUnit;
- /** 计价类型 */
- //Column("PRICE_TYPE")
- private String priceType;
- /** 计划价 */
- //Column("BUG_PRICE")
- private Double bugPrice;
- /** 最近采购价 */
- //Column("LAST_PRICE")
- private Double lastPrice;
- /** 月末移动平均价 */
- //Column("MONTH_END_AVG_PRICE")
- private Double monthEndAvgPrice;
- /** 币种代码 */
- //Column("CURRENCY_CODE")
- private String currencyCode;
- /** 最小采购数量 */
- //Column("MIN_QTY")
- private Double minQty;
- /** 批量数 */
- //Column("QTY_MULTIPLE")
- private Double qtyMultiple;
- /** 有效期 */
- //Column("LIFE_CYCLE")
- private Double lifeCycle;
- /** 采购管理部门代码 */
- private String buyerDeptCode;
- /** 采购管理部门描叙 */
- private String buyerDeptDesc;
- /** 采购管理科室代码 */
- private String buyerUnitCode;
- /** 采购管理科室描叙 */
- private String receiveType;
- private string itemAttrId;
- /// <summary>
- /// 属性编码
- /// </summary>
- public string ItemAttrId
- {
- set { itemAttrId = value; }
- get { return itemAttrId; }
- }
- private string tenantId;
- public string TenantId
- {
- get { return tenantId; }
- set { tenantId = value; }
- }
- private string tenantName;
- public string TenantName
- {
- get { return tenantName; }
- set { tenantName = value; }
- }
- private string itemAttr;
- /// <summary>
- /// 属性
- /// </summary>
- public string ItemAttr
- {
- set { itemAttr = value; }
- get { return itemAttr; }
- }
- private String buyerUnitDesc;
- public String getReceiveType()
- {
- return this.receiveType;
- }
- public String getBuyerDeptCode()
- {
- return this.buyerDeptCode;
- }
- public String getBuyerDeptDesc()
- {
- return this.buyerDeptDesc;
- }
- public String getBuyerUnitCode()
- {
- return this.buyerUnitCode;
- }
- public String getBuyerUnitDesc()
- {
- return this.buyerUnitDesc;
- }
- public String getItemCode()
- {
- return this.itemCode;
- }
- public String getItemDesc()
- {
- return this.itemDesc;
- }
- public String getItemName()
- {
- return this.itemName;
- }
- public String getItemDescE()
- {
- return this.itemDescE;
- }
- public String getItemIdx()
- {
- return this.itemIdx;
- }
- public String getItemSpec()
- {
- return this.itemSpec;
- }
- public String getItemModel()
- {
- return this.itemModel;
- }
- public String getItemUom()
- {
- return this.itemUom;
- }
- public String getItemUomFormula()
- {
- return this.itemUomFormula;
- }
- public String getItemUomConefficient()
- {
- return this.itemUomConefficient;
- }
- public String getWeightUnit()
- {
- return this.weightUnit;
- }
- public String getPriceType()
- {
- return this.priceType;
- }
- public Double getBugPrice()
- {
- return this.bugPrice;
- }
- public Double getLastPrice()
- {
- return this.lastPrice;
- }
- public Double getMonthEndAvgPrice()
- {
- return this.monthEndAvgPrice;
- }
- public String getCurrencyCode()
- {
- return this.currencyCode;
- }
- public Double getMinQty()
- {
- return this.minQty;
- }
- public Double getQtyMultiple()
- {
- return this.qtyMultiple;
- }
- public Double getLifeCycle()
- {
- return this.lifeCycle;
- }
- private String itemUseUom;
- public String getItemUseUom()
- {
- return this.itemUseUom;
- }
- private string itemUnique;
- /// <summary>
- /// 唯一值标识
- /// </summary>
- public string ItemUnique
- {
- get { return itemUnique; }
- set { itemUnique = value; }
- }
- //-----------------------------------------属性
- private string itemAttrCode;
- /// <summary>
- /// 属性编码
- /// </summary>
- public string ItemAttrCode
- {
- set { itemAttrCode = value; }
- get { return itemAttrCode; }
- }
- //-----------------------------------------标准编号
- private string itemStandardsId;
- /// <summary>
- /// 主键ID
- /// </summary>
- public string ItemStandardsId
- {
- set { itemStandardsId = value; }
- get { return itemStandardsId; }
- }
- private string standardsId;
- /// <summary>
- /// 采购标准ID
- /// </summary>
- public string StandardsId
- {
- set { standardsId = value; }
- get { return standardsId; }
- }
- private string standardsCode;
- /// <summary>
- /// 采购标准编号
- /// </summary>
- public string StandardsCode
- {
- set { standardsCode = value; }
- get { return standardsCode; }
- }
- //-------------------------------------------单位
- private string weightUnitCode;
- /// <summary>
- /// 库存单位编码
- /// </summary>
- public string WeightUnitCode
- {
- set { weightUnitCode = value; }
- get { return weightUnitCode; }
- }
- private string itemUomId;
- /// <summary>
- /// 主键
- /// </summary>
- public string ItemUomId
- {
- set { itemUomId = value; }
- get { return itemUomId; }
- }
- private string uomCode;
- /// <summary>
- /// 采购单位编码
- /// </summary>
- public string UomCode
- {
- set { uomCode = value; }
- get { return uomCode; }
- }
- private string uomName;
- /// <summary>
- /// 采购单位名称
- /// </summary>
- public string UomName
- {
- set { uomName = value; }
- get { return uomName; }
- }
- private string isBudgetCtrl;
- /// <summary>
- /// 是否定额控制(1是,0否)
- /// </summary>
- public string IsBudgetCtrl
- {
- set { isBudgetCtrl = value; }
- get { return isBudgetCtrl; }
- }
- private void FrmPurPlanMat_Load(object sender, EventArgs e)
- {
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0]);
- GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0]);
- GridHelper.SetExcludeColumnsActive(ultraGrid5.DisplayLayout.Bands[0]);
- GridHelper.SetExcludeColumnsActive(ultraGrid7.DisplayLayout.Bands[0]);
- GridHelper.SetExcludeColumnsActive(ultraGrid7.DisplayLayout.Bands[1],"Check");
- cmbNum.SelectedIndex = 0;
- string[] strItemUniques = QstrItemUnique.Split('@');
- if (strItemUniques[0].Trim() != "")
- {
- txt_wlbm.Text = strItemUniques[0].Trim();
- }
- GetPUR_MAT_Class();
- }
- /// <summary>
- /// 查询物料分类和物料
- /// </summary>
- public void GetPUR_MAT_Class()
- {
- //查询物料分类
-
- ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- PurmatclassEntity matclassEntity = new PurmatclassEntity();
- matclassEntity.UpdateUserid = this.UserInfo.GetDeptid();
- 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;
- if (ultraTextEditor3.Text.Trim() != "")
- {
- mat.DeleteName = ultraTextEditor3.Text;
- }
- mat.ItemName = txt_wlmc.Text;
- getMat(mat);
- //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatService","findAll",new object[] { });
- //GridHelper.CopyDataToDatatable(dt,dataTable1,true);
- }
- private void ultraButton3_Click(object sender, EventArgs e)
- {
- Pur.Entity.configureEntity.MatEntity mAT = new MatEntity();
- mAT.ItemCode = txt_wlbm.Text;
- mAT.ItemName = txt_wlmc.Text;
- mAT.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatService", "getMat", new object[] { mAT });
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- }
- /// <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());
- }
- }
- mat.UpdateUserid = this.UserInfo.GetDeptid();
- 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 dataTable1, true);//绑定物料分类表
- if (ultraGrid1.Rows.Count == 0)
- {
- dataTable6.Rows.Clear();
- dataTable7.Rows.Clear();
- dataTable8.Rows.Clear();//清空dataTable5之前先清空dataTable8
- dataTable5.Rows.Clear();
- }
- }
- /// <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 ultraButton1_Click_1(object sender, EventArgs e)
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择一条物料!");
- return;
- }
- this.itemCode = uge.Cells["itemCode"].Value.ToString();
- this.itemDesc = uge.Cells["itemDesc"].Value.ToString();
- this.itemName = uge.Cells["itemName"].Value.ToString();
- this.itemSpec = uge.Cells["itemSpec"].Value.ToString();
- this.itemModel = uge.Cells["itemModel"].Value.ToString();
- this.itemUom = uge.Cells["itemUom"].Value.ToString();
- this.itemUomConefficient = uge.Cells["itemUomConefficient"].Value.ToString();
- this.itemUomFormula = uge.Cells["itemUomFormula"].Value.ToString();
- this.weightUnit = uge.Cells["weightUnit"].Value.ToString();
- this.bugPrice = Convert.ToDouble(uge.Cells["bugPrice"].Value.ToString());
- this.priceType = uge.Cells["priceType"].Value.ToString();
- this.itemUseUom = uge.Cells["itemUseUom"].Value.ToString();
- this.buyerDeptCode = uge.Cells["buyerDeptCode"].Value.ToString();
- this.buyerDeptDesc = uge.Cells["buyerDeptDesc"].Value.ToString();
- this.buyerUnitCode = uge.Cells["buyerUnitCode"].Value.ToString();
- this.buyerUnitDesc = uge.Cells["buyerUnitDesc"].Value.ToString();
- this.receiveType = uge.Cells["receiveType"].Value.ToString();
- this.Close();
- return;
- }
- private void ultraButton2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- 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;//设置未点击
- }
- //Pur.Entity.configureEntity.MatEntity mAT = new MatEntity();
- //mAT.ItemCode = txt_wlbm.Text;
- //if (ultraTextEditor3.Text.Trim() != "")
- //{
- // mAT.DeleteName = ultraTextEditor3.Text;
- //}
- //mAT.ItemName = txt_wlmc.Text;
- //mAT.Validflag = "1";
- //getMat(mAT);
- }
- break;
- case "conFirmation":
- {
- ultraGrid7.UpdateData();
- UltraGridRow uge = null;
- UltraGridRow uge1 = ultraGrid1.ActiveRow;
- //UltraGridRow[] uge3 = new UltraGridRow[dataTable5.Rows.Count];//属性
- //ArrayList alAttr = new ArrayList();
- //string[] attr = new string[3];
- //foreach (UltraGridRow ugr in ultraGrid7.Rows)
- //{
- // if (ugr.HasParent() && (bool)ugr.Cells["Check"].Value)
- // {
- // attr[0] = ugr.Cells["itemAttr"].Value.ToString();
- // attr[1] = ugr.Cells["ITEMATTRCODE"].Value.ToString();
- // attr[2] = ugr.Cells["itemAttrId"].Value.ToString();
- // alAttr.Add(attr);
- // }
- //}
- UltraGridRow uge4 = ultraGrid4.ActiveRow;//标准编号
- UltraGridRow uge5 = ultraGrid5.ActiveRow;//单位
- if (uge5 != null)//采购单位
- {
- this.itemUomId = uge5.Cells["itemUomId"].Value.ToString();
- this.weightUnit = uge5.Cells["weightUnit"].Value.ToString();
- if (string.IsNullOrEmpty(this.weightUnit))
- {
- MessageUtil.ShowTips("所选物料采购单位的库存单位不能为空值,请重新选择!");
- return;
- }
- this.weightUnitCode = uge5.Cells["weightUnitCode"].Value.ToString();
- this.itemUomConefficient = uge5.Cells["itemUomConefficient"].Value.ToString();
- double b_itemUomConefficient = 0;
- if (!double.TryParse(this.itemUomConefficient = uge5.Cells["itemUomConefficient"].Value.ToString(), out b_itemUomConefficient))
- {
- MessageUtil.ShowTips("所选物料采购单位转换系数必须>0,请重新选择!");
- return;
- }
- if (!(b_itemUomConefficient > 0))
- {
- MessageUtil.ShowTips("所选物料采购单位转换系数必须>0,请重新选择!");
- return;
- }
- this.uomCode = uge5.Cells["uomCode"].Value.ToString();
- this.uomName = uge5.Cells["uomName"].Value.ToString();
- if (string.IsNullOrEmpty(this.uomName))
- {
- MessageUtil.ShowTips("所选物料采购单位的库存单位不能为空值,请重新选择!");
- return;
- }
- }
- else
- {
- MessageUtil.ShowTips("此物料没有维护单位信息,不能选择");
- return;
- }
- if (uge1 == null)
- {
- MessageUtil.ShowTips("没有数据可选!");
- return;
- }
- else
- {
- uge = uge1;
- this.itemCode = uge.Cells["itemCode"].Value.ToString();
- this.itemDesc = uge.Cells["itemDesc"].Value.ToString();
- this.itemName = uge.Cells["itemName"].Value.ToString();
- this.itemSpec = uge.Cells["itemSpec"].Value.ToString();
- this.itemModel = uge.Cells["itemModel"].Value.ToString();
- String strArcCode= uge.Cells["ARCCODE"].Value.ToString();
- PurmatclassEntity matclass1 = this.execute<PurmatclassEntity>("com.hnshituo.pur.configure.service.MatClassService", "findById", new object[] { strArcCode });
- if (matclass1 == null)
- {
- MessageUtil.ShowTips("未发现该物料分类信息!");
- return;
- }
- if (String.IsNullOrEmpty(matclass1.TenantId))
- {
- MessageUtil.ShowTips("该物料未维护审批流程!");
- return;
- }
- this.tenantId = matclass1.TenantId;
- this.TenantName = matclass1.TenantName;
- this.itemUomFormula = uge.Cells["itemUomFormula"].Value.ToString();
- this.weightUnit = uge.Cells["weightUnit"].Value.ToString();
- this.bugPrice = Convert.ToDouble(uge.Cells["bugPrice"].Value.ToString());
- this.priceType = uge.Cells["priceType"].Value.ToString();
- this.buyerDeptCode = uge.Cells["buyerDeptCode"].Value.ToString();
- this.buyerDeptDesc = uge.Cells["buyerDeptDesc"].Value.ToString();
- this.buyerUnitCode = uge.Cells["buyerUnitCode"].Value.ToString();
- this.buyerUnitDesc = uge.Cells["buyerUnitDesc"].Value.ToString();
- this.receiveType = uge.Cells["receiveType"].Value.ToString();
- this.isBudgetCtrl = uge.Cells["isBudgetCtrl"].Value.ToString();
- //this.itemUseUom = uge.Cells["itemUseUom"].Value.ToString();
- //this.itemUom = uge.Cells["itemUom"].Value.ToString();
- //this.itemUomConefficient = uge.Cells["itemUomConefficient"].Value.ToString();
- if (ultraTextEditor4.Text.Trim() != "")//属性
- {
- this.itemAttr = ultraTextEditor4.Text;//属性名称
- this.itemAttrCode = ultraTextEditor5.Text;//属性编码
- this.itemAttrId = ultraTextEditor6.Text;//属性Id
- //for (int i = 0; i < alAttr.Count; i++)
- //{
- // string[] strAttr = (string[])alAttr[i];
- // this.itemAttr += strAttr[0];
- // this.itemAttrCode += strAttr[1];
- // this.itemAttrId += strAttr[2];
- // if (i != alAttr.Count - 1)
- // {
- // this.itemAttr += ";";
- // this.itemAttrCode += ";";
- // this.itemAttrId += ";";
- // }
- //}
- }
- else
- {
- this.itemAttr = "";
- this.itemAttrCode = "";
- this.itemAttrId = "";
- }
- if (uge4 != null)//标准编号
- {
- this.itemStandardsId = uge4.Cells["itemStandardsId"].Value.ToString();
- this.standardsId = uge4.Cells["standardsId"].Value.ToString();
- this.standardsCode = uge4.Cells["standardsCode"].Value.ToString();
- }
- else
- {
- this.itemStandardsId = "";
- this.standardsId = "";
- this.standardsCode = "";
- }
- //所选物料唯一标识值
- this.ItemUnique = this.itemCode + "@" + this.itemAttrId + "@" + this.itemStandardsId + "@" + this.itemUomId;
- }
- 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)
- {
- getItemAttr();//获取物料属性
- getMatStandard();// 获取物料标准编号
- getMatUOM();// 获取单位转换
- string[] strItemUniques = QstrItemUnique.Split('@');
- if (QstrItemUnique != "")
- {
- QClickCellOrQuery = true;//不刷新右侧物料数据
- if (strItemUniques.Length == 4)
- {
- //if(strItemUniques[0].Trim()!="")
- //comm.doActiveSelRow(ultraGrid1, "ITEMCODE", strItemUniques[0]);//激活物料
- if (strItemUniques[2].Trim() != "")
- comm.doActiveSelRow(ultraGrid4, "itemStandardsId", strItemUniques[2]);//激活标准编号
- if (strItemUniques[3].Trim() != "")
- comm.doActiveSelRow(ultraGrid5, "itemUomId", strItemUniques[3]);//激活采购单位
- //选中属性
- if (strItemUniques[1].Trim() != "")
- {
- //显示所选属性
- strItemUniques[1] += ";";
- strItemUniques[1] = ";" + strItemUniques[1];
- for (int i = 0; i < ultraGrid7.Rows.Count; i++)
- {
- foreach (UltraGridRow ugr in ultraGrid7.Rows[i].ChildBands[0].Rows)
- {
- if (strItemUniques[1].Contains(ugr.Cells["itemAttrId"].Value.ToString()))
- {
- ugr.Cells["Check"].Value = true;
- ultraTextEditor4.Text += ultraGrid7.Rows[i].Cells["itemAttrClassName"].Value.ToString() + ":" + ugr.Cells["itemAttr"].Value.ToString() + "; ";
- ultraTextEditor5.Text += ugr.Cells["ITEMATTRCODE"].Value.ToString() + ";";
- ultraTextEditor6.Text += ugr.Cells["itemAttrId"].Value.ToString() + ";";
- }
- }
- }
- if (ultraTextEditor4.Text != "")
- {
- ultraTextEditor4.Text = ultraTextEditor4.Text.Remove(ultraTextEditor4.Text.Length - 2);
- ultraTextEditor5.Text = ultraTextEditor5.Text.Remove(ultraTextEditor5.Text.Length - 1);
- ultraTextEditor6.Text = ultraTextEditor6.Text.Remove(ultraTextEditor6.Text.Length - 1);
- }
- }
- }
- QstrItemUnique = "";
- QClickCellOrQuery = false;
- //激活右侧节点
- UltraTreeNode uttNode = ulTreeMat.GetNodeByKey(ultraGrid1.ActiveRow.Cells["ARCCODE"].Value.ToString());
- if (ulTreeMat.ActiveNode == uttNode)
- {
- return;
- }
- ulTreeMat.CollapseAll();
- QClickCellOrQuery = true;
- ulTreeMat.ActiveNode = uttNode;
- if (uttNode == null)
- {
- MessageUtil.ShowTips("物料名称:" + ultraGrid1.ActiveRow.Cells["ITEMNAME"].Value.ToString() + " 未找到相应的分类:" + ultraGrid1.ActiveRow.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;//设置未点击
- }
- }
- /// <summary>
- /// 获取物料属性
- /// </summary>
- /// <param name="parm"></param>
- private void getItemAttr()
- {
- //清空所选属性
- ultraTextEditor4.Text = "";
- ultraTextEditor5.Text = "";
- ultraTextEditor6.Text = "";
- //查询属性父表
- dataTable8.Rows.Clear(); //清空子表
- PurMatAttrsEntity MatAttrsEntity = new PurMatAttrsEntity();
- MatAttrsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatAttrsService", "getMatAttrClass", new object[] { MatAttrsEntity });
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable5, true);//获取物料属性
- //查询属性字表
- //dataTable5.Rows.Clear();
- Dictionary<string, object> param = new Dictionary<string, object>();
- param.Add("ItemCode", ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());
- param.Add("Validflag", "1");
- DataTable dt_mat = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatAttrsService", "find", new object[] { param, 0, 0 });
- //按是否常用排序
- //if (dt_mat.Rows.Count > 1)
- //{
- // dt_mat.DefaultView.Sort = "ISDEFAULT DESC";
- // dt_mat = dt_mat.DefaultView.ToTable();
- //}
- for (int i = 0; i < dt_mat.Rows.Count; i++)
- {
- if (dt_mat.Rows[i]["ISDEFAULT"].ToString() == "1")
- {
- dt_mat.Rows[i]["ISDEFAULT"] = "是";
- }
- else if (dt_mat.Rows[i]["ISDEFAULT"].ToString() == "0")
- {
- dt_mat.Rows[i]["ISDEFAULT"] = "否";
- }
- }
- GridHelper.CopyDataToDatatable(ref dt_mat, ref dataTable8, true);//获取物料属性
- }
- /// <summary>
- /// 获取物料标准编号
- /// </summary>
- private void getMatStandard()
- {
- dataTable6.Rows.Clear();
- if (ultraGrid1.ActiveRow != null)
- {
- PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
- PurMatStandards_Entity.Validflag = "1";
- PurMatStandards_Entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- DataTable dt_matStandards = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatStandardsService", "find", new object[] { PurMatStandards_Entity, 0, 0 });
- //按是否常用排序
- if (dt_matStandards.Rows.Count > 1)
- {
- dt_matStandards.DefaultView.Sort = "ISDEFAULT DESC";
- dt_matStandards = dt_matStandards.DefaultView.ToTable();
- }
- for (int i = 0; i < dt_matStandards.Rows.Count; i++)
- {
- if (dt_matStandards.Rows[i]["ISDEFAULT"].ToString() == "1")
- {
- dt_matStandards.Rows[i]["ISDEFAULT"] = "是";
- }
- else if (dt_matStandards.Rows[i]["ISDEFAULT"].ToString() == "0")
- {
- dt_matStandards.Rows[i]["ISDEFAULT"] = "否";
- }
- }
- GridHelper.CopyDataToDatatable(ref dt_matStandards, ref dataTable6, true);//绑定物料规格
- }
- }
- /// <summary>
- /// 获取单位转换
- /// </summary>
- private void getMatUOM()
- {
- dataTable7.Rows.Clear();
- if (ultraGrid1.ActiveRow != null)
- {
- PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
- MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- MatUomsEntity.Validflag = "1";
- DataTable dt_matUOM = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatUomsService", "find", new object[] { MatUomsEntity, 0, 0 });
- //按是否常用排序
- if (dt_matUOM.Rows.Count > 1)
- {
- dt_matUOM.DefaultView.Sort = "ISDEFAULT DESC";
- dt_matUOM = dt_matUOM.DefaultView.ToTable();
- }
- for (int i = 0; i < dt_matUOM.Rows.Count; i++)
- {
- if (dt_matUOM.Rows[i]["ISDEFAULT"].ToString() == "1")
- {
- dt_matUOM.Rows[i]["ISDEFAULT"] = "是";
- }
- else if (dt_matUOM.Rows[i]["ISDEFAULT"].ToString() == "0")
- {
- dt_matUOM.Rows[i]["ISDEFAULT"] = "否";
- }
- }
- GridHelper.CopyDataToDatatable(ref dt_matUOM, ref dataTable7, true);//绑定物料规格
- }
- }
- /// <summary>
- /// 选择属性
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid3_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- ultraGrid3.UpdateData();
- if (e.Cell.Column.Key == "Check")
- {
- //设置单选
- if (e.Cell.Row.HasParent() && (bool)e.Cell.Value)
- {
- foreach (UltraGridRow ugr in e.Cell.Row.ParentRow.ChildBands[0].Rows)
- {
- if (ugr != e.Cell.Row)
- {
- ugr.Cells["Check"].Value = false;
- }
- }
- }
- }
- }
- /// <summary>
- /// 选择标准编号
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid4_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- ultraGrid4.UpdateData();
- if (e.Cell.Column.Key == "Check")
- {
- if ((bool)e.Cell.Value)
- {
- foreach (UltraGridRow ugr in ultraGrid4.Rows)
- {
- if (ugr != e.Cell.Row)
- {
- ugr.Cells["Check"].Value = false;
- }
- }
- }
- }
- }
- /// <summary>
- /// 选择采购标准
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid5_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- ultraGrid5.UpdateData();
- if (e.Cell.Column.Key == "Check")
- {
- if ((bool)e.Cell.Value)
- {
- foreach (UltraGridRow ugr in ultraGrid5.Rows)
- {
- if (ugr != e.Cell.Row)
- {
- ugr.Cells["Check"].Value = false;
- }
- }
- }
- }
- }
- /// <summary>
- /// 选择属性
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- FrmPopAttrs frm = new FrmPopAttrs(this.ob);
- frm.ShowDialog();
- if (frm.QstrItemAttr == "")
- {
- return;
- }
- ultraTextEditor1.Text = frm.QstrItemAttr;
- ultraTextEditor2.Text = frm.QstrItemAttrCode;
- }
- /// <summary>
- /// 添加属性
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraButton1_Click(object sender, EventArgs e)
- {
- if (MessageUtil.ShowYesNoAndQuestion("确认添加属性?").Equals(DialogResult.Yes))
- {
- if (ultraTextEditor2.Text.Trim() == "")
- {
- MessageUtil.ShowTips("请选择属性");
- return;
- }
- PurMatAttrsEntity mat_entity = new PurMatAttrsEntity();
- mat_entity.ItemAttr = ultraTextEditor2.Text.Trim();//属性名称
- mat_entity.Validflag = "1";
- if (isExsitRow("com.hnshituo.pur.configure.service.MatAttrsService", mat_entity) > 0)
- {
- MessageUtil.ShowTips("添加失败 数据库中已经存在所选物料相同的属性编码");
- return;
- }
- mat_entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- mat_entity.ItemAttrCode = ultraTextEditor1.Text;//属性编码
- mat_entity.ItemAttrId = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getMaxSeq", new object[] { "PUR_MAT_ATTRS", "ITEM_ATTR_ID" });//属性ID
- mat_entity.IsDefault = "0";//是否常用
- mat_entity.CreateTime = System.DateTime.Now;//创建时间
- mat_entity.CreateName = UserInfo.GetUserName();
- mat_entity.CreateUserid = UserInfo.GetUserID();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.MatAttrsService", "doInsert", new object[] { mat_entity });//添加操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功!");
- getItemAttr();//查询规格
- ConfigureClassCommon.doActiveSelRow(ultraGrid3, "ITEMATTRID", mat_entity.ItemAttrId);//激活当前行
- }
- }
- /// <summary>
- /// 判断数据库中是否存在相同的列
- /// </summary>
- /// <param name="strJavaPackName"></param>
- /// <param name="o"></param>
- /// <returns>true存在</returns>
- public int isExsitRow(string strJavaPackName, object o)
- {
- DataTable dt = this.execute<DataTable>(strJavaPackName, "find", new object[] { o, 0, 0 });
- if (dt != null && dt.Rows.Count > 0)//存在相同的行
- {
- return dt.Rows.Count;
- }
- return 0;
- }
- /// <summary>
- /// 选择属性
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid7_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- ultraGrid7.UpdateData();
- if (e.Cell.Column.Key == "Check")
- {
- if ((bool)e.Cell.Value)
- {
- foreach (UltraGridRow ugr in e.Cell.Row.ParentRow.ChildBands[0].Rows)
- {
- if (ugr != e.Cell.Row)
- {
- ugr.Cells["Check"].Value = false;
- }
- }
- }
- //显示所选属性
- ultraTextEditor4.Text = "";
- ultraTextEditor5.Text = "";
- ultraTextEditor6.Text = "";
- for (int i = 0; i < ultraGrid7.Rows.Count; i++)
- {
- foreach (UltraGridRow ugr in ultraGrid7.Rows[i].ChildBands[0].Rows)
- {
- if ((bool)ugr.Cells["Check"].Value)
- {
- ultraTextEditor4.Text += ultraGrid7.Rows[i].Cells["itemAttrClassName"].Value.ToString() + ":" + ugr.Cells["itemAttr"].Value.ToString() + "; ";
- ultraTextEditor5.Text += ugr.Cells["ITEMATTRCODE"].Value.ToString() + ";";
- ultraTextEditor6.Text += ugr.Cells["itemAttrId"].Value.ToString() + ";";
- }
- }
- }
- if (ultraTextEditor4.Text != "")
- {
- ultraTextEditor4.Text = ultraTextEditor4.Text.Remove(ultraTextEditor4.Text.Length - 2);
- ultraTextEditor5.Text = ultraTextEditor5.Text.Remove(ultraTextEditor5.Text.Length - 1);
- ultraTextEditor6.Text = ultraTextEditor6.Text.Remove(ultraTextEditor6.Text.Length - 1);
- }
- }
- }
- /// <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;//设置未点击
- }
- private void ultraTextEditor4_MouseHover(object sender, EventArgs e)
- {
- }
- private void ultraTextEditor4_MouseMove(object sender, MouseEventArgs e)
- {
- }
- private void ultraTextEditor4_MouseEnter(object sender, EventArgs e)
- {
- UltraToolTipInfo utti = new UltraToolTipInfo(ultraTextEditor4.Text, ToolTipImage.Info, "所选属性:", DefaultableBoolean.True);
- ultraToolTipManager1.SetUltraToolTip(ultraTextEditor4, utti);
- ultraToolTipManager1.AutoPopDelay = 10000;
- }
- }
- }
|