/// <summary> /// Populate OH Reason with core attributes (ID, Code, & Description) /// Called by all Find overloads and from LoadJobFromWorkOrder in WIS /// </summary> /// <param name="dtResults"></param> /// <returns></returns> public static OnHoldReasonCollection Populate(DataTable dtResults, DataTable materialsRequested) { OnHoldReasonCollection colMembers = null; OnHoldReason onHoldReason = null; string filterExpression = string.Empty; if (dtResults != null && dtResults.Rows.Count > 0) { colMembers = new OnHoldReasonCollection(); foreach (DataRow drMember in dtResults.Rows) { onHoldReason = new OnHoldReason(); onHoldReason.ID = (int)drMember["OnHoldReasonID"]; onHoldReason.Code = drMember["OnHoldReasonCode"].ToString(); onHoldReason.Description = drMember["OnHoldReasonDesc"].ToString(); if (dtResults.Columns.Contains("WMSourceSystem") && !drMember["WMSourceSystem"].Equals(DBNull.Value)) { onHoldReason.SourceSystem = (eWMSourceSystem)Enum.Parse(typeof(eWMSourceSystem), drMember["WMSourceSystem"].ToString()); } if (dtResults.Columns.Contains("Comments") && !drMember["Comments"].Equals(DBNull.Value)) { System.Xml.XmlDocument objDOM = new System.Xml.XmlDocument(); objDOM.LoadXml(drMember["Comments"].ToString()); onHoldReason.Comments = (CommentAuditRecordCollection)BusinessObjects.Base.Deserialize(typeof(CommentAuditRecordCollection), objDOM); } if (materialsRequested != null && onHoldReason.Code.ToUpper() == "MAT") { onHoldReason.MaterialsRequired = MaterialCollection.Populate(materialsRequested); } if (!drMember["DateResolved"].Equals(DBNull.Value)) { DateTime dateResolved = (DateTime)drMember["DateResolved"]; if (dateResolved != DateTime.MinValue) { onHoldReason.DateResolved = dateResolved; } } colMembers.Add(onHoldReason); } } return colMembers; }
public static OnHoldReasonCollection FindByJob(int jobID) { OnHoldReasonCollection colMembers = new OnHoldReasonCollection(); OnHoldReason onHoldReason = null; DataAccess objADO = new DataAccess(); // TaskStore database DataTable dtResults = null; ArrayList colParameters = new ArrayList(); string strStoredProcedure = "selJobOnHoldDetails"; colParameters.Add(new SqlParameter("@WMSourceID", jobID)); dtResults = objADO.GetDataTable(strStoredProcedure, "OnHoldReasons", (SqlParameter[])colParameters.ToArray(typeof(SqlParameter))); objADO = null; if (dtResults != null && dtResults.Rows.Count > 0) { foreach (DataRow drMember in dtResults.Rows) { onHoldReason = new OnHoldReason(); onHoldReason.ID = (int)drMember["OnHoldReasonID"]; onHoldReason.Code = drMember["OnHoldReasonCode"].ToString(); onHoldReason.Description = drMember["OnHoldReasonDesc"].ToString(); // Note. Additional columns expected in this method to other Find methods if (!drMember["DateResolved"].Equals(DBNull.Value)) { onHoldReason.DateResolved = (DateTime)drMember["DateResolved"]; } if (!drMember["ResolvingUser"].Equals(DBNull.Value)) { onHoldReason.ResolvingUser = drMember["ResolvingUser"].ToString(); } if (!drMember["Comments"].Equals(DBNull.Value)) { System.Xml.XmlDocument objDOM = new System.Xml.XmlDocument(); objDOM.LoadXml(drMember["Comments"].ToString()); onHoldReason.Comments = (CommentAuditRecordCollection)BusinessObjects.Base.Deserialize(typeof(CommentAuditRecordCollection), objDOM); } colMembers.Add(onHoldReason); } } return colMembers; }