1.生产任务单界面设计如下:
要求实现功能如下:
1.生产任务单可以由销售订单选取而产生。
2.生产任务单可以下推领料。生产完后可以下推成品入库。
3.自动根据BOM计算此次生产所需要的原料。
代码如下:
客户端代码:
/// <summary> /// 生产任务单 /// </summary> class Product : Jeez.MulEntityInput.BaseBillUI { //控件声明定义 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txWLDW;//往来单位 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txOrg;//组织机构 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txDept;//部门 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txEmployee;//业务员 private Jeez.Control.JeezUltraTextBox.JeezUltraTextBox txBibie;//币别 private Jeez.Control.JeezNumberTextBox.JeezNumberTextBox txRat;//汇率 private Jeez.Control.JeezUltraCalendarCombo.JeezUltraCalendarCombo dtDate;//日期 private Jeez.Control.JeezGrid.JeezGrid gridZY;//明细grid private Jeez.Control.JeezUltraTabControl.JeezUltraTabControl pagecontrol1 = null;//下方页框控件 private Jeez.Control.JeezGrid.JeezGrid gridKucun;//库存 private Jeez.Control.JeezGrid.JeezGrid gridNeed;//库存 private bool isLoading = true; //定义几个初始化常见的值 private bool isSelect = true;//是否选单 public static int j = 0;//因为导入可能连续导入所以用来计数,而且还有可能 /// <summary> /// 加载控件,以及控件相关事件定义 /// </summary> /// <returns></returns> public override bool LoadUI() { bool b = base.LoadUI(); if (b) { txWLDW = base.GetControlByName("JeezTextBox5") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txOrg = base.GetControlByName("JeezTextBox3") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txDept = base.GetControlByName("JeezTextBox4") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txEmployee = base.GetControlByName("JeezTextBox6") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txBibie = base.GetControlByName("JeezTextBox8") as Jeez.Control.JeezUltraTextBox.JeezUltraTextBox; txRat = base.GetControlByName("JeezNumberTextBox1") as Jeez.Control.JeezNumberTextBox.JeezNumberTextBox; dtDate = base.GetControlByName("JeezCalendarCombo1") as Jeez.Control.JeezUltraCalendarCombo.JeezUltraCalendarCombo; pagecontrol1 = base.GetControlByName("JeezTabControl1") as Jeez.Control.JeezUltraTabControl.JeezUltraTabControl; gridZY = base.GetControlByName("JeezGrid1") as Jeez.Control.JeezGrid.JeezGrid; gridKucun = base.GetControlByName("gridKucun") as Jeez.Control.JeezGrid.JeezGrid; gridNeed = base.GetControlByName("JeezGrid2") as Jeez.Control.JeezGrid.JeezGrid; pagecontrol1.SelectedTabChanged += new Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventHandler(pagecontrol1_SelectedTabChanged); gridZY.AfterCellUpdate += new CellEventHandler(gridZY_AfterCellUpdate); } return b; } /// <summary> /// 更改Grid的构建方式 /// </summary> /// <param name="CTL"></param> /// <param name="EOL"></param> /// <param name="IsDeleteChildEntity"></param> protected override void FillGridDataToEntity(Jeez.ControlManager.ControlHelper CTL, EntityObjectList EOL, bool IsDeleteChildEntity) { base.FillGridDataToEntity(CTL, EOL, false); } /// <summary> /// 设置默认值 /// </summary> void InitByDefineOrder() { } /// <summary> /// 页框轮换点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void pagecontrol1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (e.Tab.Index == 2) { //如果点的是第二个页框,用来显示即时库存 if (gridKucun != null) { StringBuilder strMatID = new StringBuilder(); strMatID.Append("(0"); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridNeed.Rows) { if (row.Cells["matid"].Value.ToString() != "") { //获取物料 EntityObject eoMat = base.GetRefEntityObjectByGridEntityCol(gridNeed, row.Cells["matid"]); strMatID.Append(string.Format(",{0}", (int)eoMat.PrimaryKeyValue)); } } strMatID.Append(")"); DataTable dt = new DataTable(); DataSet ds = new DataSet(); Jeez.Core.NativeQueryCommand cmd; Jeez.Core.INativeQuery quary = Jeez.Login.RemoteCall.GetNativeQuery(); cmd = new NativeQueryCommand(); cmd.CommandText = string.Format(@"select b.Number as 物料代码,b.Name as 物料名称,c.Name as 计量单位, sum(a.Many) as 总数量,sum(a.UseMany) as 订单占用数量,sum(a.CUseMany) as 出库占用数量,sum(a.Many)-sum(a.CUseMany) as 可用数量 from jzNowKucun a left join jzMat b on a.MatID=b.ID left join jzJiliangdanwei c on a.JiliangdanweiID=c.ID left join jzWareHouse w on w.ID=a.WareHouseID where a.MatID in {0} and w.OrganizationID={1} group by b.Number,b.Name,c.Name", strMatID,(int)txOrg.Tag); try { dt = quary.GetDataTable(this.objContext.ConnectionString, cmd); ds = new System.Data.DataSet(); ds.Tables.Add(dt); gridKucun.DataSource = ds.Tables[0]; gridKucun.FixCol = 3; } catch (Exception ex) { Jeez.Common.UI.MsgBox.Show(ex.Message.ToString()); } } } } /// <summary> /// 设置菜单控件状态 /// </summary> public override void SetMenuStatus() { base.SetMenuStatus(); } /// <summary> /// 保存前检查事件 /// </summary> /// <returns></returns> protected override bool BeforeSaveCheck() { bool b = base.BeforeSaveCheck(); if (b) { Hashtable hs = new Hashtable(); int i = 0; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridZY.Rows) { if (row.Cells["matid"].Value.ToString() != "") { if (!hs.Contains(row.Cells["MatID"].Value)) { hs.Add(row.Cells["MatID"].Value, row.Cells["MatID"].Value); } i++; } } if (hs.Count != i) { Jeez.Common.UI.MsgBox.Show("录入的物料有重复!"); return false; } } return b; } /// <summary> /// 指定服务端调用的类 /// </summary> /// <param name="ServerDllName"></param> /// <param name="ServerClassName"></param> protected override void SetInvokeBusiLogicName(out string ServerDllName, out string ServerClassName) { ServerDllName = "FolyerERPServer.dll"; ServerClassName = "FolyerERPServer.FolyerERPServer_SCM.ProductServer"; } /// <summary> /// 新增事件 /// </summary> protected override void AddNew() { base.AddNew(); if (this.entityobject == null) { InitByDefine(); } } /// <summary> /// 单元格值变化事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void gridZY_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if (!isLoading) return; //下推过程中以下推传过来的数据为主,不然会被冲掉 if (UserData != null) return; if (!isSelect) return; } /// <summary> /// 弹出窗体事件, /// </summary> /// <param name="sender"></param> /// <param name="EntityID"></param> /// <param name="RunTimeFilter"></param> protected override void ShowUISelectedForm(object sender, int EntityID, ArrayList RunTimeFilter) { //如果是往来单位表 if (EntityID == EntityIDEnum.RefUnit) { ArrayList ar = new ArrayList(); //过滤只有客户的往来单位 Jeez.Runtime.Base.General.RunTimefilterDefine fd; fd = new Jeez.Runtime.Base.General.RunTimefilterDefine("{jzRefUnit.IsSupply}", 0, 0, Jeez.FormProperty.FilterDefineCompare.Equals, Jeez.FormProperty.FilterDefineLogic.NONE, 1); ar.Add(fd); base.ShowUISelectedForm(sender, EntityID, ar); } else { base.ShowUISelectedForm(sender, EntityID, RunTimeFilter); } } protected override void BillUI_Load(object sender, EventArgs e) { base.BillUI_Load(sender, e); if (this.entityobject == null) { //公共的初始化值 InitByDefine(); } } /// <summary> /// 将实体数据banding到控件上的事件 /// </summary> protected override void LoadEntityDataToControl() { isLoading = false; base.LoadEntityDataToControl(); isLoading = true; InitByDefineOrder(); } /// <summary> /// 自定义初始化控件上的一些值 /// </summary> void InitByDefine() { //实现自动将当前登录用户所对应的职员信息的部门,组织机构,本身职员信息填充到界面上的三个控件减少输入 EntityObjectFactory eofEmployee = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Employee); EntityObject eoEmp = eofEmployee.FindFirst("SysUserID={0}", Jeez.Login.Environment.UserID); if (eoEmp != null && txEmployee != null) { txEmployee.Tag = eoEmp.PrimaryKeyValue; txEmployee.VALUE = eoEmp.ToString(); txOrg.Tag = eoEmp.GetRelatedObject("OrganizationID").PrimaryKeyValue; txOrg.VALUE = eoEmp.GetRelatedObject("OrganizationID").ToString(); txDept.Tag = eoEmp.GetRelatedObject("DepartMentID").PrimaryKeyValue; txDept.VALUE = eoEmp.GetRelatedObject("DepartMentID").ToString(); } ////默认登录的时候往来单位ID获取 EntityObjectFactory eofInnit = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.SystemInit); EntityObject eoInit = eofInnit.FindFirst("ID>0"); if (eoInit != null) { EntityObject eoBibie = eoInit.GetRelatedObject("CurrencyID"); if (eoBibie != null) { txBibie.Tag = eoBibie.PrimaryKeyValue; txBibie.VALUE = eoBibie.ToString(); txRat.PropertyPage.Value = 1.0m; //BibieID = (int)eoBibie.PrimaryKeyValue; } EntityObject eoWLDW = eoInit.GetRelatedObject("RefUnitID"); if (eoWLDW != null) { txWLDW.Tag = eoWLDW.PrimaryKeyValue; txWLDW.VALUE = eoWLDW.ToString(); } } this.gridZY.RowCount = 5;//默认设置5行 } /// <summary> /// 菜单事件的扩展 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="Tool"></param> public override void ResponseMenuToolClickEvent(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e, object Tool) { Jeez.FormProperty.JeezTool tool = Tool as Jeez.FormProperty.JeezTool; if (tool == null) return; this.Cursor = Jeez.Common.UI.Waitcursor.WaitCursor; switch (tool.Name) { //物料BOM拆解 case "toolBomDepart": BomDepart(); break; case "toolNextLingliao": NextBill("jzProductNeed", "ProductNeedID", "jzLingliaoDetail", "ProductID", EntityFormIDEnum.内部领料单2); break; case "toolNextRuku": NextBill("jzProductDetail", "ProductDetailID", "jzProductRukuDetail", "ProductID", EntityFormIDEnum.成品入库单2); break; case "toolUpBill": UpBill(EntityFormIDEnum.销售订单一览表3, "jzSaleOrder"); break; default: break; } base.ResponseMenuToolClickEvent(sender, e, Tool); this.Cursor = Jeez.Common.UI.Waitcursor.Default; } /// 选单功能 /// </summary> /// <param name="UpEntityFormID">选取的目标一览表ID</param> /// <param name="upTableName">选取的单据父表名称</param> public void UpBill(int UpEntityFormID, string upTableName) { foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows) { if (row.Cells["MatID"].Value.ToString() == "") { base.DeleteRow(); } } isSelect = false; SaleOrderList f; ArrayList ar = new ArrayList(); f = base.ShowForm(EntityFormIDEnum.销售订单一览表3, ar, null) as SaleOrderList; f.FormClosing += new FormClosingEventHandler(fList_FormClosing); } void fList_FormClosing(object sender, FormClosingEventArgs e) { int UpDeailEntityID = 0; string UpTableEntityID = ""; string UpTableDetailID = ""; SaleOrderList f = sender as SaleOrderList; UpDeailEntityID = EntityIDEnum.SaleOrderDetail; UpTableEntityID = "SaleOrderID"; UpTableDetailID = "SaleOrderDetailID"; if (f != null && f.CurrentGrid != null && f.CurrentGrid.Selected.Rows.Count != 0) { EntityObject eoOrg = null; EntityObject eoSupier = null; EntityObject eoBibie = null; int i = 0; Hashtable hs = new Hashtable(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in f.CurrentGrid.Selected.Rows) { //以下只是做判断是否满足选单条件 if (!(bool)BaseFunc.IsNull(row.Cells["IsCheck"].Value, false)) { Jeez.Common.UI.MsgBox.Inform(string.Format("第{0}行没有审核", row.ListIndex + 1)); return; } EntityObjectFactory eofDetail = EntityObjectFactory.GetInstance(this.objContext, UpDeailEntityID); EntityObject eoDetail = eofDetail.FindFirst("ID={0}", row.Cells["DetailID"].Value);//获取子表对象 EntityObject eob = eoDetail.GetRelatedObject(string.Format(@"{0}", UpTableEntityID));//获取父表实体 if (eob != null) { if (eoOrg != null && eoOrg.PrimaryKeyValue.ToString() != eob.GetProperty("OrganizationID").ToString()) { Jeez.Common.UI.MsgBox.Inform(string.Format("选择的组织机构不一致")); return; } eoOrg = eob.GetRelatedObject("OrganizationID"); if (eoBibie != null && eoBibie.PrimaryKeyValue.ToString() != eob.GetProperty("CurrencyID").ToString()) { Jeez.Common.UI.MsgBox.Inform(string.Format("选择的币别不一致")); return; } eoBibie = eob.GetRelatedObject("CurrencyID"); } } foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in f.CurrentGrid.Selected.Rows) { //如果满足选单条件 EntityObjectFactory eofDetail = EntityObjectFactory.GetInstance(this.objContext, UpDeailEntityID); EntityObject eoDetail = eofDetail.FindFirst("ID={0}", row.Cells["DetailID"].Value);//获取子表对象 //string a = string.Format(@"{0}", UpTableEntityID); EntityObject eoParent = eoDetail.GetRelatedObject(string.Format(@"{0}", UpTableEntityID));//获取父表实体 if (eoDetail != null) { if (i == 0) {//保证只赋值一次 txOrg.Tag = eoParent.GetRelatedObject("OrganizationID").PrimaryKeyValue; txOrg.VALUE = eoParent.GetRelatedObject("OrganizationID").ToString(); txDept.Tag = eoParent.GetRelatedObject("DepartMentID").PrimaryKeyValue; txDept.VALUE = eoParent.GetRelatedObject("DepartMentID").ToString(); //txWLDW.Tag = eoParent.GetRelatedObject("RefUnitID").PrimaryKeyValue; //txWLDW.VALUE = eoParent.GetRelatedObject("RefUnitID").ToString(); txBibie.Tag = eoParent.GetRelatedObject("CurrencyID").PrimaryKeyValue; txBibie.VALUE = eoParent.GetRelatedObject("CurrencyID").ToString(); txRat.PropertyPage.Value = (decimal)eoParent.GetProperty("Rate"); txEmployee.Tag = eoParent.GetRelatedObject("EmployeeID").PrimaryKeyValue; txEmployee.VALUE = eoParent.GetRelatedObject("EmployeeID").ToString(); } //为子Grid赋值 this.gridZY.ReadOnly = false; this.gridZY.InsertRow(this.gridZY.Rows.Count); this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["UpBillNo"].Value = eoParent.GetProperty("BillNo"); this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["MatID"].Tag = eoDetail.GetRelatedObject("MatID").PrimaryKeyValue; this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["MatID"].Value = eoDetail.GetRelatedObject("MatID").ToString(); this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["JiliangdanweiID"].Tag = eoDetail.GetRelatedObject("JiliangdanweiID").PrimaryKeyValue; this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["JiliangdanweiID"].Value = eoDetail.GetRelatedObject("JiliangdanweiID").ToString(); this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["UpMany"].Value = eoDetail.GetProperty("Many"); this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells[UpTableDetailID].Tag = eoDetail.PrimaryKeyValue; this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells[UpTableDetailID].Value = eoDetail.ToString(); //this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["Date"].Value = eoDetail.GetProperty("Date"); this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["Many"].Value = Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)); //this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["SMany"].Value = eoDetail.GetProperty("SMany"); //this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["Danjia"].Value = eoDetail.GetProperty("Danjia"); //this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["RDanjia"].Value = eoDetail.GetProperty("RDanjia"); //this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["Amount"].Value = (Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)) - Convert.ToDecimal(BaseFunc.IsNull(row.Cells["POMany"].Value, 0m))) * (decimal)eoDetail.GetProperty("Danjia"); //this.gridZY.Rows[this.gridZY.Rows.Count - 1].Cells["RAmount"].Value = (Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)) - Convert.ToDecimal(BaseFunc.IsNull(row.Cells["POMany"].Value, 0m))) * (decimal)eoDetail.GetProperty("RDanjia"); i++; } } //删除空行 foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows) { if (row.Cells["MatID"].Value.ToString() == "") { base.DeleteRow(); } } } isSelect = true; } /// <summary> /// 单据下推事件 /// </summary> /// <param name="eoChildTableName">当前单据子表名</param> /// <param name="eoChildTableID">当前单据子表与下推单据子表关联字段,即子表实体名添加ID</param> /// <param name="nextChildTableName">下推目标单据子表名</param> /// <param name="eoTableID">当前单据与父表关联字段,即当前单据父表名实体名添加ID</param> /// <param name="NextEntityFormID">下推界面ID</param> public void NextBill(string eoChildTableName, string eoChildTableID, string nextChildTableName, string eoTableID, int NextEntityFormID) { if (this.entityobject == null) return; if ((int)this.entityobject.GetProperty("CheckID") == 0) { Jeez.Common.UI.MsgBox.Show("单据还未审核!不能下推!"); return; } //判断当前还有多少报价没下推订单 Jeez.Core.NativeQueryCommand cmd; Jeez.Core.INativeQuery quary = Jeez.Login.RemoteCall.GetNativeQuery(); cmd = new NativeQueryCommand(); cmd.CommandText = string.Format(@"select a.ID,a.Many-IsNull(b.PoQty,0) as LeftMany from {1} a left join (select {2},isnull(Sum(Many),0) as PoQty from {3} where {2}>0 group by {2} ) b on a.id=b.{2} where a.{4}={0}", (int)this.entityobject.PrimaryKeyValue, eoChildTableName, eoChildTableID, nextChildTableName, eoTableID); try { DataTable dt = quary.GetDataTable(this.objContext.ConnectionString, cmd); if (dt.Rows.Count > 0) { ArrayList arr = new ArrayList(); foreach (DataRow row in dt.Rows) { if (Convert.ToDecimal(BaseFunc.IsNull(row["LeftMany"], 0m)) > 0m) { Hashtable htv = new Hashtable(); htv["DetailID"] = row["ID"]; htv["Many"] = Convert.ToDecimal(BaseFunc.IsNull(row["LeftMany"], 0m)); arr.Add(htv); } } Hashtable ht = new Hashtable(); ht["DetailList"] = arr; //跳转到销售订单界面 if (NextEntityFormID == EntityFormIDEnum.内部领料单2) { SaleOrder f = base.ShowForm(EntityFormIDEnum.内部领料单2, ht) as SaleOrder; } if (NextEntityFormID == EntityFormIDEnum.成品入库单2) { SaleChuku f = base.ShowForm(EntityFormIDEnum.成品入库单2, ht) as SaleChuku; } } else { Jeez.Common.UI.MsgBox.Show("单据已经下推完,不能再执行下推!"); return; } } catch (Exception ex) { Jeez.Common.UI.MsgBox.Show(ex.Message.ToString()); } } /// <summary> /// 物料BOM拆解 /// </summary> void BomDepart() { if (this.entityobject == null) { return; } if (gridNeed.ReadOnly) return; Hashtable htMaterial = new Hashtable(); ArrayList arrRow = new ArrayList(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in gridZY.Rows) { // //获取表格列引用的实体对象 EntityObject eomat = base.GetRefEntityObjectByGridEntityCol(gridZY, row.Cells["MatID"]); if (eomat != null) { Hashtable ht = GetBOMMaterial(objContext, (int)eomat.PrimaryKeyValue, Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m))); if (ht == null || ht.Count == 0) { if (htMaterial.ContainsKey(eomat.PrimaryKeyValue.ToString() + "@" + eomat.GetRelatedObject("jiliangdanweiID").PrimaryKeyValue.ToString())) { htMaterial[eomat.PrimaryKeyValue.ToString() + "@" + eomat.GetRelatedObject("jiliangdanweiID").PrimaryKeyValue.ToString()] = Convert.ToDecimal(htMaterial[eomat.PrimaryKeyValue.ToString() + "@" + eomat.GetRelatedObject("jiliangdanweiID").PrimaryKeyValue.ToString()]) + Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)); } else htMaterial[eomat.PrimaryKeyValue.ToString() + "@" + eomat.GetRelatedObject("jiliangdanweiID").PrimaryKeyValue.ToString()] = Convert.ToDecimal(BaseFunc.IsNull(row.Cells["Many"].Value, 0m)); } else { foreach (DictionaryEntry de in ht) { if (htMaterial.ContainsKey(de.Key.ToString())) { htMaterial[de.Key.ToString()] = Convert.ToDecimal(htMaterial[de.Key.ToString()]) + Convert.ToDecimal(de.Value); } else htMaterial[de.Key.ToString()] = Convert.ToDecimal(de.Value); } } } } EntityObjectFactory eof = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.Mat); EntityObjectFactory eofUnit = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.jiliangdanwei); gridNeed.DeleteAllRow(); //gridNeed.ReadOnly = false; foreach (DictionaryEntry de in htMaterial) { string key = de.Key.ToString(); string[] sArray = key.Split('@'); string MID = sArray[0]; string UID = sArray[1]; EntityObject eomat = eof.FindObject(Convert.ToInt32(MID)); EntityObject eoUnit = eofUnit.FindObject(Convert.ToInt32(UID)); if (eomat != null && eoUnit != null) { gridNeed.InsertRow(gridNeed.Rows.Count); Infragistics.Win.UltraWinGrid.UltraGridRow row = gridNeed.Rows[gridNeed.Rows.Count - 1]; row.Cells["MatID"].Tag = eomat.PrimaryKeyValue; row.Cells["MatID"].Value = eomat.ToString(); row.Cells["jiliangdanweiID"].Tag = eoUnit.PrimaryKeyValue; row.Cells["jiliangdanweiID"].Value = eoUnit.ToString(); row.Cells["Many"].Value = de.Value; } } // gridNeed.ReadOnly = true; base.Save(); } /// <summary> /// 获取物料BOM构成函数 /// </summary> /// <param name="objContent"></param> /// <param name="MatID"></param> /// <param name="BaseQty"></param> /// <returns></returns> public Hashtable GetBOMMaterial(ObjectContext objContent, int MatID, decimal BaseQty) { objContext = objContent; Hashtable htBOMMaterial = new Hashtable(); if (GetBomMaterial(MatID, htBOMMaterial, BaseQty)) return htBOMMaterial; else return null; } private bool GetBomMaterial(int MatID, Hashtable htBomMaterial, decimal baseQty) { EntityObject eo = EntityObjectFactory.GetInstance(objContext, EntityIDEnum.MatBom).FindFirst("MatID={0} ", MatID); if (eo != null) { foreach (EntityObject eod in eo.GetChildEntityObjects(EntityIDEnum.MatBomDetail)) { int UnitID = (int)eod.GetProperty("jiliangdanweiID"); if (!GetBomMaterial((int)eod.GetProperty("MatID"), htBomMaterial, baseQty * (decimal)eod.GetProperty("Many"))) { if (htBomMaterial.ContainsKey(eod.GetProperty("MatID").ToString() + "@" + UnitID)) { // Hashtable htMaterial = htBomMaterial[eod.GetProperty("MMatID").ToString()] as Hashtable; htBomMaterial[eod.GetProperty("MatID").ToString() + "@" + UnitID] = Convert.ToDecimal(htBomMaterial[eod.GetProperty("MatID").ToString() + "@" + UnitID]) + baseQty * (decimal)eod.GetProperty("Many"); } else { htBomMaterial[eod.GetProperty("MatID").ToString() + "@" + UnitID] = baseQty * (decimal)eod.GetProperty("Many"); } } } return true; } else return false; } }
服务端代码:
/// <summary> /// 生产任务单 /// </summary> class ProductServer : SCMBaseServer { protected override bool CheckValidate(EntityObject eo, bool IsCheck, ref string strMessage) { bool b = base.CheckValidate(eo, IsCheck, ref strMessage); if (b) { if (IsCheck) {//审核执行自己的业务逻辑 } else { if (!ERPServerFunc.IsNextBill(Context, eo, EntityIDEnum.LingliaoDetail, EntityIDEnum.ProductNeed, "LingliaoID", "ProductNeedID", ref strMessage)) return false; if (!ERPServerFunc.IsNextBill(Context, eo, EntityIDEnum.ProductRukuDetail, EntityIDEnum.ProductDetail, "ProductRukuID", "ProductDetailID", ref strMessage)) return false; } } return b; } }
官网:www.jeez.com.cn
平台介绍:www.jeez.com.cn/jbf
平台下载地址:http://www.jeez.com.cn/upfiles/jbfsetuppro.rar
(下载即可有3个月免费试用)
联系电话:13826519021 18988763421 QQ:180315586 420977542 (加我注明极致软件即可)
平台销售经理:李先生
将互联网时代的管理软件做到极致!
==================================================================
快速开发,随需而变,将互联网时代的企业管理软件做到极致