private Dictionary <string, UpdateFields> getUpdateFields(string model, ExcuteDataBaseResult dataResult) { Dictionary <string, UpdateFields> updateFieldMap = new Dictionary <string, UpdateFields>(); if (string.Equals(CustomerSQLObject.Customer, model, StringComparison.CurrentCultureIgnoreCase)) { for (int i = 0; i < dataResult.Ds.Tables[0].Rows.Count; i++) { CustomerUpdateFields customerUpdateFields = new CustomerUpdateFields(); customerUpdateFields.FName = dataResult.Ds.Tables[0].Rows[i]["FName"].ToString(); string key = dataResult.Ds.Tables[0].Rows[i]["FNumber"].ToString(); updateFieldMap.Add(key, customerUpdateFields); } } if (string.Equals(SupplierSQLObject.Supplier, model, StringComparison.CurrentCultureIgnoreCase)) { for (int i = 0; i < dataResult.Ds.Tables[0].Rows.Count; i++) { SupplierUpdateFields supplierUpdateFields = new SupplierUpdateFields(); supplierUpdateFields.FName = dataResult.Ds.Tables[0].Rows[i]["FName"].ToString(); supplierUpdateFields.FopenBankName = dataResult.Ds.Tables[0].Rows[i]["FopenBankName"].ToString(); supplierUpdateFields.FbankCode = dataResult.Ds.Tables[0].Rows[i]["FbankCode"].ToString(); string key = dataResult.Ds.Tables[0].Rows[i]["FNumber"].ToString(); updateFieldMap.Add(key, supplierUpdateFields); } } return(updateFieldMap); }
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); }