public AMSRequestActivityDetail[] FormatActivity(DataTable dt) { AMSRequestActivityDetail[] _list = new AMSRequestActivityDetail[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { _list[i] = FormatActivity(dt.Rows[i]); } return(_list); }
AMSRequestActivityDetail FormatActivity(DataRow row) { AMSRequestActivityDetail entry = new AMSRequestActivityDetail(); entry.ID = row["ID"].ToString(); entry.RequestID = row["RequestID"].ToString(); if (!string.IsNullOrEmpty(row["HasServiceProvider"].ToString())) { entry.HasServiceProvider = bool.Parse(row["HasServiceProvider"].ToString()); } if (!string.IsNullOrEmpty(row["ProductRelated"].ToString())) { entry.ProductRelated = bool.Parse(row["ProductRelated"].ToString()); } entry.DepartmentAndProduct = row["DepartmentAndProduct"].ToString(); entry.Category = row["Category"].ToString(); entry.CostCenter = row["CostCenter"].ToString(); entry.GLAccount = row["GLAccount"].ToString(); entry.Sub_AMSNumber = row["Sub_AMSNumber"].ToString(); entry.BeginDate = string.IsNullOrEmpty(row["BeginDate"].ToString()) ? DateTime.MinValue : DateTime.Parse(row["BeginDate"].ToString()); entry.EndDate = string.IsNullOrEmpty(row["EndDate"].ToString()) ? DateTime.MinValue : DateTime.Parse(row["EndDate"].ToString()); entry.Planning_Participant_InternalQuantity = string.IsNullOrEmpty(row["Planning_Participant_InternalQuantity"].ToString()) ? 0 : int.Parse(row["Planning_Participant_InternalQuantity"].ToString()); entry.Planning_Participant_ExternalQuantity = string.IsNullOrEmpty(row["Planning_Participant_ExternalQuantity"].ToString()) ? 0 : int.Parse(row["Planning_Participant_ExternalQuantity"].ToString()); entry.Planning_Country = row["Planning_Country"].ToString(); entry.Planning_City = row["Planning_City"].ToString(); entry.Planning_Location = row["Planning_Location"].ToString(); entry.Planning_Description = row["Planning_Description"].ToString(); entry.Actual_BeginDate = string.IsNullOrEmpty(row["Actual_BeginDate"].ToString()) ? DateTime.MinValue : DateTime.Parse(row["Actual_BeginDate"].ToString()); entry.Actual_EndDate = string.IsNullOrEmpty(row["Actual_EndDate"].ToString()) ? DateTime.MinValue : DateTime.Parse(row["Actual_EndDate"].ToString()); entry.Actual_Participant_InternalQuantity = string.IsNullOrEmpty(row["Actual_Participant_InternalQuantity"].ToString()) ? 0 : int.Parse(row["Actual_Participant_InternalQuantity"].ToString()); entry.Actual_Participant_ExternalQuantity = string.IsNullOrEmpty(row["Actual_Participant_ExternalQuantity"].ToString()) ? 0 : int.Parse(row["Actual_Participant_ExternalQuantity"].ToString()); entry.Actual_City = row["Actual_City"].ToString(); entry.Actual_Location = row["Actual_Location"].ToString(); entry.Category = row["Category"].ToString(); entry.ExpenseSubTotal = string.IsNullOrEmpty(row["ExpenseSubTotal"].ToString()) ? 0 : float.Parse(row["ExpenseSubTotal"].ToString()); entry.FFSSubTotal = string.IsNullOrEmpty(row["FFSSubTotal"].ToString()) ? 0 : float.Parse(row["FFSSubTotal"].ToString()); entry.Total = string.IsNullOrEmpty(row["Total"].ToString()) ? 0 : float.Parse(row["Total"].ToString()); if (!string.IsNullOrEmpty(row["Default"].ToString())) { entry.Default = bool.Parse(row["Default"].ToString()); } entry.Status = row["Status"].ToString(); entry.CreateTime = string.IsNullOrEmpty(row["CreateTime"].ToString()) ? DateTime.MinValue : DateTime.Parse(row["CreateTime"].ToString()); entry.CreatedBy = row["CreatedBy"].ToString(); entry.UpdateTime = string.IsNullOrEmpty(row["UpdateTime"].ToString()) ? DateTime.MinValue : DateTime.Parse(row["UpdateTime"].ToString()); entry.UpdatedBy = row["UpdatedBy"].ToString(); entry.CostCenter = row["CostCenter"].ToString(); entry.GLAccount = row["GLAccount"].ToString(); entry.FreezeStatus = row["FreezeStatus"].ToString(); entry.MonitorStatus = row["MonitorStatus"].ToString(); //entry.CRCNO = row["CRCNO"].ToString();//add by hdwang 20140416 return(entry); }