private static void SetSapParameter(SapParameter mSapParameters, Hashtable parametersHash) { foreach (DictionaryEntry entry in parametersHash) { foreach (PropertyInfo prop in mSapParameters.GetType().GetProperties()) { if (entry.Key.AsString() == prop.Name) { switch (prop.PropertyType.ToString()) { case "System.Decimal": prop.SetValue(mSapParameters, decimal.Parse(entry.Value.AsString()), null); break; default: prop.SetValue(mSapParameters, entry.Value.AsString(), null); break; } break; } } } }
private List<SapParameter> InitializeSapParameter(DataTable originalDetailsDT, DataTable expenseTypeDT, Hashtable parametersHash) { List<SapParameter> mSapParametersTR = new List<SapParameter>(); SapParameter mSapParameters = new SapParameter() { BusAct = "RFBU", CompCode = "CA10", DocType = "KR", BusArea = "0001", Currency = "RMB", //EmployeeID = "6000000150", // // EmployeeName = "TEST", // ExchRate = 1, //Header = "Travel Expense Claim", //RefDocNo = "CA" + DateTime.Now.ToString("yyyyMMddHHmmss"),// UserName = "******" }; foreach (DictionaryEntry entry in parametersHash) { foreach (PropertyInfo prop in mSapParameters.GetType().GetProperties()) { if (entry.Key.AsString() == prop.Name) { switch (prop.PropertyType.ToString()) { case "System.Decimal": prop.SetValue(mSapParameters, decimal.Parse(entry.Value.AsString()), null); break; default: prop.SetValue(mSapParameters, entry.Value.AsString(), null); break; } break; } } } mSapParameters.GroupExpenceDetails = GetSapParametersList(expenseTypeDT); mSapParameters.ExpenceDetails = GetSapParametersList(originalDetailsDT); mSapParametersTR.Add(mSapParameters); return mSapParametersTR; }