Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormsGallery.AddExistingRecordPage"/> class.
        /// </summary>
        /// <param name="recordType">The types of record to be listed</param>
        /// <param name="parentRecord">The parent record</param>
        public AddExistingRecordPage(RecordType recordType, AbstractRecord parentRecord)
        {
            this.parentRecord = parentRecord;
            this.recordType   = recordType;

            var tableSection = new TableSection(this.recordType.ToString());               // TODO: Proper title

            // Get records that aren't already linked to the parent record
            var selectableRecords =
                RecordRepository
                .Instance
                .GetRecords(this.recordType)
                .Except(this.parentRecord.LinkedRecords)
                .OrderBy(r => r.ToString());

            foreach (var record in selectableRecords)
            {
                TextCell cell = CreateCellFromRecord(record);
                tableSection.Add(cell);
            }

            var tableView = new TableView
            {
                Intent = TableIntent.Menu,
                Root   = new TableRoot(this.recordType.ToString())
                {
                    tableSection
                }                                                                                   // TODO: Proper title
            };

            this.Content = new StackLayout {
                Children = { tableView }
            };
        }
        public int Add(AbstractRecord record)
        {
            int id = this.records.Select(r => r.RecordId).OrderByDescending(r => r).FirstOrDefault() + 1;

            record.RecordId = id;
            this.records.Add(record);

            return(id);
        }
Ejemplo n.º 3
0
        private void AddListViewItem(AbstractRecord record, string[] subs, WorkPackage workPackage)
        {
            Color foreColor = Color.Black;

            if (record is ActualStateRecord)
            {
                foreColor = Color.FromArgb(0, 122, 122, 122);
            }

            ListViewItem newItem = new ListViewItem(subs)
            {
                Group     = listViewCompliance.Groups[1],
                Tag       = record,
                ForeColor = foreColor
            };

            if (record is AbstractPerformanceRecord)
            {
                AbstractPerformanceRecord apr = (AbstractPerformanceRecord)record;
                if (workPackage != null)
                {
                    //запись о выполнении блокируется найденым пакетом
                    apr.DirectivePackage = workPackage;
                    newItem.BackColor    = Color.FromArgb(Highlight.Grey.Color);
                    newItem.ToolTipText  =
                        "Perform of the task:" + apr.Parent +
                        "\nadded by Work Package:" +
                        "\n" + apr.DirectivePackage.Title +
                        "\nTo remove a performance of task, you need to exclude task from this work package," +
                        "\nor delete the work package ";
                }
                else if (apr is DirectiveRecord)
                {
                    DirectiveRecord dr = apr as DirectiveRecord;
                    if (dr.MaintenanceDirectiveRecordId > 0)
                    {
                        DirectiveRecord mdr = GlobalObjects.CasEnvironment.NewLoader.GetObjectById <DirectiveRecordDTO, DirectiveRecord>(dr.MaintenanceDirectiveRecordId);
                        if (mdr != null && mdr.ParentType == SmartCoreType.MaintenanceDirective)
                        {
                            MaintenanceDirective md = GlobalObjects.MaintenanceCore.GetMaintenanceDirective(mdr.ParentId);
                            if (md != null)
                            {
                                newItem.ToolTipText =
                                    "Perform of the task:" + dr.WorkType +
                                    "\nadded by MPD Item:" +
                                    "\n" + md.TaskNumberCheck;
                            }
                        }
                    }
                }
            }
            //listViewCompliance.Items.Insert(index, newItem);
            listViewCompliance.Items.Add(newItem);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Осуществляет поиск указанного объекта и возвращает отсчитываемый от нуля индекс первого вхождения,
 /// найденного в пределах всего списка.
 /// </summary>
 /// <param name="item">Искомый объект</param>
 /// <returns></returns>
 int IRecordCollection.IndexOf(AbstractRecord item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item", "must be not null");
     }
     if (item is T)
     {
         return(IndexOf(item as T));
     }
     throw new ArgumentException("must be not of type:" + typeof(T), "item");
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Сравнивает детали имебщиеся в коллекции с добавляемой по их ID
 /// если деталь с подобным ID в коллекции не существует,
 /// то она добавляется в коллекцию и возвращается true
 /// ежели деталь с подобным ID в коллекции есть
 /// то она НЕ добавляется в коллекцию и возвращается false
 /// </summary>
 /// <param name="addedObject"></param>
 bool IRecordCollection.CompareAndAdd(AbstractRecord addedObject)
 {
     if (addedObject == null)
     {
         throw new ArgumentNullException("addedObject", "must be not null");
     }
     if (addedObject is T)
     {
         return(CompareAndAdd(addedObject as T));
     }
     throw new ArgumentException("must be not of type:" + typeof(T), "addedObject");
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Удаляет объект из списка
 /// </summary>
 /// <param name="removedObject"></param>
 void IRecordCollection.Remove(AbstractRecord removedObject)
 {
     if (removedObject == null)
     {
         return;
     }
     if (removedObject is T)
     {
         Remove(removedObject as T);
     }
     else
     {
         throw new ArgumentException("must be not of type:" + typeof(T), "removedObject");
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Добавляет объект в коллекцию
 /// </summary>
 /// <param name="addedObject"></param>
 void IRecordCollection.Add(AbstractRecord addedObject)
 {
     if (addedObject == null)
     {
         throw new ArgumentNullException("addedObject", "must be not null");
     }
     if (addedObject is T)
     {
         Add(addedObject as T);
     }
     else
     {
         throw new ArgumentException("must be not of type:" + typeof(T), "addedObject");
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a TextCell from a record and attaches a Command to select the item
        /// </summary>
        private TextCell CreateCellFromRecord(AbstractRecord record)
        {
            Command selectRecordCommand =
                new Command(async() =>
            {
                this.parentRecord.LinkedRecords.Add(record);
                await this.Navigation.PopAsync();
            });

            var cell = new TextCell
            {
                Text    = record.ToString(),
                Command = selectRecordCommand
            };

            return(cell);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Set a record in the cache
 /// </summary>
 /// <param name="key">
 /// A <see cref="System.String"/> case insensitive key.
 /// </param>
 /// <param name="value">
 /// A <see cref="AbstractRecord"/>
 /// </param>
 public bool Set( string key, AbstractRecord value )
 {
     //log.Debug("setting key 1 ", prepareKey(key), value );
     if( value == null || value.OriginalSource == null )
         throw new ArgumentException("Unable to index AbstractRecord: " + value );
     return Set( key, value.OriginalSource.Table );
 }
Ejemplo n.º 10
0
 private void AddChildNode( Widget parent, AbstractRecord r )
 {
     TreeNode n = RootContext.CreateWidget<TreeNode>();
        recordToNode[r] = n;
        n.OnClick += new EventHandler<ClickEventArgs>(nodeSelectManager);
        n.Title = r[TitleKey].ToString();
        n.Record = r;
        parent.Add(n);
        if( r[ChildrenKey] != null )
       	recurseBind(n,r[ChildrenKey] as IRecordList);
 }
Ejemplo n.º 11
0
 public void DeleteRecord(AbstractRecord record)
 {
     records.Remove(record);
 }
Ejemplo n.º 12
0
 public void AddRecord(AbstractRecord record)
 {
     records.Add(record);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormsGallery.NewContactPage"/> class.
        /// </summary>
        /// <param name="parentRecord">Allows a parent record to be set. Use null if there is no parent.</param>
        public NewContactPage(AbstractRecord parentRecord)
        {
            this.parentRecord = parentRecord;
            this.contact      = new Contact {
                Notes = ""
            };

            Command <Type> notesEditorCommand =
                new Command <Type>(async(Type pageType) =>
            {
                NotesEditorPage page = (NotesEditorPage)Activator.CreateInstance(pageType, this.contact);
                await this.Navigation.PushAsync(page);
                this.notesCell.Detail = this.contact.Notes;
            });

            // Contact (General Information)
            Label contactHeader = new Label
            {
                Text = "Contact",
                Font = Font.SystemFontOfSize(30, FontAttributes.Bold),
                HorizontalOptions = LayoutOptions.Center
            };

            this.companyNameCell = new EntryCell    {
                Label = "Company Name"
            };
            this.titleCell = new EntryCell                  {
                Label = "Title"
            };
            this.firstNameCell = new EntryCell              {
                Label = "First Name"
            };
            this.lastNameCell = new EntryCell               {
                Label = "Last Name"
            };
            this.jobTitleRoleCell = new EntryCell   {
                Label = "Job Title / Role"
            };
            this.sourceCell = new EntryCell                 {
                Label = "Source"
            };
            this.companyCell = new SwitchCell               {
                Text = "Company"
            };
            this.notesCell = new TextCell
            {
                Text             = "Notes",
                Detail           = contact.Notes,
                Command          = notesEditorCommand,
                CommandParameter = typeof(NotesEditorPage)
            };

            this.detailsSection = new TableSection("Contact");
            this.detailsView    = new TableView
            {
                Intent = TableIntent.Form,
                Root   = new TableRoot("Details")
                {
                    detailsSection
                }
            };

            companyCell.OnChanged += (object sender, ToggledEventArgs e) => { ChangeCompanyMode(this.companyCell.On); };

            // Linked Records
            Command addNewRecordCommand =
                new Command(async() =>
            {
                string action = await DisplayActionSheet(null, "Cancel", null, "Contact", "Shoot", "Quote", "Sale");
                if (action == "Contact")
                {
                    var page = new NewContactPage(this.contact);
                    await this.Navigation.PushAsync(page);
                }
            });
            Command addExistingRecordCommand =
                new Command(async() =>
            {
                string action = await DisplayActionSheet(null, "Cancel", null, "Contact", "Shoot", "Quote", "Sale");
                if (action == "Contact")
                {
                    var page = new AddExistingRecordPage(RecordType.Contact, this.contact);
                    await this.Navigation.PushAsync(page);
                }
            });

            this.linkedRecordsSection = new TableSection("Linked Records");
            this.addNewLinkCell       = new TextCell {
                Text = "Add New", Command = addNewRecordCommand
            };
            this.addExistingLinkCell = new TextCell {
                Text = "Add Existing", Command = addExistingRecordCommand
            };

            PopulateLinkedRecordsSection();
            this.detailsView.Root.Add(this.linkedRecordsSection);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = { contactHeader, detailsView }
            };

            ChangeCompanyMode(this.companyCell.On);
        }