using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Util; using System; using System.ComponentModel; using System.Data; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel; namespace Demo.BillView.PRD { [Description("齐套分析列表功能")] [HotUpdate] public class ProCompleteAnalysisDetail : AbstractDynamicFormPlugIn { bool did = false; string FHICMOInterID = "";//日计划工单内码 string tempName = "JIT_MOMaterReadysBill";//表名称 public override void OnLoad(EventArgs e) { //LogHelper.Info("[齐套分析明细加载列表]"); base.OnLoad(e); if (this.View.OpenParameter.GetCustomParameter("FHICMOInterID") == null) { SearchList(); ChangeColor(); } else { if (did) return; if (this.View.OpenParameter.GetCustomParameter("tempName") != null) tempName = this.View.OpenParameter.GetCustomParameter("tempName")?.ToString();//表名 FHICMOInterID = this.View.OpenParameter.GetCustomParameter("FHICMOInterID").ToString();//日计划订单主内码 string sql = string.Format(@"/*dialect*/select * from view_{0} where FHICMOInterID='{1}' order by FPlanDate, FHStockQty desc ,FHMaterID ", tempName, FHICMOInterID); DataTable dt = DBServiceHelper.ExecuteDataSet(this.Context, sql).Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { this.Model.CreateNewEntryRow("FEntity"); this.Model.SetValue("FSEQ", i + 1, i);//序号 this.Model.SetValue("FMateralDetailId", dt.Rows[i]["FHMATERID"], i); this.Model.SetValue("FPlanIssueCount", dt.Rows[i]["FSumPlanCount"], i);//计划发料数量 this.Model.SetValue("FCompleteCount", dt.Rows[i]["FCompleteCount1"], i);//齐套数量 this.Model.SetValue("FLackCount", dt.Rows[i]["FLackCount"], i);//缺料数量 this.Model.SetValue("FPassableCount", dt.Rows[i]["FHLeftQty"].ToString(), i);//可用数量 this.Model.SetValue("FMateralCount", dt.Rows[i]["FHStockQty"].ToString(), i);//物料数量 this.Model.SetValue("FOccupyCount", dt.Rows[i]["FOccupyCount"].ToString(), i);//占用数量 this.Model.SetValue("FCompleteDetailStatus", dt.Rows[i]["FComPlete"].ToString(), i);//是否齐套 this.Model.SetValue("FIsHavePur", dt.Rows[i]["FIsHavePur"].ToString(), i);//是否有采购订单 this.Model.SetValue("FHMainICMOInterIDr", dt.Rows[i]["FHMainICMOInterIDr"].ToString(), i);//生产订单内码 this.Model.SetValue("FPRDBillNo", dt.Rows[i]["FPRDBillNo"].ToString(), i);//生产订单内码 this.Model.SetValue("FPlanDate", dt.Rows[i]["FPlanDate"].ToString(), i);//日计划日期 this.Model.SetValue("FOrgId", dt.Rows[i]["FHStockOrgID"], i);//库存组织 this.Model.SetValue("FOwnerTypeId", dt.Rows[i]["FOwnerTypeId"], i);//货主类型 this.Model.SetValue("FOwnerId", dt.Rows[i]["FOwnerId"], i);//货主 this.Model.SetValue("FErpClsID", dt.Rows[i]["FErpClsID"], i);//物料属性 } } ChangeColor(); did = true; } } private void ChangeColor() { Entity entity = this.View.BillBusinessInfo.GetEntity("FEntity"); //单据体信息转换为列表集合 DynamicObjectCollection entityDataObjoct = this.View.Model.GetEntityDataObject(entity); EntryGrid grid = this.View.GetControl("FEntity"); int _i = 0; foreach (DynamicObject current in entityDataObjoct) { if (Convert.ToString(current["FCompleteDetailStatus"]) == "未齐套") { grid.SetRowBackcolor("#71FF98CB", _i); } else { grid.SetRowBackcolor("#ffffff", _i); } _i++; } } public override void BarItemClick(BarItemClickEventArgs e) { base.BarItemClick(e); if (e.BarItemKey.ToUpper() == "TBFILTER") { SearchList(); ChangeColor(); } } /// /// 行双击 跳出齐套分析明细列表 /// /// public override void EntityRowDoubleClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntityRowClickEventArgs e) { var m = e.Row; var n = e.Key; base.EntityRowClick(e); DynamicFormShowParameter formPa = new DynamicFormShowParameter(); formPa.FormId = "paez_CompleteAnalysisMateriel"; formPa.CustomParams.Add("FHMainICMOInterIDr", Convert.ToString(this.View.Model.GetValue("FHMainICMOInterIDr", e.Row).ToString())); formPa.CustomParams.Add("FMatrailId", Convert.ToString((this.View.Model.GetValue("FMateralDetailId", e.Row) as DynamicObject)["Id"].ToString())); this.View.ShowForm(formPa); } /// /// 查询事件 /// public void SearchList() { string sqlwhere = $" where FHICMOInterID='{FHICMOInterID}'"; string sql = string.Format($"/*dialect*/select * from view_{tempName}"); //物料 if ((this.Model.GetValue("FMateralId") as DynamicObject) != null) { string FMateralId = (this.Model.GetValue("FMateralId") as DynamicObject)["Id"].ToString(); if (!string.IsNullOrEmpty(FMateralId)) sqlwhere += $" and FHMATERID='{FMateralId}'"; } //齐套 string FCompleteStatus = Convert.ToString(this.Model.GetValue("FCompleteStatus")); if (!string.IsNullOrEmpty(FCompleteStatus)) sqlwhere += $" and FComPlete='{FCompleteStatus}'"; //有无采购订单 string FIsHavePurs = Convert.ToString(this.Model.GetValue("FIsHavePurs")); if (!string.IsNullOrEmpty(FIsHavePurs)) sqlwhere += $" and FIsHavePur='{FIsHavePurs}'"; //日计划日期 string FPlanDate = Convert.ToString(this.Model.GetValue("FPlanDate2")); if (!string.IsNullOrEmpty(FPlanDate)) sqlwhere += $" and FPlanDate='{FPlanDate}'"; //生产订单号 string PRDBillNo = Convert.ToString(this.Model.GetValue("FScOrderNo")); if (!string.IsNullOrEmpty(PRDBillNo)) sqlwhere += $" and FPRDBillNo='{PRDBillNo}'"; sql += sqlwhere; sql += "order by FPlanDate, FHStockQty desc ,FHMaterID"; DataTable dt = DBServiceHelper.ExecuteDataSet(this.Context, sql).Tables[0]; //this.Model.DeleteEntryData("FEntity"); while (this.Model.GetEntryRowCount("FEntity") > 0) { this.Model.DeleteEntryRow("FEntity", 0); } //this.View.Refresh(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { this.Model.CreateNewEntryRow("FEntity"); this.Model.SetValue("FSEQ", i + 1, i);//序号 this.Model.SetValue("FMateralDetailId", dt.Rows[i]["FHMATERID"], i); this.Model.SetValue("FPlanIssueCount", dt.Rows[i]["FSumPlanCount"], i);//计划发料数量 this.Model.SetValue("FCompleteCount", dt.Rows[i]["FCompleteCount1"], i);//齐套数量 this.Model.SetValue("FLackCount", dt.Rows[i]["FLackCount"], i);//缺料数量 this.Model.SetValue("FPassableCount", dt.Rows[i]["FHLeftQty"].ToString(), i);//可用数量 this.Model.SetValue("FMateralCount", dt.Rows[i]["FHStockQty"].ToString(), i);//物料数量 this.Model.SetValue("FOccupyCount", dt.Rows[i]["FOccupyCount"].ToString(), i);//占用数量 this.Model.SetValue("FCompleteDetailStatus", dt.Rows[i]["FComPlete"].ToString(), i);//是否齐套 this.Model.SetValue("FIsHavePur", dt.Rows[i]["FIsHavePur"].ToString(), i);//是否有采购订单 this.Model.SetValue("FHMainICMOInterIDr", dt.Rows[i]["FHMainICMOInterIDr"].ToString(), i);//生产订单内码 this.Model.SetValue("FPRDBillNo", dt.Rows[i]["FPRDBillNo"].ToString(), i);//生产订单内码 this.Model.SetValue("FPlanDate", dt.Rows[i]["FPlanDate"].ToString(), i);//日计划日期 this.Model.SetValue("FOrgId", dt.Rows[i]["FHStockOrgID"], i);//库存组织 this.Model.SetValue("FOwnerTypeId", dt.Rows[i]["FOwnerTypeId"], i);//货主类型 this.Model.SetValue("FErpClsID", dt.Rows[i]["FErpClsID"], i);//物料属性 this.Model.SetValue("FOwnerId", dt.Rows[i]["FOwnerId"], i);//货主 } } //this.View.UpdateView(); did = true; } } }