Exemplo n.º 1
0
        private void GetCustInfo(long lCustid)
        {
            List <SelectorItemInfo> selector = new List <SelectorItemInfo> {
                new SelectorItemInfo("FWEBSITE"),
                new SelectorItemInfo("FFAX"),
                new SelectorItemInfo("FADDRESS")
            };
            OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter($"FCustID={lCustid}");

            DynamicObject[] objArray = BusinessDataServiceHelper.Load(base.Context, "CRM_CUST", selector, ofilter);
            string          str      = "";
            string          str2     = "";
            string          str3     = "";

            if ((objArray != null) && (objArray.Length > 0))
            {
                DynamicObject obj2 = objArray[0];
                str  = obj2["WEBSITE"].ToString();
                str2 = obj2["FAX"].ToString();
                str3 = obj2["ADDRESS"].ToString();
                base.View.Model.SetValue("FHomePage", str);
                base.View.Model.SetValue("FFax", str2);
                base.View.Model.SetValue("FAddress", str3);
            }
        }
Exemplo n.º 2
0
        public override void OnParseFilterOptions(ParseFilterOptionsEventArgs e)
        {
            string MaterialQualityDTF       = Convert.ToString(e.TargetData["F_PAEZ_Material_Id"]);
            string MaterialQualityFilterDTF = "";

            //先查物料表 查出物料ID 然后去即时库存表查
            DynamicObject[] lotMasters = null;
            string          filter     = string.Format("F_BEM_CZ ='{0}'", MaterialQualityDTF);
            OQLFilter       of         = OQLFilter.CreateHeadEntityFilter(filter);

            lotMasters = BusinessDataServiceHelper.Load(this.Context, "BD_MATERIAL", null, of);

            if (lotMasters.Count() > 0)
            {
                foreach (DynamicObject objma in lotMasters)
                {
                    materialList.Add(Convert.ToString(objma[0]));
                }
            }

            MaterialQualityFilterDTF = String.Format(" FMATERIALID in ('{0}')", string.Join("','", materialList));

            if (String.IsNullOrEmpty(e.FilterOptionsSQL))
            {
                e.FilterOptionsSQL = MaterialQualityFilterDTF;
            }
        }
Exemplo n.º 3
0
        public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
        {
            if (e.BarItemKey.Equals("tbsave"))
            {
                long entryid = 0;

                getTableName();
                Entity entity = this.View.BusinessInfo.GetEntity("FEntity");
                DynamicObjectCollection objs       = this.View.Model.GetEntityDataObject(entity);
                DynamicObject[]         lotMasters = null;
                if (!lotIds.IsEmpty() && !lotIds.Equals("0"))
                {
                    string    filter = string.Format("FLOTID IN ('{0}')", lotIds);
                    OQLFilter of     = OQLFilter.CreateHeadEntityFilter(filter);
                    lotMasters = BusinessDataServiceHelper.Load(this.Context, "BD_BatchMainFile", null, of);
                }
                foreach (DynamicObject obj in objs)
                {
                    value   = obj["F_QANo"];
                    entryid = Convert.ToInt64(obj["F_BEM_billentryid"]);
                    if (entryid == 0)
                    {
                        continue;
                    }
                    foreach (DynamicObject lotobj in lotMasters)
                    {
                        if (lotobj["id"].Equals(obj["FLOT_Id"]))
                        {
                            lotobj["F_QANo"] = obj["F_QANo"];
                        }
                    }

                    updateSqls.Add(string.Format(@"UPDATE  {0}  set F_QANo ='{1}'  WHERE fentryid  = {2}  ", tableName, value, entryid));
                }

                ISaveService service = Kingdee.BOS.App.ServiceHelper.GetService <ISaveService>();
                service.Save(this.Context, lotMasters);
                DBUtils.ExecuteBatch(this.Context, updateSqls, updateSqls.Count);
                //返回值到父窗口
                this.View.ReturnToParentWindow("true");
                this.View.Close();
            }
            base.AfterBarItemClick(e);
        }
Exemplo n.º 4
0
        public override void OnParseFilterOptions(ParseFilterOptionsEventArgs e)
        {
            string PRODMaterialQuality       = Convert.ToString(e.TargetData["F_PAEZ_Material_Id"]);
            string MaterialQualityFilterProd = "";

            int a = e.SourceBusinessInfo.GetEntryCount();

            Entity        FillStatus    = e.SourceBusinessInfo.GetEntity("FBillHead");
            DynamicObject FillStatusObj = new DynamicObject(FillStatus.DynamicObjectType);

            string FillStatusSqlFilter = Convert.ToString(FillStatusObj["FBillStatus"]);


            //先查物料表 查出物料ID 然后去合同信息过滤数据
            DynamicObject[] lotMasters = null;
            string          filter     = string.Format("F_BEM_CZ ='{0}'", PRODMaterialQuality);
            OQLFilter       of         = OQLFilter.CreateHeadEntityFilter(filter);

            lotMasters = BusinessDataServiceHelper.Load(this.Context, "BD_MATERIAL", null, of);

            if (lotMasters.Count() > 0)
            {
                foreach (DynamicObject objma in lotMasters)
                {
                    materialList.Add(Convert.ToString(objma[0]));
                }
            }



            string sqlSearchCondition = " FMATERIALID in ('{0}')" + string.Join("','", materialList);


            //      MaterialQualityFilterProd = sqlSearchCondition;

            if (String.IsNullOrEmpty(e.FilterOptionsSQL))
            {
                e.FilterOptionsSQL = sqlSearchCondition;
            }
        }
        private DynamicObject[] LoadPurchaseOrder(HashSet <string> poBillNos)
        {
            IViewService viewService = ServiceHelper.GetService <IViewService>();
            string       formId      = "PUR_PurchaseOrder";

            // 指定需要加载的采购订单字段
            List <SelectorItemInfo> fields = new List <SelectorItemInfo>();

            fields.Add(new SelectorItemInfo("FID"));                    // 单据主键
            fields.Add(new SelectorItemInfo("FPOOrderEntry_FEntryID")); // 单据体主键
            fields.Add(new SelectorItemInfo("FBillNo"));                // 单据编号
            fields.Add(new SelectorItemInfo("FBFLowId"));               // 业务流程
            fields.Add(new SelectorItemInfo("FMaterialId"));            // 物料
            fields.Add(new SelectorItemInfo(" FBaseUnitQty"));          // 基本单位数量
            fields.Add(new SelectorItemInfo("FBaseJoinQty"));           // 基本单位关联数量
            // 指定过滤条件
            string    filter  = string.Format(" FBillNo IN ('{0}') ", string.Join("','", poBillNos));
            OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter(filter);
            var       objs    = viewService.Load(this.Context, formId, fields, ofilter);

            return(objs);
        }
Exemplo n.º 6
0
        private void GetContactInfo(long lCONTACTID)
        {
            List <SelectorItemInfo> selector = new List <SelectorItemInfo> {
                new SelectorItemInfo("FTel"),
                new SelectorItemInfo("FEMail"),
                new SelectorItemInfo("FDuty"),
                new SelectorItemInfo("FMobile")
            };
            OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter($"FCONTACTID={lCONTACTID}");

            DynamicObject[] objArray = BusinessDataServiceHelper.Load(base.Context, "CRM_CUST_Contact", selector, ofilter);
            string          str      = "";
            string          str2     = "";
            string          str3     = "";
            string          str4     = "";

            if ((objArray != null) && (objArray.Length > 0))
            {
                DynamicObject obj2 = objArray[0];
                str  = obj2["FTel"].ToString();
                str3 = obj2["FEMail"].ToString();
                str2 = obj2["Mobile"].ToString();
                DynamicObjectCollection objects = obj2["T_CRM_Contact"] as DynamicObjectCollection;
                if ((objects != null) && (objects.Count > 0))
                {
                    DynamicObject obj3 = objects[0];
                    if (obj3["FDuty"] != null)
                    {
                        str4 = obj3["FDuty"].ToString();
                    }
                }
                base.View.Model.SetValue("FPhone", str);
                base.View.Model.SetValue("FMobile", str2);
                base.View.Model.SetValue("FEmail", str3);
                base.View.Model.SetValue("FDuty", str4);
            }
        }
Exemplo n.º 7
0
        public override void AfterBindData(EventArgs e)
        {
            base.AfterBindData(e);
            //绑定第一个单据体的数据源

            //可以使用SQL方式获取数据
            //string strSql = "select * from t_pur_poorder where 1=1";
            const string            formId        = "PUR_PurchaseOrder"; //使用采购订单示例
            List <SelectorItemInfo> selectorItems = new List <SelectorItemInfo>
            {
                new SelectorItemInfo("FID"),
                new SelectorItemInfo("FBillNo"),
                new SelectorItemInfo("FSupplierId")
            };
            OQLFilter filter = OQLFilter.CreateHeadEntityFilter("FCREATEDATE > '2014-08-25' AND FCREATEDATE < '2014-08-26' ");
            var       objs   = BusinessDataServiceHelper.Load(this.View.Context, formId, selectorItems, filter);

            if (objs.Length == 0)
            {
                return;
            }

            for (int i = 0; i < objs.Length; i++)
            {
                this.Model.CreateNewEntryRow(HeadEntityKey);
                this.Model.SetValue(HeadFidKey, objs[i]["ID"], i);
                this.Model.SetValue(BillNoKey, objs[i]["BillNo"], i);

                var suplierData = objs[i]["SupplierId"] as DynamicObject;
                if (suplierData != null)
                {
                    this.Model.SetValue(SupplierKey, suplierData["Name"] == null ? string.Empty : suplierData["Name"].ToString(), i);
                }
            }
            this.View.UpdateView(HeadEntityKey);
        }
        /// <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"]));
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取用户
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        DynamicObject GetUser(string userID)
        {
            OQLFilter filter = OQLFilter.CreateHeadEntityFilter(string.Format("FUSERID={0}", userID));

            return(BusinessDataServiceHelper.Load(this.View.Context, FormIdConst.SEC_User, null, filter).FirstOrDefault());
        }
        public BumpAnalysisResultEntrity Get_Bumpfields(string FormID, FormMetadata entitryMeta)
        {
            BumpAnalysisResultEntrity entrity = new BumpAnalysisResultEntrity();

            entrity.BumpAnalysisFields = new Dictionary <string, BumpAnalysisFields>();
            string strFilter = $"FBumpFormID='{FormID}'";

            DynamicObject[] objArray = BusinessDataServiceHelper.Load(this.Context, "CRM_BumpAnalysisSettingEntity", null, OQLFilter.CreateHeadEntityFilter(strFilter));
            if (objArray.Length == 0)
            {
                return(null);
            }
            DynamicObjectCollection objects = (objArray != null) ? ((DynamicObjectCollection)objArray[0]["FEntity"]) : null;
            List <Field>            list    = new List <Field>();
            List <FieldAppearance>  list2   = new List <FieldAppearance>();
            List <BumpTypeField>    list3   = new List <BumpTypeField>();

            if (entrity.ParaFields == null)
            {
                entrity.ParaFields = new Hashtable();
            }
            string str2 = "";

            foreach (DynamicObject obj2 in objects)
            {
                if (obj2["settype"].ToString() == "1")
                {
                    if ((bool)obj2["BUMPSHOW"])
                    {
                        string key  = obj2["FIELDNAME"].ToString();
                        Field  item = entitryMeta.BusinessInfo.GetField(key);
                        if (item != null)
                        {
                            list.Add(item);
                        }
                        FieldAppearance fieldAppearance = entitryMeta.GetLayoutInfo().GetFieldAppearance(key);
                        if (fieldAppearance != null)
                        {
                            list2.Add(fieldAppearance);
                        }
                        if (item != null)
                        {
                            string str4 = item.EntityKey + "_" + item.PropertyName;
                            if (!entrity.BumpAnalysisFields.ContainsKey(str4))
                            {
                                BumpAnalysisFields fields = new BumpAnalysisFields(str4, new BumpTypeField(item), fieldAppearance, true, false);
                                entrity.BumpAnalysisFields.Add(str4, fields);
                            }
                            else
                            {
                                entrity.BumpAnalysisFields[str4].BumpFields           = new BumpTypeField(item);
                                entrity.BumpAnalysisFields[str4].LayoutInfoAppearance = fieldAppearance;
                                entrity.BumpAnalysisFields[str4].IsShowField          = true;
                            }
                        }
                    }
                    if ((bool)obj2["SELECTED"])
                    {
                        string str5 = obj2["FIELDNAME"].ToString();
                        string str6 = this.GetFieldData(this.BillModel.GetValue(str5)).Replace("'", "''");
                        string str7 = obj2["Matching"].ToString();
                        if (!string.IsNullOrEmpty(str6))
                        {
                            str2 = str2 + "or " + str5 + ((str7 == "100") ? ("='" + str6.ToString() + "' ") : (" LIKE '%" + str6.ToString() + "%' "));
                        }
                        Field field = entitryMeta.BusinessInfo.GetField(str5);
                        if (field != null)
                        {
                            list3.Add(new BumpTypeField(field, str7));
                        }
                        if (field != null)
                        {
                            string          str8        = field.EntityKey + "_" + field.PropertyName;
                            FieldAppearance appearance2 = entitryMeta.GetLayoutInfo().GetFieldAppearance(str5);
                            if (!entrity.BumpAnalysisFields.ContainsKey(str8))
                            {
                                BumpAnalysisFields fields2 = new BumpAnalysisFields(str8, new BumpTypeField(field, str7), appearance2, false, true);
                                entrity.BumpAnalysisFields.Add(str8, fields2);
                            }
                            else
                            {
                                entrity.BumpAnalysisFields[str8].BumpFields  = new BumpTypeField(field, str7);
                                entrity.BumpAnalysisFields[str8].IsBumpField = true;
                            }
                        }
                    }
                }
                else if ((obj2["settype"].ToString() == "2") && ((bool)obj2["selected"]))
                {
                    string str9  = obj2["FIELDNAME"].ToString();
                    string str10 = obj2["Matching"].ToString();
                    entrity.ParaFields.Add(str9, str10);
                }
            }
            entrity.BumpFields           = list3;
            entrity.BusinessInfoField    = list;
            entrity.LayoutInfoAppearance = list2;
            return(entrity);
        }
        public void SetData(FormMetadata entitryMeta, string str_result_Filter)
        {
            new List <DynamicObject>();
            DynamicObject[] objArray = BusinessDataServiceHelper.Load(this.Context, entitryMeta.BusinessInfo, null, OQLFilter.CreateHeadEntityFilter(str_result_Filter));
            this.ResultEntrity.DataValue = new List <DynamicObject>();
            Dictionary <string, Hashtable> dictionary = new Dictionary <string, Hashtable>();

            this.ResultEntrity.DataValue = new List <DynamicObject>();
            foreach (DynamicObject obj2 in objArray)
            {
                string    key       = obj2["ID"].ToString();
                bool      flag      = false;
                bool      flag2     = true;
                double    num       = 0.0;
                bool      flag3     = false;
                Hashtable hashtable = new Hashtable();
                foreach (BumpTypeField field in this.ResultEntrity.BumpFields)
                {
                    string fieldName = field.field.FieldName;
                    double num2      = Convert.ToDouble(field.matching);
                    object obj3      = this.BillModel.GetValue(fieldName);
                    string str3      = (obj3 == null) ? "" : this.GetFieldData(obj3);
                    string fieldData = "";
                    if (field.field.EntityKey == "FBillHead")
                    {
                        fieldData = this.GetFieldData(obj2[field.field.PropertyName]);
                    }
                    else
                    {
                        DynamicObject obj4 = ((DynamicObjectCollection)obj2[field.field.Entity.DynamicProperty.Name])[0];
                        fieldData = this.GetFieldData(obj4[field.field.PropertyName]);
                    }
                    //double num3 = ((fieldData.Length == 0) || (fieldData.IndexOf(str3) < 0)) ? 0.0 : (((double)str3.Length) / ((double)fieldData.Length));
                    double num3 = 0.0;
                    if (fieldData.Length > str3.Length)
                    {
                        num3 = ((fieldData.Length == 0) || (fieldData.IndexOf(str3) < 0)) ? 0.0 : (((double)str3.Length) / ((double)fieldData.Length));
                    }
                    else
                    {
                        num3 = ((fieldData.Length == 0) || (str3.IndexOf(fieldData) < 0)) ? 0.0 : (((double)fieldData.Length) / ((double)str3.Length));
                    }
                    double num4 = Math.Round(num3, 4) * 100.0;
                    num += num4;
                    string str5 = num4.ToString() + "%";
                    if ((str3.Trim().Length == 0) || (fieldData.Trim().Length == 0))
                    {
                        str5 = "0%";
                    }
                    hashtable.Add(field.field.EntityKey + "_" + field.field.PropertyName, str5);
                    if (num4 == 100.0)
                    {
                        flag3 = true;
                    }
                    if ((num3 * 100.0) >= num2)
                    {
                        flag = true;
                    }
                }
                num = (this.ResultEntrity.BumpFields.Count == 0) ? 0.0 : (num / ((double)this.ResultEntrity.BumpFields.Count));
                if ((this.ResultEntrity.ParaFields["FAllMatching"] != null) && (num < Convert.ToDouble(this.ResultEntrity.ParaFields["FAllMatching"])))
                {
                    flag2 = false;
                }
                if (this.ResultEntrity.ParaFields["FoneMatching"] == null)
                {
                    flag3 = true;
                }
                if (flag && (flag2 || flag3))
                {
                    dictionary.Add(key, hashtable);
                    this.ResultEntrity.DataValue.Add(obj2);
                }
            }
            this.ResultEntrity.DicMacthDesc = dictionary;
        }
Exemplo n.º 12
0
        /// <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: 逐个填写其他字段值,示例代码略
                    }
                }
            }
        }
        public override void EndOperationTransaction(BOS.Core.DynamicForm.PlugIn.Args.EndOperationTransactionArgs e)
        {
            lotIds.Clear();
            List <SqlObject> sqlList = new List <SqlObject>();

            foreach (var item in e.DataEntitys)
            {
                string formId = "";
                if (item.DynamicObjectType.Name.Equals("InvInit"))
                {
                    formId = "STK_InvInit";
                }
                else
                {
                    formId = item["FFormId"].ToString();
                }

                DynamicObjectCollection details = null;
                switch (formId)
                {
                case "STK_MISCELLANEOUS":
                    details = item["STK_MISCELLANEOUSENTRY"] as DynamicObjectCollection;
                    break;

                case "STK_InStock":
                    details = item["InStockEntry"] as DynamicObjectCollection;
                    break;

                case "SP_InStock":
                    details = item["Entity"] as DynamicObjectCollection;
                    break;

                case "STK_OEMInStock":
                    details = item["OEMInStockEntry"] as DynamicObjectCollection;
                    break;

                case "STK_InitInStock":
                    details = item["InitInStockEntry"] as DynamicObjectCollection;
                    break;

                case "STK_InvInit":
                    details = item["InvInitDetail"] as DynamicObjectCollection;
                    break;

                default: break;
                }
                if (details == null)
                {
                    return;
                }
                foreach (var entryItem in details)
                {
                    Object lotObj = entryItem["LOT"];
                    if (null != lotObj && Convert.ToInt16((lotObj as DynamicObject)["BizType"]) == 1)
                    {
                        sqlList.Add(this.getSqlParams(formId, entryItem, item));
                    }
                }
            }
            if (sqlList.Count > 0 && lotIds.Count > 0)
            {
                DBUtils.ExecuteBatch(this.Context, sqlList);
                string          filter     = string.Format("FLOTID IN ({0})", string.Join(",", lotIds));
                OQLFilter       of         = OQLFilter.CreateHeadEntityFilter(filter);
                DynamicObject[] lotMasters = BusinessDataServiceHelper.Load(this.Context, "BD_BatchMainFile", null, of);
                ISaveService    service    = Kingdee.BOS.App.ServiceHelper.GetService <ISaveService>();
                service.Save(this.Context, lotMasters);
            }
        }
        /// <summary>
        /// 主单据体的字段携带完毕,与源单的关联关系创建好之后,触发此事件
        /// </summary>
        /// <param name="e"></param>
        public override void OnAfterCreateLink(CreateLinkEventArgs e)
        {
            base.OnAfterCreateLink(e);
            //预先获取一些必要的元数据,后续代码要用到
            //源单第一单据体
            Entity srcFirstEntity = e.SourceBusinessInfo.GetEntity("FEntity");

            //目标单第一单据体
            Entity mainEntity = e.TargetBusinessInfo.GetEntity("FEntityDetail");


            // 目标单关联子单据体
            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;
                DynamicObject           mainEntityRow = mainEntryRows[0];
                DynamicObjectCollection linkRows      =
                    linkEntity.DynamicProperty.GetValue(mainEntityRow) as DynamicObjectCollection;
                long srcBillId = Convert.ToInt64(linkRows[0]["SBillId"]);
                if (srcBillId != 0 &&
                    srcBillIds.Contains(srcBillId) == false)
                {
                    srcBillIds.Add(srcBillId);
                }
                if (srcBillIds.Count == 0)
                {
                    continue;
                }
                #region 隐藏
                //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);
                //        }
                //    }
                //}
                //if (srcBillIds.Count == 0)
                //{
                //    continue;
                //}
                #endregion

                // 开始加载源单第二单据体上的字段

                // 确定需要加载的源单字段(仅加载需要携带的字段)
                List <SelectorItemInfo> selector = new List <SelectorItemInfo>();
                selector.Add(new SelectorItemInfo("FDate"));       //日期
                selector.Add(new SelectorItemInfo("FCustomerID")); //客户
                selector.Add(new SelectorItemInfo("FSaleDeptID")); //销售部门
                selector.Add(new SelectorItemInfo("FMaterialID")); //物料
                selector.Add(new SelectorItemInfo("FTaxPrice"));   //含税单价
                // TODO: 继续添加其他需要携带的字段,示例代码略
                // 设置过滤条件
                string filter = string.Format(" {0} IN ({1}) ",
                                              e.SourceBusinessInfo.GetForm().PkFieldName,
                                              string.Join(",", srcBillIds));
                OQLFilter filterObj = OQLFilter.CreateHeadEntityFilter(filter);

                // 读取源单
                Kingdee.BOS.Contracts.IViewService viewService = Kingdee.BOS.App.ServiceHelper.GetService <Kingdee.BOS.Contracts.IViewService>();
                var srcBillObjs = viewService.Load(this.Context,
                                                   e.SourceBusinessInfo.GetForm().Id,
                                                   selector,
                                                   filterObj);
                #region 隐藏
                // 开始把源单单据体数据,填写到目标单上
                //DynamicObjectCollection secondEntryRows =
                //    secondEntity.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection;
                //secondEntryRows.Clear();    // 删除空行
                #endregion

                foreach (DynamicObject srcBillObj in srcBillObjs)
                {
                    DynamicObject dept = srcBillObj["SaleDeptID"] as DynamicObject; //销售部门
                    DynamicObject Cust = srcBillObj["CustomerID"] as DynamicObject; //客户
                    //bool isRight = !Cust["FKHBD"].Equals("1") && !Cust["FKHBD"].Equals("2") ? Convert.ToInt32(Cust["FSAP"]) == 2 : Convert.ToInt32(Cust["FKHBD"]) == 1 ? true: Convert.ToInt32(Cust["FKHBD"]) == 2 ? true:false;
                    //补差、丢货或者客户结算方式是现金
                    bool isRight = (Cust["FKHBD"].Equals("1") || Cust["FKHBD"].Equals("2")) ? true : Convert.ToInt32(Cust["FSAP"]) == 2 ? true : false;
                    //if ((Convert.ToInt32(Cust["FSAP"]) == 2 || Convert.ToInt32(Cust["FKHBD"]) == 1 || Convert.ToInt32(Cust["FKHBD"]) == 2) && Convert.ToInt32(dept["FDEPTTYPE"]) == 4)

                    if (isRight && Convert.ToInt32(dept["FDEPTTYPE"]) == 4)//部门类别外埠
                    {
                        //外埠现金客户执行销售政策折扣
                        Dictionary <string, double> disCounts = TLMBServiceHelper.GetDiscounts(base.Context, Convert.ToInt64(dept["id"]), Convert.ToDateTime(srcBillObj["Date"]));
                        //遍历应收单,通过销售折扣计算折后的含税单价赋值。
                        foreach (DynamicObject mainEntryRow in mainEntryRows)
                        {
                            double discount = 0.0;
                            if (disCounts.TryGetValue(Convert.ToString(((DynamicObject)mainEntryRow["MATERIALID"])["FWLFL"]), out discount))
                            {
                                double ZK = Convert.ToDouble(disCounts["" + Convert.ToString(((DynamicObject)mainEntryRow["MATERIALID"])["FWLFL"]) + ""]);
                                mainEntryRow["TaxPrice"]        = Convert.ToDouble(mainEntryRow["TaxPrice"]) * ZK;
                                mainEntryRow["F_PAEZ_DisCount"] = ZK;
                            }
                        }
                    }

                    //DynamicObjectCollection srcEntryRows =
                    //    srcSecondEntity.DynamicProperty.GetValue(srcBillObj) as DynamicObjectCollection;

                    //foreach (var srcEntryRow in srcEntryRows)
                    //{
                    //    // 目标单添加新行,并接受源单字段值
                    //    DynamicObject newRow = new DynamicObject(secondEntity.DynamicObjectType);
                    //    secondEntryRows.Add(newRow);
                    //    // 填写字段值
                    //    newRow["F_JD_Text"] = srcEntryRow["F_JD_Text"];
                    //    // TODO: 逐个填写其他字段值,示例代码略
                    //}
                }
            }
        }
Exemplo n.º 15
0
        public override void ButtonClick(BOS.Core.DynamicForm.PlugIn.Args.ButtonClickEventArgs e)
        {
            base.ButtonClick(e);
            string PformId = this.View.BillBusinessInfo.GetForm().Id;

            switch (PformId)
            {
            case "STK_InStock":      //采购入库
                tableName = "T_STK_INSTOCKENTRY";
                break;

            case "STK_MISCELLANEOUS":    //其他入库
                tableName = "T_STK_MISCELLANEOUSENTRY";
                break;

            case "SP_InStock":    //简单生产入库
                tableName = "T_SP_INSTOCKENTRY";
                break;

            case "STK_InitInStock":    //期初采购入库
                tableName = "T_STK_INITINSTOCKENTRY";
                break;

            case "STK_OEMInStock":    //受托加工材料入库
                tableName = "T_STK_OEMINSTOCKENTRY";
                break;

            case "STK_InvInit":
                tableName = "T_STK_INVINITDETAIL";
                break;

            default: break;
            }

            //string a;
            //if ((a = e.Key.ToUpper()) != null)
            //{
            //    if (!(a == "FBTNCONFIRM"))
            //    {
            //        if (a == "FBTNCANCEL")
            //        {
            //            this.View.Close();
            //        }
            //    }
            //    else
            //    {
            //value = this.View.Model.GetValue("F_BEM_QANO");
            //if (value == null)
            //{
            //    this.View.ShowMessage("请输入质保书号");
            //    return;
            //}
            if (!lotIds.IsEmpty() && !lotIds.Equals("0"))
            {
                string    filter     = string.Format("FLOTID IN ('{0}')", lotIds);
                OQLFilter of         = OQLFilter.CreateHeadEntityFilter(filter);
                var       lotMasters = BusinessDataServiceHelper.Load(this.Context, "BD_BatchMainFile", null, of);
                foreach (var lot in lotMasters)
                {
                    lot["F_QANo"] = value;
                }
                ISaveService service = Kingdee.BOS.App.ServiceHelper.GetService <ISaveService>();
                service.Save(this.Context, lotMasters);
                updateSqls.Add(string.Format(@"UPDATE  {0}  set F_QANo ='{1}'  WHERE flot  in ('{2}')  ", tableName, value, lotIds));
            }


            if (!ids.IsEmpty())
            {
                updateSqls.Add(string.Format(@"UPDATE  {0}  set F_QANo ='{1}'  WHERE fid  in ('{2}')  ", tableName, value, ids));
            }
            else if (!entryIds.IsEmpty())
            {
                updateSqls.Add(string.Format(@"UPDATE  {0}  set F_QANo ='{1}'  WHERE fentryid  in ('{2}')  ", tableName, value, entryIds));
            }

            DBUtils.ExecuteBatch(this.Context, updateSqls, updateSqls.Count);

            //}
            //返回值到父窗口
            //  this.View.ReturnToParentWindow("true");
            this.View.Close();
        }