Exemple #1
0
        private void xamDataGrid_EditModeEnded(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndedEventArgs e)
        {
            // use this method to update a record after one of the cells of the record has been edited

            if (((string)e.Cell.Record.Tag) == "AddRecord")
            {
                return;                                              // not updating the AddRecord here
            }
            if (e.Cell.Record.DataItem.GetType() == typeof(MethodItem))
            {
                MethodItem mi = (MethodItem)e.Cell.Record.DataItem;

                if (mi.MethodID != 0)
                {
                    MethodContainer mc = new MethodContainer();

                    mc.MethodID        = mi.MethodID;
                    mc.Description     = mi.Description;
                    mc.BravoMethodFile = mi.BravoMethodFile;
                    mc.OwnerID         = mi.OwnerID;
                    mc.IsPublic        = mi.IsPublic;

                    bool success = wgDB.UpdateMethod(mc);
                }
            }
            else if (e.Cell.Record.DataItem.GetType() == typeof(IndicatorItem))
            {
                IndicatorItem ii = (IndicatorItem)e.Cell.Record.DataItem;

                if (ii.IndicatorID != 0)
                {
                    IndicatorContainer ic = new IndicatorContainer();
                    ic.Description = ii.Description;
                    ic.MethodID    = ii.MethodID;
                    ic.IndicatorID = ii.IndicatorID;
                    ic.ExcitationFilterPosition = ii.ExcitationFilterPosition;
                    ic.EmissionsFilterPosition  = ii.EmissionsFilterPosition;
                    ic.SignalType = ii.SignalType;

                    bool succcess = wgDB.UpdateIndicator(ic);
                }
            }
            else if (e.Cell.Record.DataItem.GetType() == typeof(CompoundPlateItem))
            {
                CompoundPlateItem cpi = (CompoundPlateItem)e.Cell.Record.DataItem;

                if (cpi.CompoundPlateID != 0)
                {
                    CompoundPlateContainer cpc = new CompoundPlateContainer();
                    cpc.CompoundPlateID = cpi.CompoundPlateID;
                    cpc.MethodID        = cpi.MethodID;
                    cpc.Description     = cpi.Description;

                    bool success = wgDB.UpdateCompoundPlate(cpc);
                }
            }
        }
Exemple #2
0
        private void xamDataGrid_RecordUpdated(object sender, Infragistics.Windows.DataPresenter.Events.RecordUpdatedEventArgs e)
        {
            if (e.Record.Tag == null)
            {
                return;
            }

            if (((string)e.Record.Tag).Equals("AddRecord"))  // is this the "AddRecord"?
            {
                if (e.Record.DataItem.GetType() == typeof(MethodItem))
                {
                    DataRecord methodRecord = (DataRecord)e.Record;

                    MethodItem mi = ((MethodItem)(methodRecord.DataItem));

                    MethodContainer newMethod = new MethodContainer();
                    newMethod.Description     = mi.Description;
                    newMethod.OwnerID         = mi.OwnerID;
                    newMethod.BravoMethodFile = mi.BravoMethodFile;
                    newMethod.IsPublic        = mi.IsPublic;

                    bool success = wgDB.InsertMethod(ref newMethod);
                    if (success)
                    {
                        mi.MethodID = newMethod.MethodID;

                        UnMarkAddNewRecord(methodRecord);

                        MethodItem miNew = new MethodItem();
                        miNew.Description     = "";
                        miNew.MethodID        = mi.MethodID;
                        miNew.OwnerID         = mi.OwnerID;
                        miNew.IsPublic        = false;
                        miNew.BravoMethodFile = "";

                        VM.Methods.Insert(0, miNew);

                        // mark the new Method as the AddRecord
                        RecordCollectionBase coll            = e.Record.ParentCollection;
                        DataRecord           newMethodRecord = (DataRecord)coll.ElementAt(0);
                        MarkAddNewRecord(newMethodRecord);

                        // add the AddRecord Indicator for this new method
                        ObservableCollection <FilterContainer>     exFilts = VM.ExcitationFilters;
                        ObservableCollection <FilterContainer>     emFilts = VM.EmissionsFilters;
                        ObservableCollection <SignalTypeContainer> stList  = VM.SignalTypeList;
                        IndicatorItem ii = new IndicatorItem(0, mi.MethodID, "", ref stList, ref exFilts, ref emFilts);


                        mi.Indicators.Add(ii);

                        // mark the new Indicator as the AddRecord
                        ExpandableFieldRecord expRecord       = (ExpandableFieldRecord)methodRecord.ChildRecords[0];
                        DataRecord            indicatorRecord = (DataRecord)expRecord.ChildRecords[0];

                        if (indicatorRecord.DataItem.GetType() == typeof(IndicatorItem))
                        {
                            MarkAddNewRecord(indicatorRecord);
                        }


                        // add the AddRecord CompoundPlate for this new method
                        CompoundPlateItem cpi = new CompoundPlateItem();
                        cpi.CompoundPlateID = 0;
                        cpi.MethodID        = mi.MethodID;
                        cpi.Description     = "";

                        mi.CompoundPlates.Add(cpi);

                        // mark the new CompoundPlate as the AddRecord
                        ExpandableFieldRecord expRecord1          = (ExpandableFieldRecord)methodRecord.ChildRecords[1];
                        DataRecord            compoundPlateRecord = (DataRecord)expRecord1.ChildRecords[0];

                        if (compoundPlateRecord.DataItem.GetType() == typeof(CompoundPlateItem))
                        {
                            MarkAddNewRecord(compoundPlateRecord);
                        }
                    }
                }
                else if (e.Record.DataItem.GetType() == typeof(IndicatorItem))
                {
                    IndicatorItem ii = (IndicatorItem)(e.Record.DataItem);

                    IndicatorContainer ic = new IndicatorContainer();
                    ic.Description = ii.Description;
                    ic.MethodID    = ii.MethodID;
                    ic.IndicatorID = ii.IndicatorID;
                    ic.ExcitationFilterPosition = ii.ExcitationFilterPosition;
                    ic.EmissionsFilterPosition  = ii.EmissionsFilterPosition;
                    ic.SignalType = ii.SignalType;

                    bool success = wgDB.InsertIndicator(ref ic);

                    if (success)
                    {
                        ii.IndicatorID = ic.IndicatorID;

                        UnMarkAddNewRecord(e.Record);

                        ObservableCollection <FilterContainer>     exFilts = VM.ExcitationFilters;
                        ObservableCollection <FilterContainer>     emFilts = VM.EmissionsFilters;
                        ObservableCollection <SignalTypeContainer> stList  = VM.SignalTypeList;
                        IndicatorItem iiNew = new IndicatorItem(0, ic.MethodID, "", ref stList, ref exFilts, ref emFilts);


                        MethodItem mi = (MethodItem)(((DataRecord)e.Record.ParentRecord.ParentRecord).DataItem);

                        mi.Indicators.Insert(0, iiNew);

                        DataRecord newIndicatorRecord = (DataRecord)e.Record.ParentCollection[0];
                        MarkAddNewRecord(newIndicatorRecord);
                    }
                }
                else if (e.Record.DataItem.GetType() == typeof(CompoundPlateItem))
                {
                    CompoundPlateItem cpi = (CompoundPlateItem)(e.Record.DataItem);

                    CompoundPlateContainer cpc = new CompoundPlateContainer();
                    cpc.CompoundPlateID = cpi.CompoundPlateID;
                    cpc.Description     = cpi.Description;
                    cpc.MethodID        = cpi.MethodID;

                    bool success = wgDB.InsertCompoundPlate(ref cpc);

                    if (success)
                    {
                        cpi.CompoundPlateID = cpc.CompoundPlateID;

                        UnMarkAddNewRecord(e.Record);

                        CompoundPlateItem cpiNew = new CompoundPlateItem();
                        cpiNew.Description     = "";
                        cpiNew.CompoundPlateID = 0;
                        cpiNew.MethodID        = cpc.MethodID;

                        MethodItem mi = (MethodItem)(((DataRecord)e.Record.ParentRecord.ParentRecord).DataItem);

                        mi.CompoundPlates.Insert(0, cpiNew);

                        DataRecord newCompoundPlateRecord = (DataRecord)e.Record.ParentCollection[0];
                        MarkAddNewRecord(newCompoundPlateRecord);
                    }
                }
            }
        }