public bool updateKingDeeDataBase(string model, List <string> SQLStatement, Dictionary <string, UpdateFields> updateMap, Context ctx) { List <string> statementList = new List <string>(); foreach (KeyValuePair <string, UpdateFields> kvp in updateMap) { if (string.Equals(CustomerSQLObject.Customer, model, StringComparison.CurrentCultureIgnoreCase)) { CustomerUpdateFields customerUpdateFields = (CustomerUpdateFields)kvp.Value; string statement = string.Format(SQLStatement[0], customerUpdateFields.FName, kvp.Key); statementList.Add(statement); CustomerFnunbers.Add(kvp.Key); } if (string.Equals(SupplierSQLObject.Supplier, model, StringComparison.CurrentCultureIgnoreCase)) { SupplierUpdateFields supplierUpdateFields = (SupplierUpdateFields)kvp.Value; string statement1 = string.Format(SQLStatement[0], supplierUpdateFields.FName, kvp.Key); string statement2 = string.Format(SQLStatement[1], supplierUpdateFields.FbankCode, kvp.Key); string statement3 = string.Format(SQLStatement[2], supplierUpdateFields.FopenBankName, kvp.Key); SupplierFnumbers.Add(kvp.Key); using (KDTransactionScope trans = new KDTransactionScope(System.Transactions.TransactionScopeOption.Required)) { if (DBServiceHelper.Execute(ctx, statement1) > 0) { if (DBServiceHelper.Execute(ctx, statement2) > 0) { if (DBServiceHelper.Execute(ctx, statement3) > 0) { BussnessLog.WriteBussnessLog("", model + "更新", "更新金蝶数据库成功! fnumber=" + kvp.Key); } else { BussnessLog.WriteBussnessLog("", model + "更新", "更新金蝶数据库失败! fnumber=" + kvp.Key); } } } trans.Complete(); } } } if (DBServiceHelper.ExecuteBatch(ctx, statementList) > 0) { foreach (string s in statementList) { BussnessLog.WriteBussnessLog("", model + "更新", "更新金蝶数据库成功! 更新语句=" + s); } } else { foreach (string s in statementList) { BussnessLog.WriteBussnessLog("", model + "更新", "更新金蝶数据库失败! 更新语句=" + s); } } return(true); }
/// <summary> ///累加日计划面积 /// </summary> /// <param name="e"></param> public override void EndOperationTransaction(EndOperationTransactionArgs e) { base.EndOperationTransaction(e); IViewService Services = ServiceHelper.GetService <IViewService>(); if (selectedRows != null && selectedRows.Count() != 0) { IMetaDataService metadataService = Kingdee.BOS.App.ServiceHelper.GetService <IMetaDataService>(); //string SoureFormId = "SZXY_FHJTRSCJH"; //获取单据元数据 //FormMetadata BilMetada = metadataService.Load(Context, SoureFormId) as FormMetadata; foreach (DynamicObject dy in selectedRows) { string Id = Convert.ToString(dy["Id"]); decimal Area = 0; string RJHFid = string.Empty; string RJHRowId = string.Empty; //RJHFid = Convert.ToString(dy["F_SZXY_FIDH"]); SZXY_XYFQEntry //Area = Convert.ToDecimal(dy["F_SZXY_AreaH"]); //RJHRowId = Convert.ToString(dy["F_SZXY_RJHEntryID"]); string F_SZXY_discardR = ""; //报废原因 decimal F_SZXY_discardA = 0; //报废面积 string FentryID = ""; List <string> InsSqlList = new List <string>(); InsSqlList.Clear(); if (dy["SZXY_XYFQEntry"] is DynamicObjectCollection Entry) { foreach (DynamicObject item in Entry) { FentryID = item["Id"].ToString(); Area = Convert.ToDecimal(item["F_SZXY_AREA"]); //反写日计划实际完成面积 RJHRowId = Convert.ToString(item["F_SZXY_RJHEntryID"]); if (!RJHRowId.IsNullOrEmptyOrWhiteSpace() && Convert.ToInt32(RJHRowId) > 0) { string sql1 = $"/*dialect*/update SZXY_t_FQJTRSCJHEntry set F_SZXY_ProductionArea=F_SZXY_ProductionArea+{Area}," + $" where FEntryID={RJHRowId}"; DBServiceHelper.Execute(Context, sql1); } F_SZXY_discardR = Convert.ToString(item["F_SZXY_discardR"]); F_SZXY_discardA = Convert.ToDecimal(item["F_SZXY_discardA"]); string F_SZXY_Blevel = ""; if (item["F_SZXY_Blevel"] is DynamicObject LevDo) { F_SZXY_Blevel = LevDo["Id"].ToString(); } if (F_SZXY_discardR.IsNullOrEmptyOrWhiteSpace() && F_SZXY_discardA == 0 && F_SZXY_Blevel.IsNullOrEmptyOrWhiteSpace()) { string DelSql = $"/*dialect*/insert into SZXY_t_XYFQEntrycopy select * from SZXY_t_XYFQEntry where SZXY_t_XYFQEntry.Fid={Id} and SZXY_t_XYFQEntry.FEntryID={FentryID} "; InsSqlList.Add(DelSql); string DelSql1 = $"/*dialect*/delete from SZXY_t_XYFQEntry where SZXY_t_XYFQEntry.Fid={Id} and SZXY_t_XYFQEntry.FEntryID={FentryID} "; InsSqlList.Add(DelSql1); } } if (InsSqlList.Count > 0) { DBServiceHelper.ExecuteBatch(Context, InsSqlList); } } } } }