/// <summary> /// "Type" the contents of this record into a NovaCode Cell. /// </summary> /// <param name="c"></param> /// <param name="rec"></param> protected override void TypeOneRecord(Cell c, object rec) { string request_type_code = this.RequestType.Substring(0, 1).ToUpper(); System.Drawing.Color request_type_color; System.Drawing.Color default_color = System.Drawing.Color.Black; switch (request_type_code) { case "C": request_type_color = System.Drawing.Color.Green; break; case "T": request_type_color = System.Drawing.Color.Red; break; default: request_type_color = default_color; break; } c.MarginTop = 0; BagLabelInfo bli = (BagLabelInfo)rec; Paragraph p = c.Paragraphs.First(); // Xceed.Words.NET should initialize Cells with one // paragraph. But, in the unlikeley case // that that paragraph isn't there, add one. if (p == null) { p = c.InsertParagraph(); } p.SpacingBefore(0); p.SpacingAfter(0); p.Append(request_type_code).Color(request_type_color).FontSize(36).Bold() .Append(" " + this.Dnr.code + " " + bli.family_id).Color(default_color).FontSize(36) .AppendLine(bli.family_name).Color(default_color).FontSize(36).Bold() .AppendLine(bli.family_members).Color(default_color).FontSize(28); }
// BagLabelInfo methods: ///////////////////////////// /// <summary> /// Is there already an object in the list that matches the /// passed-in one? /// /// Two BagLabelInfo objects match if they have the same year, request type, /// and family id. /// </summary> public BagLabelInfo MatchingBagLabelInfo(BagLabelInfo other) { return this._blicoll.Find(b => b.year == other.year && b.request_type == other.request_type && b.family_id == other.family_id ).FirstOrDefault(); }
/// <summary> /// Add passed-in object to database collection, if /// it's not already present. If it is already there, /// update the database element with the properties /// of the passed-inobject. /// </summary> /// <param name="bli"></param> /// <returns></returns> public BagLabelInfo AddOrUpdateBLI(BagLabelInfo bli) { BagLabelInfo dbo = this.MatchingBagLabelInfo(bli); if (dbo == null) { // not found -- insert the one passed // to us. As a side effect, the Insert() // method updates the Id property of the // inserted object. this._blicoll.Insert(bli); } else { // found -- set the id of the passed-in object to // that of the found object. bli.Id = dbo.Id; // Now replace the object in the database with // the one passed in. this._blicoll.Update(bli); } return bli; }