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; /// /// 属性编码 /// 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; /// /// 属性 /// 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; /// /// 唯一值标识 /// public string ItemUnique { get { return itemUnique; } set { itemUnique = value; } } //-----------------------------------------属性 private string itemAttrCode; /// /// 属性编码 /// public string ItemAttrCode { set { itemAttrCode = value; } get { return itemAttrCode; } } //-----------------------------------------标准编号 private string itemStandardsId; /// /// 主键ID /// public string ItemStandardsId { set { itemStandardsId = value; } get { return itemStandardsId; } } private string standardsId; /// /// 采购标准ID /// public string StandardsId { set { standardsId = value; } get { return standardsId; } } private string standardsCode; /// /// 采购标准编号 /// public string StandardsCode { set { standardsCode = value; } get { return standardsCode; } } //-------------------------------------------单位 private string weightUnitCode; /// /// 库存单位编码 /// public string WeightUnitCode { set { weightUnitCode = value; } get { return weightUnitCode; } } private string itemUomId; /// /// 主键 /// public string ItemUomId { set { itemUomId = value; } get { return itemUomId; } } private string uomCode; /// /// 采购单位编码 /// public string UomCode { set { uomCode = value; } get { return uomCode; } } private string uomName; /// /// 采购单位名称 /// public string UomName { set { uomName = value; } get { return uomName; } } private string isBudgetCtrl; /// /// 是否定额控制(1是,0否) /// 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(); } /// /// 查询物料分类和物料 /// 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("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("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("com.hnshituo.pur.configure.service.MatService", "getMat", new object[] { mAT }); GridHelper.CopyDataToDatatable(dt, dataTable1, true); } /// /// 获取物料分类树形结构 /// 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); } } /// /// 查询物料 /// 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("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(); } } /// /// 递归查询父节点下的所有子节点 /// /// 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("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; } } /// /// 激活物料 /// /// /// 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;//设置未点击 } } /// /// 获取物料属性 /// /// 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("com.hnshituo.pur.configure.service.MatAttrsService", "getMatAttrClass", new object[] { MatAttrsEntity }); GridHelper.CopyDataToDatatable(ref dt, ref dataTable5, true);//获取物料属性 //查询属性字表 //dataTable5.Rows.Clear(); Dictionary param = new Dictionary(); param.Add("ItemCode", ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString()); param.Add("Validflag", "1"); DataTable dt_mat = this.execute("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);//获取物料属性 } /// /// 获取物料标准编号 /// 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("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);//绑定物料规格 } } /// /// 获取单位转换 /// 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("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);//绑定物料规格 } } /// /// 选择属性 /// /// /// 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; } } } } } /// /// 选择标准编号 /// /// /// 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; } } } } } /// /// 选择采购标准 /// /// /// 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; } } } } } /// /// 选择属性 /// /// /// 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; } /// /// 添加属性 /// /// /// 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("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("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);//激活当前行 } } /// /// 判断数据库中是否存在相同的列 /// /// /// /// true存在 public int isExsitRow(string strJavaPackName, object o) { DataTable dt = this.execute(strJavaPackName, "find", new object[] { o, 0, 0 }); if (dt != null && dt.Rows.Count > 0)//存在相同的行 { return dt.Rows.Count; } return 0; } /// /// 选择属性 /// /// /// 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); } } } /// /// 单击物料单元格 /// /// /// 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; } } }