Beispiel #1
0
        void ContactDetails_ChangeContainerSet()
        {
            Contact model = null;
            if (_contactId < 0) {
                model = new Contact();
                model.ContactID = _contactId;
                RegisterUniquePendingChange(new InsertContactCommand(model));
            } else {
                var service = new LoanService(User);
                model = service.GetContact(_contactId);
            }

            _viewModel = new ContactViewModel(model);

            if (model != null && !string.IsNullOrEmpty(model.StreetAddress)) {
                if (model.StreetAddress.Equals(model.PostalAddress, StringComparison.CurrentCultureIgnoreCase)) {
                    _viewModel.PostalSameAsStreet = true;
                }
            }

            tabContact.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Contact, _viewModel));
            tabContact.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Contact, _viewModel));

            txtInstituion.BindUser(User, "tblContact", "vchrInstitution");

            _viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged);

            this.DataContext = _viewModel;
            this.WindowTitle = string.Format("Contact detail: {0} [{1}]", _viewModel.FullName, _viewModel.ContactID);
        }
        public override FileInfo GenerateLoanForm(Multimedia template, Loan loan, List<LoanMaterial> material, List<Trait> traits, Contact originator, Contact requestor, Contact receiver)
        {
            var tempFile = TempFileManager.NewTempFilename(".docx");
            var bytes = SupportService.GetMultimediaBytes(template.MultimediaID);

            Func<String, String> fieldDataFunc = (String fieldName) => {
                return base.SubstitutePlaceHolder(NormaliseFieldName(fieldName), loan, material, traits, originator, requestor, receiver);
            };

            Merge(fieldDataFunc, bytes, tempFile);
            return new FileInfo(tempFile);
        }
Beispiel #3
0
        protected string SubstitutePlaceHolder(string key, Loan loan, IEnumerable<LoanMaterial> material, IEnumerable<Trait> traits, Contact originator, Contact requestor, Contact receiver)
        {
            var sb = new StringBuilder();

            // Special placeholders

            switch (key.ToLower()) {
                case "totalspecimencount":
                    return CountTotalSpecimens(material) + "";
            }

            if (key.Contains('(')) {
                // group...
                var collectionName = key.Substring(0, key.IndexOf('('));
                var fieldstr = key.Substring(key.IndexOf('(') + 1);
                var fields = fieldstr.Substring(0, fieldstr.Length - 1).Split(',');

                List<object> collection = null;
                if (collectionName.Equals("material", StringComparison.CurrentCultureIgnoreCase)) {
                    collection = new List<object>(material);
                } else if (collectionName.Equals("trait", StringComparison.CurrentCultureIgnoreCase)) {
                    collection = new List<object>(traits);
                }

                if (collection != null) {
                    foreach (Object obj in collection) {
                        int i = 0;
                        foreach (string field in fields) {
                            var value = GetPropertyValue(obj, field);
                            if (!string.IsNullOrEmpty(value)) {
                                sb.Append(RTFUtils.EscapeUnicode(value));
                            }
                            sb.Append(++i < fields.Length ? ", " : String.Format(". {0}", NewLineSequence));
                        }
                    }
                }
            } else if (key.Contains(".")) {
                // is a property of a linked object (currently just the three different contacts attached to the loan)
                // e.g. receiver.EMail
                var bits = key.Split('.');

                if (bits.Length > 0) {
                    Object srcObject = null;
                    switch (bits[0].ToLower()) {
                        case "receiver":
                            srcObject = receiver;
                            break;
                        case "requestor":
                            srcObject = requestor;
                            break;
                        case "originator":
                            srcObject = originator;
                            break;
                    }

                    if (srcObject != null) {
                        var value = GetPropertyValue(srcObject, bits[1]);
                        if (!string.IsNullOrEmpty(value)) {
                            sb.Append(RTFUtils.EscapeUnicode(value));
                        }
                    }
                }

            } else {
                // single value from the Loan model...
                var value = GetPropertyValue(loan, key);
                if (!string.IsNullOrEmpty(value)) {
                    sb.Append(RTFUtils.EscapeUnicode(value));
                }
            }
            return sb.ToString();
        }
Beispiel #4
0
 public abstract FileInfo GenerateLoanForm(Multimedia template, Loan loan, List<LoanMaterial> material, List<Trait> traits, Contact originator, Contact requestor, Contact receiver);
Beispiel #5
0
 public static String FormatName(Contact contact)
 {
     return FormatName(contact.Title, contact.GivenName, contact.Name);
 }
Beispiel #6
0
 public void UpdateContact(Contact contact)
 {
     StoredProcUpdate("spContactUpdate",
         _P("intContactID", contact.ContactID),
         _P("vchrName", contact.Name),
         _P("vchrTitle", contact.Title),
         _P("vchrGivenName", contact.GivenName),
         _P("vchrPostalAddress", contact.StreetAddress),
         _P("vchrStreetAddress", contact.StreetAddress),
         _P("vchrInstitution", contact.Institution),
         _P("vchrJobTitle", contact.JobTitle),
         _P("vchrWorkPh", contact.WorkPh),
         _P("vchrWorkFax", contact.WorkFax),
         _P("vchrHomePh", contact.HomePh),
         _P("vchrEMail", contact.EMail));
 }
Beispiel #7
0
        public int InsertContact(Contact contact)
        {
            var retval = ReturnParam("NewContactID");
            StoredProcUpdate("spContactInsert",
                _P("vchrName", contact.Name),
                _P("vchrTitle", contact.Title),
                _P("vchrGivenName", contact.GivenName),
                _P("vchrPostalAddress", contact.StreetAddress),
                _P("vchrStreetAddress", contact.StreetAddress),
                _P("vchrInstitution", contact.Institution),
                _P("vchrJobTitle", contact.JobTitle),
                _P("vchrWorkPh", contact.WorkPh),
                _P("vchrWorkFax", contact.WorkFax),
                _P("vchrHomePh", contact.HomePh),
                _P("vchrEMail", contact.EMail),
                retval
                );

            int newContactID = (int)retval.Value;
            return newContactID;
        }