private void SetValue(DataSet Ds) { if (Ds != null && Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0) { Entity entity = this.View.BusinessInfo.GetEntity("F_SZXY_Entity"); DynamicObjectCollection Entrys = this.Model.DataObject["SZXY_Entry"] as DynamicObjectCollection; Entrys.Clear(); for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { //DynamicObject NewRow = new DynamicObject(entity.DynamicObjectType); this.Model.CreateNewEntryRow("F_SZXY_Entity"); this.Model.SetValue("F_SZXY_BillNo", Convert.ToString(Ds.Tables[0].Rows[i]["FBILLNO"]), i); this.Model.SetValue("F_SZXY_DocumentStatus", Convert.ToString(Ds.Tables[0].Rows[i]["FDocumentStatus"]), i); this.Model.SetValue("F_SZXY_CreateDate", Convert.ToString(Ds.Tables[0].Rows[i]["FCreateDate"]), i); this.Model.SetValue("F_SZXY_PONO", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_PONO"]), i); this.Model.SetValue("F_SZXY_MoLineNo", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_MoLineNo"]), i); this.Model.SetValue("F_SZXY_LEN", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_LEN"]), i); this.Model.SetValue("F_SZXY_WIDTH", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_WIDTH"]), i); this.Model.SetValue("F_SZXY_PLY", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_PLY"]), i); if (Ds.Tables[0].Rows[i]["F_SZXY_TEAMGROUP"] != null) { this.Model.SetValue("F_SZXY_TEAMGROUP", Convert.ToInt32(Ds.Tables[0].Rows[i]["F_SZXY_TEAMGROUP"]), i); } if (Ds.Tables[0].Rows[i]["F_SZXY_CLASSES"] != null) { this.Model.SetValue("F_SZXY_CLASSES", Convert.ToInt32(Ds.Tables[0].Rows[i]["F_SZXY_CLASSES"]), i); } if (Ds.Tables[0].Rows[i]["F_SZXY_Material"] != null) { this.Model.SetValue("F_SZXY_Material", Convert.ToInt32(Ds.Tables[0].Rows[i]["F_SZXY_Material"]), i); } if (Ds.Tables[0].Rows[i]["F_SZXY_OPERATOR"] != null) { this.Model.SetValue("F_SZXY_OPERATOR", Convert.ToInt32(Ds.Tables[0].Rows[i]["F_SZXY_OPERATOR"]), i); } if (Ds.Tables[0].Rows[i]["F_SZXY_recipe"] != null) { this.Model.SetValue("F_SZXY_recipe", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_recipe"]), i); } if (Ds.Tables[0].Rows[i]["F_SZXY_SMark"] != null) { this.Model.SetValue("F_SZXY_SMark", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_SMark"]), i); } if (Ds.Tables[0].Rows[i]["F_SZXY_WIRED"] != null) { this.Model.SetValue("F_SZXY_WIRED", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_WIRED"]), i); } if (Ds.Tables[0].Rows[i]["F_SZXY_MVolume"] != null) { this.Model.SetValue("F_SZXY_MVolume", Convert.ToString(Ds.Tables[0].Rows[i]["F_SZXY_MVolume"]), i); } // Entrys.Add(NewRow); } } }
private void FillReferDetail(ExtendedDataEntity[] entityDataes, DynamicObject billTypePara) { FormMetadata metadata = (FormMetadata)Kingdee.K3.MFG.App.AppServiceContext.MetadataService.Load(base.Context, "QM_InspectBill", true); EntryEntity entryEntity = metadata.BusinessInfo.GetEntryEntity("FReferDetail"); List <long> srcEntryIds = (from s in entityDataes from ss in s.DataEntity["FEntity_Link"] as DynamicObjectCollection select ss.GetDynamicObjectItemValue <long>("SId", 0L)).Distinct <long>().ToList <long>(); string businessType = billTypePara.GetDynamicObjectItemValue <string>("FInspectType", null); DynamicObjectCollection col = this.GetSrcInfo(base.Context, srcEntryIds, businessType); if (!col.IsEmpty <DynamicObject>()) { foreach (ExtendedDataEntity entity2 in entityDataes) { DynamicObject dataEntity = entity2.DataEntity; DynamicObjectCollection objects2 = entity2.DataEntity.GetDynamicObjectItemValue <DynamicObjectCollection>("ReferDetail", null); objects2.Clear(); DynamicObjectCollection objects3 = entity2.DataEntity.GetDynamicObjectItemValue <DynamicObjectCollection>("FEntity_Link", null); int num = 1; foreach (DynamicObject obj2 in objects3) { InspectBillView.FEntity_Link link = obj2; foreach (DynamicObject obj3 in (from w in col where w.GetDynamicObjectItemValue <string>("FTEID", null) == link.SId select w).ToList <DynamicObject>()) { InspectBillView.ReferDetail detail = new Kingdee.K3.MFG.Common.BusinessEntity.QM.InspectBillView.ReferDetail(new DynamicObject(entryEntity.DynamicObjectType)) { Seq = num++, SrcBillType = obj3.GetDynamicObjectItemValue <string>("FSRCBILLTYPE", null), SrcBillNo = obj3.GetDynamicObjectItemValue <string>("FSRCBILLNO", null), SrcInterId = Convert.ToInt64(link.SBillId), SrcEntryId = Convert.ToInt64(link.SId), SrcEntrySeq = (long)obj3.GetDynamicObjectItemValue <int>("FSRCENTRYSEQ", 0), OrderType_Id = obj3.GetDynamicObjectItemValue <string>("FORDERBILLTYPE", null), OrderBillNo = obj3.GetDynamicObjectItemValue <string>("FORDERBILLNO", null), OrderId = obj3.GetDynamicObjectItemValue <long>("FORDERID", 0L), OrderEntryId = obj3.GetDynamicObjectItemValue <long>("FORDERENTRYID", 0L), OrderEntrySeq = (long)obj3.GetDynamicObjectItemValue <int>("FORDERENTRYSEQ", 0) }; objects2.Add((DynamicObject)detail); } } } } }
private void RefreshErrEntity(StockOrgOperateResult opResult, ErrType errType) { Entity entryEntity = this.View.BusinessInfo.GetEntryEntity("FEntityErrInfo"); DynamicObjectType dynamicObjectType = entryEntity.DynamicObjectType; DynamicObjectCollection entityDataObject = this.Model.GetEntityDataObject(entryEntity); entityDataObject.Clear(); if (((errType == ErrType.Minus) || (errType == ErrType.None)) || ((errType == ErrType.UnAuditStkCountBill) || (errType == ErrType.StkDraftBill))) { this.View.UpdateView("FEntityErrInfo"); } else if (((opResult == null) || (opResult.ErrInfo == null)) || (opResult.ErrInfo.Count < 1)) { this.View.UpdateView("FEntityErrInfo"); } else { IEnumerable <OperateErrorInfo> enumerable; if (errType == ErrType.UnAuditBill) { enumerable = from p in opResult.ErrInfo where p.ErrType == Convert.ToInt32(ErrType.UnAuditBill) select p; } else { enumerable = from p in opResult.ErrInfo where p.ErrType < Convert.ToInt32(ErrType.OrgStatusErr) select p; } foreach (OperateErrorInfo info in enumerable) { DynamicObject item = new DynamicObject(dynamicObjectType) { ["ErrType"] = info.ErrType, ["ErrObjType"] = info.ErrObjType, ["ErrObjKeyField"] = info.ErrObjKeyField, ["ErrObjKeyID"] = info.ErrObjKeyID, ["ErrMsg"] = info.ErrMsg }; entityDataObject.Add(item); } this.View.UpdateView("FEntityErrInfo"); } }
private void RefreshMinusEntry(StockOrgOperateResult opResult, ErrType errType) { Entity entryEntity = this.View.BusinessInfo.GetEntryEntity("FMinusEntry"); DynamicObjectType dynamicObjectType = entryEntity.DynamicObjectType; DynamicObjectCollection entityDataObject = this.Model.GetEntityDataObject(entryEntity); entityDataObject.Clear(); if (((opResult != null) && (opResult.MinusErrObject != null)) && (((DynamicObjectCollection)opResult.MinusErrObject["Entry"]).Count > 0)) { foreach (DynamicObject obj2 in (DynamicObjectCollection)opResult.MinusErrObject["Entry"]) { DynamicObject item = new DynamicObject(dynamicObjectType) { ["ErrMessage"] = obj2["ErrMessage"], ["MaterialNumber"] = obj2["MaterialNumber"], ["MaterialName"] = obj2["MaterialName"], ["Specification"] = obj2["Specification"], ["StockName"] = obj2["StockName"], ["StockLocName"] = obj2["StockLocName"], ["UnitName"] = obj2["UnitName"], ["Qty"] = obj2["Qty"], ["SecUnitName"] = obj2["SecUnitName"], ["SecQty"] = obj2["SecQty"], ["LotText"] = obj2["LotText"], ["AuxPropName"] = obj2["AuxPropName"], ["BOMNumber"] = obj2["BOMNumber"], ["MtoNo"] = obj2["MtoNo"], ["ProjectNo"] = obj2["ProjectNo"], ["ProduceDate"] = obj2["ProduceDate"], ["ExpiryDate"] = obj2["ExpiryDate"], ["StockStatusName"] = obj2["StockStatusName"], ["OwnerTypeName"] = obj2["OwnerTypeName"], ["OwnerName"] = obj2["OwnerName"], ["KeeperTypeName"] = obj2["KeeperTypeName"], ["KeeperName"] = obj2["KeeperName"] }; entityDataObject.Add(item); } } this.View.UpdateView("FMinusEntry"); }
private void RefreshStkCntBillAuditEntry(StockOrgOperateResult opResult, ErrType errtype) { Entity entryEntity = this.View.BusinessInfo.GetEntryEntity("FStkCountBillAuditEntry"); DynamicObjectType dynamicObjectType = entryEntity.DynamicObjectType; DynamicObjectCollection entityDataObject = this.Model.GetEntityDataObject(entryEntity); entityDataObject.Clear(); if (((opResult != null) && (opResult.StkCountBillAuditErrInfo != null)) && (opResult.StkCountBillAuditErrInfo.Count > 0)) { foreach (OperateErrorInfo info in opResult.StkCountBillAuditErrInfo) { DynamicObject item = new DynamicObject(dynamicObjectType) { ["CtbaErrType"] = info.ErrType, ["CtbaErrObjType"] = info.ErrObjType, ["CtbaErrObjKeyField"] = info.ErrObjKeyField, ["CtbaErrObjKeyID"] = info.ErrObjKeyID, ["CtbaErrMsg"] = info.ErrMsg }; entityDataObject.Add(item); } } this.View.UpdateView("FStkCountBillAuditEntry"); }
/// <summary> /// 主单据体的字段携带完毕,与源单的关联关系创建好之后,触发此事件 /// </summary> /// <param name="e"></param> public override void OnAfterCreateLink(CreateLinkEventArgs e) { // 预先获取一些必要的元数据,后续代码要用到: // 源单第二单据体,执行部门 Entity srcSecondEntity = e.SourceBusinessInfo.GetEntity("F_PEJK_ExecuteDept"); // 目标单第一单据体,产品明细 //Entity mainEntity = e.TargetBusinessInfo.GetEntity("FEntity"); // 目标单第二单据体,执行部门 Entity secondEntity = e.TargetBusinessInfo.GetEntity("F_PEJK_OppExecuteDept"); // 目标单关联子单据体 //Entity linkEntity = null; //Form form = e.TargetBusinessInfo.GetForm(); //if (form.LinkSet != null // && form.LinkSet.LinkEntitys != null // && form.LinkSet.LinkEntitys.Count != 0) //{ // linkEntity = e.TargetBusinessInfo.GetEntity( // form.LinkSet.LinkEntitys[0].Key); //} //if (linkEntity == null) //{ // return; //} // 获取生成的全部下游单据 ExtendedDataEntity[] billDataEntitys = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead"); // 对下游单据,逐张单据进行处理 //foreach (var item in billDataEntitys) //{ // DynamicObject dataObject = item.DataEntity; // // 定义一个集合,用于收集本单对应的源单内码 // HashSet<long> srcBillIds = new HashSet<long>(); // //开始到主单据体中,读取关联的源单内码 // DynamicObjectCollection mainEntryRows = // mainEntity.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; // foreach (var mainEntityRow in mainEntryRows) // { // DynamicObjectCollection linkRows = // linkEntity.DynamicProperty.GetValue(mainEntityRow) as DynamicObjectCollection; // foreach (var linkRow in linkRows) // { // long srcBillId = Convert.ToInt64(linkRow["SBillId"]); // if (srcBillId != 0 // && srcBillIds.Contains(srcBillId) == false) // { // srcBillIds.Add(srcBillId); // } // } // } //DynamicObject linkRows = // linkEntity.DynamicProperty.GetValue(dataObject) as DynamicObject; // long srcBillId = Convert.ToInt64(linkRows["SBillId"]); // if (srcBillId != 0 // && srcBillIds.Contains(srcBillId) == false) // { // srcBillIds.Add(srcBillId); // } //定义一个集合,用于收集本单对应的源单内码 HashSet <long> srcBillIds = new HashSet <long>(); foreach (var item in billDataEntitys) { DynamicObject dataObject = item.DataEntity; if (Convert.ToString(dataObject["FSourceBillNo"]) != null && Convert.ToString(dataObject["FSourceBillNo"]) != " ") { string strSql = string.Format(@"/*dialect*/select FID from T_CRM_Clue where FBILLNO = '{0}'", Convert.ToString(dataObject["FSourceBillNo"])); long srcBillId = DBUtils.ExecuteScalar <long>(this.Context, strSql, 0, null); if (srcBillId != 0 && srcBillIds.Contains(srcBillId) == false) { srcBillIds.Add(srcBillId); } if (srcBillIds.Count == 0) { continue; } // 开始加载源单第二单据体上的字段 // 确定需要加载的源单字段(仅加载需要携带的字段) List <SelectorItemInfo> selector = new List <SelectorItemInfo>(); selector.Add(new SelectorItemInfo("F_PEJK_ExecuteDeptId")); // TODO: 继续添加其他需要携带的字段,示例代码略 // 设置过滤条件 string filter = string.Format(" {0} IN ({1}) ", e.SourceBusinessInfo.GetForm().PkFieldName, string.Join(",", srcBillIds)); OQLFilter filterObj = OQLFilter.CreateHeadEntityFilter(filter); // 读取源单 IViewService viewService = ServiceHelper.GetService <IViewService>(); var srcBillObjs = viewService.Load(this.Context, e.SourceBusinessInfo.GetForm().Id, selector, filterObj); // 开始把源单单据体数据,填写到目标单上 DynamicObjectCollection secondEntryRows = secondEntity.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; secondEntryRows.Clear(); // 删除空行 foreach (var srcBillObj in srcBillObjs) { DynamicObjectCollection srcEntryRows = srcSecondEntity.DynamicProperty.GetValue(srcBillObj) as DynamicObjectCollection; foreach (var srcEntryRow in srcEntryRows) { // 目标单添加新行,并接受源单字段值 DynamicObject newRow = new DynamicObject(secondEntity.DynamicObjectType); secondEntryRows.Add(newRow); // 填写字段值 newRow["F_PEJK_ExecuteDeptId"] = srcEntryRow["F_PEJK_ExecuteDeptId"]; // TODO: 逐个填写其他字段值,示例代码略 } } } //string strSql = string.Format(@"/*dialect*/select fsbillid from T_CRM_Opportunity_LK where fid = {0}", Convert.ToInt64(dataObject["id"])); } }
public override void AfterCreateModelData(EventArgs e) { List <Bem_QanoArgs> resultList = null; BizQanoService service = BizQanoService.GetInstance(); int seq = 0;//父单据体行 Entity entity = this.View.BusinessInfo.GetEntity("FEntity"); DynamicObjectCollection objs = this.View.Model.GetEntityDataObject(entity); //this.Model.ClearNoDataRow(); objs.Clear(); resultList = service.GetBillMaterialList(this.Context, ids, entryIds, PformId); if (resultList.Count > 0) { foreach (Bem_QanoArgs one in resultList) { DynamicObject obj = new DynamicObject(entity.DynamicObjectType); objs.Add(obj); //this.Model.CreateNewEntryRow(entity,seq); //obj["F_QANo"] = one.qano; //obj["F_RealLength"] = one.RealLength; //obj["F_RealWidth"] = one.RealWidth; //obj["F_RealThinkness"] = one.RealThinkness; //obj["F_Length"] = one.Length; //obj["F_Width"] = one.Width; //obj["F_Thinkness"] = one.Thinkness; //obj["F_Specification"] = one.Specification; //obj["F_CContent"] = one.CContent; //obj["F_CrContent"] = one.CrContent; //obj["F_ElementRemark"] = one.ElementRemark; //obj["F_PerRemark"] = one.PerRemark; //obj["F_SurfaceRemark"] = one.SurfaceRemark; //obj["F_OtherRemaek"] = one.OtherRemaek; //obj["F_WeightMethod_Id"] = one.weightMethod; //obj["F_QualityLevel_Id"] = one.qualityLevel; //obj["F_EdgeState_Id"] = one.edgeState; ////obj["F_Surface"] = one.surface; ////obj["F_MQuailty_Id"] = one.mQuailty; ////obj["F_Category_Id"] = one.category; //obj["F_Standard_Id"] = one.standard; //obj["F_Origin_Id"] = one.origin; //obj["F_PCategory_Id"] = one.pCategory; //obj["FMATERIALID_Id"] = one.masterId; //obj["F_BEM_billseq"] = one.seq; //obj["FLOT_Id"] = one.FLotNo; //obj["F_BEM_billentryid"] = one.entryid; //obj["F_BEM_billno"] = one.FBILLNO; this.View.Model.SetValue("F_QANo", one.qano, seq); this.View.Model.SetValue("F_RealLength", one.RealLength, seq); this.View.Model.SetValue("F_RealWidth", one.RealWidth, seq); this.View.Model.SetValue("F_RealThinkness", one.RealThinkness, seq); this.View.Model.SetValue("F_Length", one.Length, seq); this.View.Model.SetValue("F_Width", one.Width, seq); this.View.Model.SetValue("F_Thinkness", one.Thinkness, seq); this.View.Model.SetValue("F_Specification", one.Specification, seq); this.View.Model.SetValue("F_CContent", one.CContent, seq); this.View.Model.SetValue("F_CrContent", one.CrContent, seq); this.View.Model.SetValue("F_ElementRemark", one.ElementRemark, seq); this.View.Model.SetValue("F_PerRemark", one.PerRemark, seq); this.View.Model.SetValue("F_SurfaceRemark", one.SurfaceRemark, seq); this.View.Model.SetValue("F_OtherRemaek", one.OtherRemaek, seq); this.View.Model.SetValue("F_WeightMethod", one.weightMethod, seq); this.View.Model.SetValue("F_QualityLevel", one.qualityLevel, seq); this.View.Model.SetValue("F_EdgeState", one.edgeState, seq); this.View.Model.SetValue("F_Surface", one.surface, seq); this.View.Model.SetValue("F_MQuailty", one.mQuailty, seq); this.View.Model.SetValue("F_Category", one.category, seq); this.View.Model.SetValue("F_Standard", one.standard, seq); this.View.Model.SetValue("F_Origin", one.origin, seq); this.View.Model.SetValue("F_PCategory", one.pCategory, seq); this.View.Model.SetValue("FMATERIALID", one.masterId, seq); this.View.Model.SetValue("F_BEM_billseq", one.seq, seq); this.View.Model.SetValue("FLOT", one.FLotNo, seq); this.View.Model.SetValue("F_BEM_billentryid", one.entryid, seq); this.View.Model.SetValue("F_BEM_billno", one.FBILLNO, seq); this.View.Model.SetEntryCurrentRowIndex("FEntity", seq); obj["Seq"] = ++seq; } this.View.UpdateView("FEntity"); } }
/// <summary> /// 主单据体的字段携带完毕,与源单的关联关系创建好之后,触发此事件 /// </summary> /// <param name="e"></param> public override void OnAfterCreateLink(CreateLinkEventArgs e) { // 预先获取一些必要的元数据,后续代码要用到: // 源单第二单据体 Entity srcSecondEntity = e.SourceBusinessInfo.GetEntity("F_PAEZ_OtherEntity"); // 目标单第一单据体 Entity destMainEntity = e.TargetBusinessInfo.GetEntity("FEntity"); // 目标单第二单据体 Entity destSecondEntity = e.TargetBusinessInfo.GetEntity("F_PAEZ_OtherEntity"); // 目标单关联子单据体 Entity linkEntity = null; Form form = e.TargetBusinessInfo.GetForm(); if (form.LinkSet != null && form.LinkSet.LinkEntitys != null && form.LinkSet.LinkEntitys.Count != 0) { linkEntity = e.TargetBusinessInfo.GetEntity( form.LinkSet.LinkEntitys[0].Key); } if (linkEntity == null) { return; } // 获取生成的全部下游单据 ExtendedDataEntity[] billDataEntitys = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead"); // 对下游单据,逐张单据进行处理 foreach (var item in billDataEntitys) { DynamicObject destBillObject = item.DataEntity; // 定义一个集合,用于收集本单对应的源单内码 HashSet <long> srcBillIds = new HashSet <long>(); // 开始到主单据体中,读取关联的源单内码 DynamicObjectCollection destMainEntryRows = destMainEntity.DynamicProperty.GetValue(destBillObject) as DynamicObjectCollection; foreach (var mainEntityRow in destMainEntryRows) { DynamicObjectCollection linkRows = linkEntity.DynamicProperty.GetValue(mainEntityRow) as DynamicObjectCollection; foreach (var linkRow in linkRows) { long srcBillId = Convert.ToInt64(linkRow["SBillId"]); if (srcBillId != 0 && srcBillIds.Contains(srcBillId) == false) { srcBillIds.Add(srcBillId); } } } if (srcBillIds.Count == 0) { continue; } // 开始加载源单第二单据体上的字段 // 确定需要加载的源单字段(仅加载需要携带的字段) List <SelectorItemInfo> selector = new List <SelectorItemInfo>(); selector.Add(new SelectorItemInfo("F_PAEZ_Desc")); // TODO: 继续添加其他需要携带的字段,示例代码略 // 设置过滤条件 string filter = string.Format(" {0} IN ({1}) ", e.SourceBusinessInfo.GetForm().PkFieldName, string.Join(",", srcBillIds)); OQLFilter filterObj = OQLFilter.CreateHeadEntityFilter(filter); // 读取源单 IViewService viewService = ServiceHelper.GetService <IViewService>(); var srcBillObjs = viewService.Load(this.Context, e.SourceBusinessInfo.GetForm().Id, selector, filterObj); // 开始把源单单据体数据,填写到目标单上 DynamicObjectCollection destSecondEntryRows = destSecondEntity.DynamicProperty.GetValue(destBillObject) as DynamicObjectCollection; destSecondEntryRows.Clear(); // 删除空行 foreach (var srcBillObj in srcBillObjs) { DynamicObjectCollection srcEntryRows = srcSecondEntity.DynamicProperty.GetValue(srcBillObj) as DynamicObjectCollection; foreach (var srcEntryRow in srcEntryRows) { // 目标单添加新行,并接受源单字段值 DynamicObject newRow = new DynamicObject(destSecondEntity.DynamicObjectType); destSecondEntryRows.Add(newRow); // 填写字段值 newRow["F_PAEZ_Desc"] = srcEntryRow["F_PAEZ_Desc"]; // TODO: 逐个填写其他字段值,示例代码略 } } } }
private void UpdateData() { string strSql = string.Format(@"/*dialect*/select /*移动BOS-产品*/ b.fshortname fname, sum(outqty) + sum(fbaseqty) - sum(returnqty0) ftakenum, sum(outqty) - sum(returnqty0) outqty, sum(fbaseqty) fbaseqty, sum(returnqty) returnqty from ( --出库单 select a.fmaterialid, 0 fqty, a.frealqty outqty, 0 fbaseqty, 0 returnqty, 0 returnqty0 from t_sal_outstockentry a join t_sal_outstock b on a.fid = b.fid join t_bd_customer c on b.fcustomerid = c.fcustid where b.fline = {0} and b.fdate = trunc(sysdate) and b.fdocumentstatus = 'C' union all --及时库存 select zz.fmaterialid, 0, 0 outqty, zz.fbaseqty, 0 returnqty, 0 from (select t04.fmaterialid, 0, 0 outqty, sum(t0.fbaseqty) fbaseqty, 0 returnqty, 0 from t_stk_inventory t0 left outer join t_bd_material t04 on t0.fmaterialid = t04.fmaterialid left outer join t_bd_materialbase t04base on t04.fmaterialid = t04base.fmaterialid left outer join t_bas_flexvaluesdetail t07 on t0.fstocklocid = t07.fid join t_tl_line line on t0.fstockid = line.flinestock where line.fid = {0} group by t04.fmaterialid, t04.fnumber, t0.fstockid) zz where zz.fbaseqty > 0 union all --退货 select a.fmaterialid, 0, 0 outqty, 0 fbaseqty, a.frealqty returnqty, 0 from t_sal_returnstockentry a join t_sal_returnstock b on a.fid = b.fid where b.fline = {0} and b.freturntype0 = '1' and b.fdate = trunc(sysdate) and b.fdocumentstatus = 'C' union all --出库单补差 select a.fmaterialid, 0, 0 outqty, 0 fbaseqty, a.frealqty returnqty, 0 from t_sal_outstockentry a join t_sal_outstock b on a.fid = b.fid join t_bd_customer c on b.fcustomerid = c.fcustid and c.fkhbd = '1' where b.fline = {0} and b.fdate = trunc(sysdate) and b.fdocumentstatus = 'C' union all --正品退货 select a.fmaterialid, 0, 0 outqty, 0 fbaseqty, 0, a.frealqty returnqty0 from t_sal_returnstockentry a join t_sal_returnstock b on a.fid = b.fid where b.fline = {0} and b.freturntype0 = '2' and b.fdate = trunc(sysdate) and b.fdocumentstatus = 'C') a join t_bd_material_l b on a.fmaterialid = b.fmaterialid join t_bd_material e on e.fmaterialid = b.fmaterialid group by b.fshortname order by max(e.fno) ", this.curCustId); DynamicObjectCollection source = DBUtils.ExecuteDynamicObject(base.Context, strSql); if (source.Count() > 0) { DynamicObjectCollection objects2 = this.Model.DataObject["FMobileListViewEntity"] as DynamicObjectCollection; objects2.Clear(); base.View.Model.BeginIniti(); for (int i = 0; i < source.Count <DynamicObject>(); i++) { base.View.Model.CreateNewEntryRow("FMobileListViewEntity"); objects2[i]["FNAME"] = source[i]["FNAME"]; objects2[i]["FPICKUP"] = source[i]["FTAKENUM"]; objects2[i]["FSONG"] = source[i]["OUTQTY"]; objects2[i]["FLEFT"] = source[i]["FBASEQTY"]; objects2[i]["FRETURN"] = source[i]["RETURNQTY"]; } base.View.Model.EndIniti(); base.View.UpdateView(); } }
private void ShowErrTypeInfo() { long curStockOrgId; Entity entryEntity = this.View.BusinessInfo.GetEntryEntity("FEntityErrType"); DynamicObjectType dynamicObjectType = entryEntity.DynamicObjectType; DynamicObjectCollection entityDataObject = this.Model.GetEntityDataObject(entryEntity); entityDataObject.Clear(); if ((this.opResults == null) || (this.opResults.Count < 1)) { this.ClearEntity("FEntityErrInfo"); this.ShowHideErrTabDetail(null, ErrType.None); this.View.UpdateView("FEntityErrType"); this.ShowErrGrid(true); } else { int entryCurrentRowIndex = this.Model.GetEntryCurrentRowIndex("FEntityAction"); curStockOrgId = Convert.ToInt64(this.Model.GetValue("FStockOrgID", entryCurrentRowIndex)); StockOrgOperateResult result = this.opResults.SingleOrDefault <StockOrgOperateResult>(p => p.StockOrgID == curStockOrgId); if ((result == null) || result.OperateSuccess) { this.ClearEntity("FEntityErrInfo"); this.ShowHideErrTabDetail(null, ErrType.None); this.View.UpdateView("FEntityErrType"); this.ShowErrGrid(true); } else { DynamicObject obj2; if ((result.ErrInfo != null) && result.ErrInfo.Exists(p => p.ErrType < Convert.ToInt32(ErrType.UnAuditBill))) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.OrgStatusErr, ["ErrTypeName"] = string.Format(ResManager.LoadKDString("当前组织状态不符合{0}操作条件", "004023030002140", SubSystemType.SCM, new object[0]), this.isOpenAccount ? ResManager.LoadKDString("反关账", "004023030000238", SubSystemType.SCM, new object[0]) : ResManager.LoadKDString("关账", "004023030000241", SubSystemType.SCM, new object[0])) }; entityDataObject.Add(obj2); } if ((result.ErrInfo != null) && result.ErrInfo.Exists(p => p.ErrType == Convert.ToInt32(ErrType.UnAuditBill))) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.UnAuditBill, ["ErrTypeName"] = string.Format(ResManager.LoadKDString("当前组织存在未审核的库存单据", "004023030002143", SubSystemType.SCM, new object[0]), new object[0]) }; entityDataObject.Add(obj2); } if ((result.StkBillDraftErrInfo != null) && (result.StkBillDraftErrInfo.Count > 0)) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.StkDraftBill, ["ErrTypeName"] = ResManager.LoadKDString("当前组织存在暂存的库存单据", "004023000022222", SubSystemType.SCM, new object[0]) }; entityDataObject.Add(obj2); } if ((result.StkCountBillAuditErrInfo != null) && (result.StkCountBillAuditErrInfo.Count > 0)) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.UnAuditStkCountBill, ["ErrTypeName"] = ResManager.LoadKDString("当前组织存在未审核的盘点单据", "004023000018755", SubSystemType.SCM, new object[0]) }; entityDataObject.Add(obj2); } if (result.MinusErrObject != null) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.Minus, ["ErrTypeName"] = string.Format(ResManager.LoadKDString("当前组织存在异常库存数据", "004023030002146", SubSystemType.SCM, new object[0]), new object[0]) }; entityDataObject.Add(obj2); } this.View.UpdateView("FEntityErrType"); this.View.SetEntityFocusRow("FEntityErrType", 0); this.ShowErrInfo(); } } }
private void BuildSerial(ExtendedDataEntity[] entryDataes) { List <long> col = (from s in entryDataes from ss in s.DataEntity["FEntity_Link"] as DynamicObjectCollection select ss.GetDynamicObjectItemValue <long>("SId", 0L)).Distinct <long>().ToList <long>(); if (!col.IsEmpty <long>()) { IEnumerable <DynamicObject> purSNInfo = Kingdee.K3.MFG.App.AppServiceContext.GetService <IInspectSrcService>().GetPurSNInfo(base.Context, col); if (purSNInfo.IsEmpty <DynamicObject>()) { foreach (ExtendedDataEntity entity in entryDataes) { entity.DataEntity.SetDynamicObjectItemValue("SNUnitID_Id", 0); entity.DataEntity.SetDynamicObjectItemValue("SNUnitID", null); } } else { Dictionary <long, IGrouping <long, DynamicObject> > dictionary = (from g in purSNInfo where g.GetDynamicValue <long>("FIBENTRYID", 0L) <= 0L group g by g.GetDynamicValue <long>("FENTRYID", 0L)).ToDictionary <IGrouping <long, DynamicObject>, long>(d => d.Key); FormMetadata metadata = (FormMetadata)Kingdee.K3.MFG.App.AppServiceContext.MetadataService.Load(base.Context, "QM_InspectBill", true); Entity entity2 = metadata.BusinessInfo.GetEntity("FEntity"); foreach (ExtendedDataEntity entity3 in entryDataes) { DynamicObject dataEntity = entity3.DataEntity; DynamicObjectCollection objects = dataEntity.GetDynamicValue <DynamicObjectCollection>("FEntity_Link", null); dataEntity.GetDynamicValue <long>("SrcEntryId", 0L); DynamicObjectCollection source = dataEntity.GetDynamicValue <DynamicObjectCollection>("PolicyDetail", null); DynamicObject obj3 = source.First <DynamicObject>() as DynamicObject; List <DynamicObject> list2 = new List <DynamicObject>(); foreach (DynamicObject obj4 in objects) { long key = obj4.GetDynamicValue <long>("SId", 0L); IGrouping <long, DynamicObject> grouping = null; if (dictionary.TryGetValue(key, out grouping)) { foreach (DynamicObject obj5 in grouping) { list2.Add(obj5); } } } if (list2.All <DynamicObject>(a => a.GetDynamicValue <long>("FSERIALID", 0L) <= 0L)) { dataEntity.SetDynamicObjectItemValue("SNUnitID_Id", 0); dataEntity.SetDynamicObjectItemValue("SNUnitID", null); } else { source.Clear(); List <DynamicObject> list3 = (from s in list2 orderby s.GetDynamicValue <string>("FSERIALNO", null) select s).ToList <DynamicObject>(); List <DynamicObject> list4 = (from s in list3 where !s.GetDynamicValue <string>("FSERIALNO", null).IsNullOrEmptyOrWhiteSpace() select s).ToList <DynamicObject>(); List <DynamicObject> collection = (from s in list3 where s.GetDynamicValue <string>("FSERIALNO", null).IsNullOrEmptyOrWhiteSpace() select s).ToList <DynamicObject>(); list4.AddRange(collection); int num2 = 1; DynamicObject baseUnitInfo = dataEntity.GetDynamicValue <DynamicObject>("BaseUnitId", null); DynamicObject unitInfo = dataEntity.GetDynamicValue <DynamicObject>("SNUnitID", null); foreach (DynamicObject obj8 in list4) { DynamicObject dynamicObject = obj3 as DynamicObject; dynamicObject.SetDynamicObjectItemValue("PolicyQty", 1); decimal num3 = MFGQtyConvertUtil.getToBasePrecisionQty(base.Context, dynamicObject.GetDynamicValue <long>("PolicyMaterialId_Id", 0L), unitInfo, baseUnitInfo, 1M); dynamicObject.SetDynamicObjectItemValue("BasePolicyQty", num3); dynamicObject.SetDynamicObjectItemValue("Seq", num2++); if (obj8.GetDynamicValue <int>("FSERIALID", 0) != 0) { dynamicObject.SetDynamicObjectItemValue("SerialId_Id", obj8.GetDynamicValue <int>("FSERIALID", 0)); } source.Add(dynamicObject); } } } Kingdee.K3.MFG.App.AppServiceContext.DBService.LoadReferenceObject(base.Context, (from s in entryDataes select s.DataEntity).ToArray <DynamicObject>(), entity2.DynamicObjectType, true); foreach (ExtendedDataEntity entity4 in entryDataes) { DynamicObject obj10 = entity4.DataEntity; DynamicObject obj11 = obj10.GetDynamicValue <DynamicObject>("BaseUnitId", null); DynamicObject obj12 = obj10.GetDynamicValue <DynamicObject>("SNUnitID", null); if (!obj12.IsNullOrEmpty()) { DynamicObjectCollection objects3 = obj10.GetDynamicValue <DynamicObjectCollection>("PolicyDetail", null); decimal num4 = MFGQtyConvertUtil.getToBasePrecisionQty(base.Context, objects3.FirstOrDefault <DynamicObject>().GetDynamicValue <long>("PolicyMaterialId_Id", 0L), obj12, obj11, 1M); foreach (DynamicObject obj13 in objects3) { obj13.SetDynamicObjectItemValue("BasePolicyQty", num4); } } } } } }
private void SplitData(AfterConvertEventArgs e) { ExtendedDataEntity[] source = e.Result.FindByEntityKey("FEntity"); string billTypeId = (source.FirstOrDefault <ExtendedDataEntity>().DataEntity.Parent as DynamicObject).GetDynamicObjectItemValue <string>("FBillTypeID_Id", null); DynamicObject dynamicObject = Kingdee.K3.MFG.App.AppServiceContext.BusinessDataService.LoadBillTypePara(base.Context, "InspectBillTPS", billTypeId, true); string str2 = dynamicObject.GetDynamicObjectItemValue <string>("SPLITBY", null); if ((!dynamicObject.IsNullOrEmpty() && !str2.EqualsIgnoreCase("A")) && !str2.IsNullOrEmptyOrWhiteSpace()) { List <long> materialIds = (from s in source select s.DataEntity.GetDynamicValue <long>("MaterialId_Id", 0L)).ToList <long>(); Dictionary <long, Tuple <long, long> > inspectorInfo = Kingdee.K3.MFG.App.AppServiceContext.GetService <IInspectService>().GetInspectorInfo(base.Context, materialIds); if (!inspectorInfo.IsEmpty <KeyValuePair <long, Tuple <long, long> > >()) { ExtendedDataEntity[] entityArray2 = e.Result.FindByEntityKey("FBillHead"); List <ExtendedDataEntity> list2 = new List <ExtendedDataEntity>(); foreach (ExtendedDataEntity entity in entityArray2) { Dictionary <long, ExtendedDataEntity> dictionary2 = new Dictionary <long, ExtendedDataEntity>(); foreach (DynamicObject obj3 in entity.DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null)) { Tuple <long, long> tuple; long key = obj3.GetDynamicValue <long>("MaterialId_Id", 0L); if (inspectorInfo.TryGetValue(key, out tuple)) { long num2 = str2.EqualsIgnoreCase("B") ? tuple.Item1 : tuple.Item2; if (dictionary2.Keys.Contains <long>(num2)) { dictionary2[num2].DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null).Add(obj3); } else { ExtendedDataEntity entity2 = (ExtendedDataEntity)entity.Clone(); DynamicObjectCollection objects3 = entity2.DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null); objects3.Clear(); objects3.Add(obj3); if (str2.EqualsIgnoreCase("B")) { entity2.DataEntity.SetDynamicObjectItemValue("InspectGroupId_Id", tuple.Item1); } else if (str2.EqualsIgnoreCase("C")) { entity2.DataEntity.SetDynamicObjectItemValue("InspectorId_Id", tuple.Item2); } dictionary2.Add(num2, entity2); } } } list2.AddRange(dictionary2.Values); dictionary2.Clear(); } DynamicObject[] col = (from s in list2 select s.DataEntity).ToArray <DynamicObject>(); if (!col.IsEmpty <DynamicObject>()) { Kingdee.K3.MFG.App.AppServiceContext.DBService.LoadReferenceObject(base.Context, col, col.FirstOrDefault <DynamicObject>().DynamicObjectType, true); for (int i = 0; i < entityArray2.Length; i++) { e.Result.RemoveExtendedDataEntity("FBillHead", 0);//原来e.Result.RemoveExtendedDataEntity("FBillHead",i) } e.Result.AddExtendedDataEntities("FBillHead", list2.ToArray()); } } } }
public override void OnAfterCreateLink(CreateLinkEventArgs e) { base.OnAfterCreateLink(e); //源单 Entity srcFEntity = e.SourceBusinessInfo.GetEntity("FEntity"); Entity srcFEntityBPR = e.SourceBusinessInfo.GetEntity("FEntityBPR"); Entity srcFEntityM = e.SourceBusinessInfo.GetEntity("FEntityM"); //Entity srcFEntityHD = e.SourceBusinessInfo.GetEntity("FEntityHD"); //目标单 Entity tgtFEntity = e.TargetBusinessInfo.GetEntity("FEntity"); Entity tgtFEntityBPR = e.TargetBusinessInfo.GetEntity("FEntityBPR"); Entity tgtFEntityM = e.TargetBusinessInfo.GetEntity("FEntityM"); //Entity tgtFEntityHD = e.TargetBusinessInfo.GetEntity("FEntityHD"); var billDataEntitys = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead"); foreach (var item in billDataEntitys) { DynamicObject dataObject = item.DataEntity; string sql = string.Format("select * from ora_CRM_Contract where FBillNo='{0}'", dataObject["FNicheID"].ToString()); var pkIDs = CZDB_GetData(sql); if (pkIDs.Count <= 0) { continue; } string FID = pkIDs[0]["FID"].ToString(); //加载源单数据 IViewService viewService = ServiceHelper.GetService <IViewService>(); sql = string.Format("select FEntryID from ora_CRM_ContractEntry where FID='{0}'", FID); var srcFEntityEIDs = CZDB_GetData(sql); if (srcFEntityEIDs.Count > 0) { object[] objs = new object[srcFEntityEIDs.Count]; for (int i = 0; i < srcFEntityEIDs.Count; i++) { objs[i] = srcFEntityEIDs[i]["FEntryID"].ToString(); } var srcFEntityBillObjs = viewService.Load(this.Context, objs, srcFEntity.DynamicObjectType); // 开始把源单单据体数据,填写到目标单上 DynamicObjectCollection tgtFEntityRows = tgtFEntity.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; tgtFEntityRows.Clear(); foreach (var srcRow in srcFEntityBillObjs) { DynamicObject newRow = new DynamicObject(tgtFEntity.DynamicObjectType); tgtFEntityRows.Add(newRow); newRow["FMtlGroup"] = srcRow["FMtlGroup"]; newRow["FDescribe"] = srcRow["FDescribe"]; newRow["FQty"] = srcRow["FQty"]; newRow["FModel"] = srcRow["FModel"]; newRow["FIsStandard"] = srcRow["FIsStandard"]; newRow["FBPRndID"] = srcRow["FBPRndID"]; newRow["FBRndNo"] = srcRow["FBRndNo"]; newRow["FGUID"] = srcRow["FGUID"]; newRow["FIS2W"] = srcRow["FIS2W"]; } } /* * sql = string.Format("select FBEntryID from ora_CRM_ContractBPR where FID='{0}'", FID); * var srcFEntityBPREIDs = CZDB_GetData(sql); * if (srcFEntityBPREIDs.Count > 0) * { * object[] objs = new object[srcFEntityBPREIDs.Count]; * for (int i = 0; i < srcFEntityBPREIDs.Count; i++) * { * objs[i] = srcFEntityBPREIDs[i]["FBEntryID"].ToString(); * } * var srcFEntityBPRBillObjs = viewService.Load(this.Context, objs, srcFEntityBPR.DynamicObjectType); * DynamicObjectCollection tgtFEntityBPRRows = tgtFEntityBPR.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; * tgtFEntityBPRRows.Clear(); * foreach (var srcRow in srcFEntityBPRBillObjs) * { * DynamicObject newRow = new DynamicObject(tgtFEntityBPR.DynamicObjectType); * tgtFEntityBPRRows.Add(newRow); * //newRow["BSEQ"] = srcRow["BSEQ"]; * newRow["FBGUID"] = srcRow["FBGUID"]; * newRow["FBSrcEID"] = srcRow["FBSrcEID"]; * newRow["FBSrcSEQ"] = srcRow["FBSrcSEQ"]; * newRow["FBPRndSEQ"] = srcRow["FBPRndSEQ"]; * newRow["FBMtlGroup"] = srcRow["FBMtlGroup"]; * newRow["FBMtlItem"] = srcRow["FBMtlItem"]; * newRow["FMaterialID"] = srcRow["FMaterialID"]; * newRow["FBDescribe"] = srcRow["FBDescribe"]; * newRow["FBQty"] = srcRow["FBQty"]; * newRow["FBModel"] = srcRow["FBModel"]; * newRow["FBIsStandard"] = srcRow["FBIsStandard"]; * newRow["FBasePrice"] = srcRow["FBasePrice"]; * newRow["FBPAmt"] = srcRow["FBPAmt"]; * newRow["FBPAmtGroup"] = srcRow["FBPAmtGroup"]; * newRow["FBRptPrice"] = srcRow["FBRptPrice"]; * newRow["FBAbaComm"] = srcRow["FBAbaComm"]; * newRow["FBDownPoints"] = srcRow["FBDownPoints"]; * newRow["FBWorkDay"] = srcRow["FBWorkDay"]; * newRow["FBCostAdj"] = srcRow["FBCostAdj"]; * newRow["FBCAReason"] = srcRow["FBCAReason"]; * newRow["FBDelivery"] = srcRow["FBDelivery"]; * newRow["FBPAmtLc"] = srcRow["FBPAmtLc"]; * newRow["FBRptPrcLc"] = srcRow["FBRptPrcLc"]; * newRow["FBIS2W"] = srcRow["FBIS2W"]; * newRow["FBUnitID"] = srcRow["FBUnitID"]; * newRow["FBTaxRateID"] = srcRow["FBTaxRateID"]; * newRow["FBTaxRate"] = srcRow["FBTaxRate"]; * newRow["FBBomVsn"] = srcRow["FBBomVsn"]; * newRow["FBTaxPrice"] = srcRow["FBTaxPrice"]; * newRow["FBNTPrice"] = srcRow["FBNTPrice"]; * newRow["FBTaxAmt"] = srcRow["FBTaxAmt"]; * newRow["FBNTAmt"] = srcRow["FBNTAmt"]; * * newRow["FBRangeAmtOne"] = srcRow["FBRangeAmtOne"]; * newRow["FBRangeAmtGP"] = srcRow["FBRangeAmtGP"]; * newRow["FBRangeAmtReason"] = srcRow["FBRangeAmtReason"]; * newRow["FProdFactory"] = srcRow["FProdFactory"]; * //newRow["FBLkQty"] = srcRow["FBLkQty"]; * } * } */ sql = string.Format("select FEntryIDM from ora_CRM_ContractMtl where FID='{0}'", FID); var srcFEntityMEIDs = CZDB_GetData(sql); if (srcFEntityMEIDs.Count > 0) { object[] objs = new object[srcFEntityMEIDs.Count]; for (int i = 0; i < srcFEntityMEIDs.Count; i++) { objs[i] = srcFEntityMEIDs[i]["FEntryIDM"].ToString(); } var srcFEntityMBillObjs = viewService.Load(this.Context, objs, srcFEntityM.DynamicObjectType); DynamicObjectCollection tgtFEntityMRows = tgtFEntityM.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; tgtFEntityMRows.Clear(); foreach (var srcRow in srcFEntityMBillObjs) { DynamicObject newRow = new DynamicObject(tgtFEntityM.DynamicObjectType); tgtFEntityMRows.Add(newRow); newRow["FMGUID"] = srcRow["FMGUID"]; newRow["FMSrcEID"] = srcRow["FMSrcEID"]; newRow["FMSrcSEQ"] = srcRow["FMSrcSEQ"]; newRow["FMMtlGroup"] = srcRow["FMMtlGroup"]; newRow["FMMtlItem"] = srcRow["FMMtlItem"]; newRow["FMClass"] = srcRow["FMClass"]; newRow["FMMtl"] = srcRow["FMMtl"]; newRow["FMModel"] = srcRow["FMModel"]; newRow["FMQty"] = srcRow["FMQty"]; newRow["FMUnit"] = srcRow["FMUnit"]; newRow["FMPrice"] = srcRow["FMPrice"]; newRow["FMAmt"] = srcRow["FMAmt"]; newRow["FMGpAmtB"] = srcRow["FMGpAmtB"]; newRow["FMCostRate"] = srcRow["FMCostRate"]; newRow["FMCost"] = srcRow["FMCost"]; newRow["FMGPRate"] = srcRow["FMGPRate"]; newRow["FMGP"] = srcRow["FMGP"]; newRow["FMGpAmt"] = srcRow["FMGpAmt"]; newRow["FMGpAmtLc"] = srcRow["FMGpAmtLc"]; newRow["FMIS2W"] = srcRow["FMIS2W"]; } } } }