Ejemplo n.º 1
0
        public ActionResult UserAction(List <IndicatorItem> IItems, string actioncase)
        {
            switch (actioncase.ToLower())
            {
            case "update":
                if (IItems != null)
                {
                    List <IndicatorItem> newitems = new List <IndicatorItem>();
                    for (int i = 0; i < IItems.Count; i++)
                    {
                        IndicatorItem newitem = new IndicatorItem();
                        newitem.IndicatorID              = IItems[i].IndicatorID;
                        newitem.IndicatorItemID          = IItems[i].IndicatorItemID;
                        newitem.IndicatorLabelID         = IItems[i].IndicatorLabelID;
                        newitem.IndicatorCategoryLabelID = IItems[i].IndicatorCategoryLabelID;
                        newitem.Baseline  = IItems[i].Baseline;
                        newitem.Benchmark = IItems[i].Benchmark;
                        newitem.Final     = IItems[i].Final;

                        newitems.Add(newitem);
                    }
                    IService.UpdateIndicatorItems(newitems);
                }
                break;

            default: break;
            }

            return(RedirectToAction("Index"));
        }
 private static void AddOutcomeHeader(DataTable dataTable, IndicatorItem indicatorItem)
 {
     dataTable.Columns.Add(indicatorItem.Name + " - Klar");
     dataTable.Columns.Add(indicatorItem.Name + " - Result");
     dataTable.Columns.Add(indicatorItem.Name + " - Result text");
     dataTable.Columns.Add(indicatorItem.Name + " - Krav");
     dataTable.Columns.Add(indicatorItem.Name + " - Formulering på utfall");
 }
Ejemplo n.º 3
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);
                }
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(IndicatorItem item)
        {
            if (Session["ProposalID"] == null)
            {
                return(RedirectToAction("Search", "ProposalInfo"));
            }

            IService.UpdateIndicatorItem(item);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult Edit(int id)
        {
            if (Session["ProposalID"] == null)
            {
                return(RedirectToAction("Search", "ProposalInfo"));
            }

            IndicatorItem item = IService.GetIndicatorItem(id);

            return(View(item));
        }
Ejemplo n.º 6
0
        private void xamDataGrid_RecordsDeleting(object sender, Infragistics.Windows.DataPresenter.Events.RecordsDeletingEventArgs e)
        {
            bool success;

            foreach (DataRecord record in e.Records)
            {
                if (record.DataItem.GetType() == typeof(MethodItem))
                {
                    MethodItem mi = (MethodItem)record.DataItem;
                    foreach (IndicatorItem ii in mi.Indicators)
                    {
                        success = wgDB.DeleteIndicator(ii.IndicatorID);
                        if (!success)
                        {
                            break;
                        }
                    }

                    foreach (CompoundPlateItem cpi in mi.CompoundPlates)
                    {
                        success = wgDB.DeleteCompoundPlate(cpi.CompoundPlateID);
                        if (!success)
                        {
                            break;
                        }
                    }

                    success = wgDB.DeleteMethod(mi.MethodID);
                    if (!success)
                    {
                        break;
                    }
                }
                else if (record.DataItem.GetType() == typeof(IndicatorItem))
                {
                    IndicatorItem ii = (IndicatorItem)record.DataItem;
                    success = wgDB.DeleteIndicator(ii.IndicatorID);
                    if (!success)
                    {
                        break;
                    }
                }
                else if (record.DataItem.GetType() == typeof(CompoundPlateItem))
                {
                    CompoundPlateItem cpi = (CompoundPlateItem)record.DataItem;
                    success = wgDB.DeleteCompoundPlate(cpi.CompoundPlateID);
                    if (!success)
                    {
                        break;
                    }
                }
            }
        }
        public bool InsertFromTemplate(int ProjectID)
        {
            bool result = true;
            var  query  = (from t in db.IndicatorTemplateItems
                           join ic in db.IndicatorCategoryLabels
                           on t.IndicatorCategoryLabelID equals ic.IndicatorCategoryLabelID
                           join gt in db.GrantTypes
                           on ic.GrantTypeCodeID equals gt.GrantTypeCodeID
                           where gt.ProjectID == ProjectID
                           select t);

            IfIndicatorCreate(ProjectID);
            List <IndicatorItem> tosubmit = new List <IndicatorItem>();

            if (query != null)
            {
                if (query.Count() != 0)
                {
                    foreach (var item in query)
                    {
                        if (item != null)
                        {
                            IndicatorItem newitem = new IndicatorItem();
                            newitem.Baseline                 = 0;
                            newitem.Benchmark                = 0;
                            newitem.Final                    = 0;
                            newitem.IndicatorID              = ProjectID;
                            newitem.IndicatorLabelID         = item.IndicatorLabelID;
                            newitem.IndicatorCategoryLabelID = item.IndicatorCategoryLabelID;
                            tosubmit.Add(newitem);
                        }
                    }
                }
            }
            try
            {
                db.IndicatorItems.InsertAllOnSubmit(tosubmit.AsEnumerable());
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(IndicatorRepository), "----------------------------------------------", ex);
                // result = false;
            }
            return(result);
        }
Ejemplo n.º 8
0
        private void EmissionFilter_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            XamComboEditor xce    = (XamComboEditor)sender;
            DataRecord     record = (DataRecord)xce.DataContext;

            if (record == null)
            {
                return;
            }
            IndicatorItem indItem = (IndicatorItem)record.DataItem;


            if (xamDataGrid.ActiveDataItem == null)
            {
                return;
            }

            if (xamDataGrid.ActiveDataItem.GetType() == typeof(IndicatorItem))
            {
                IndicatorItem indicator = (IndicatorItem)xamDataGrid.ActiveDataItem;

                if (e.NewValue == null)
                {
                    return;
                }

                if (e.NewValue.GetType() == typeof(FilterContainer))
                {
                    FilterContainer filter = (FilterContainer)e.NewValue;

                    if (indicator.IndicatorID != 0 && indicator.IndicatorID == indItem.IndicatorID)  // the 2nd condition makes sure the event is for the currently active Indicator
                    {
                        IndicatorContainer ic = new IndicatorContainer();
                        ic.Description              = indicator.Description;
                        ic.EmissionsFilterPosition  = filter.PositionNumber;
                        ic.ExcitationFilterPosition = indicator.ExcitationFilterPosition;
                        ic.IndicatorID              = indicator.IndicatorID;
                        ic.MethodID   = indicator.MethodID;
                        ic.SignalType = indicator.SignalType;

                        bool succcess = wgDB.UpdateIndicator(ic);
                    }
                }
            }
        }
        public bool UpdateIndicatorItem(IndicatorItem item)
        {
            bool result = true;

            try
            {
                db.IndicatorItems.Attach(item);
                db.Refresh(RefreshMode.KeepCurrentValues, item);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(IndicatorRepository), "----------------------------------------------", ex);
                result = false;
                //  throw ex;
            }
            return(result);
        }
        public bool InsertIndicatorItem(IndicatorItem item)
        {
            bool result = true;

            IfIndicatorCreate(item.IndicatorID);
            try
            {
                db.IndicatorItems.InsertOnSubmit(item);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(IndicatorRepository), "----------------------------------------------", ex);
                result = false;
                // throw ex;
            }
            return(result);
        }
Ejemplo n.º 11
0
        private void _chartControl_DragDrop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(typeof(IndicatorItem)))
            {
                return;
            }
            ChartBox cbox = this._chartControl.GetChartPanel(new Point(e.X, e.Y)) as ChartBox;

            if (cbox == null)
            {
                return;
            }
            IndicatorItem indicatorItem = e.Data.GetData(typeof(IndicatorItem)) as IndicatorItem;

            FigureIndicator figure = new FigureIndicator(indicatorItem.IndicatorType);

            cbox.Figures.Add(figure);
            Global.MainForm.Properties.SetPropertiesObject(figure);
        }
Ejemplo n.º 12
0
        public ActionResult NewIndicatorItem(int ddlIndicator, int ddlCategory,
                                             int NewBaseline, int NewBenchmark, int NewFinal)
        {
            if (Session["ProposalID"] == null)
            {
                return(RedirectToAction("Search", "ProposalInfo"));
            }

            IndicatorItem item = new IndicatorItem();

            //item.IndicatorID = int.Parse(Session["ProposalID"].ToString());
            item.IndicatorLabelID         = ddlIndicator;
            item.IndicatorCategoryLabelID = ddlCategory;
            item.IndicatorID = int.Parse(Session["ProposalID"].ToString());
            item.Baseline    = NewBaseline;
            item.Benchmark   = NewBenchmark;
            item.Final       = NewFinal;
            IService.InsertIndicatorItem(item);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 13
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);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public MethodManager()
        {
            InitializeComponent();

            wgDB = new WaveguideDB();

            VM = new MethodManagerViewModel();

            RefreshSignalTypeList();
            RefreshFilterList();

            //Initialize data in the XamDataGrid - NOTE: A blank record is added FIRST, this is key to this approach for the XamDataGrid
            MethodItem blank = new MethodItem();

            blank.Description     = "";
            blank.BravoMethodFile = "";
            blank.OwnerID         = GlobalVars.UserID;
            blank.MethodID        = 0;
            blank.IsPublic        = false;
            VM.Methods.Add(blank);

            // load all methods for user
            bool success = wgDB.GetAllMethodsForUser(GlobalVars.UserID);

            if (success)
            {
                foreach (MethodContainer mc in wgDB.m_methodList)
                {
                    MethodItem mi = new MethodItem();
                    mi.Description     = mc.Description;
                    mi.BravoMethodFile = mc.BravoMethodFile;
                    mi.OwnerID         = mc.OwnerID;
                    mi.MethodID        = mc.MethodID;
                    mi.IsPublic        = mc.IsPublic;

                    VM.Methods.Add(mi);

                    // load all indicators for the method
                    // add blank Indicator container to hold the AddRecord
                    ObservableCollection <FilterContainer>     exFilts = VM.ExcitationFilters;
                    ObservableCollection <FilterContainer>     emFilts = VM.EmissionsFilters;
                    ObservableCollection <SignalTypeContainer> stList  = VM.SignalTypeList;
                    IndicatorItem blankInd = new IndicatorItem(0, mi.MethodID, "", ref stList, ref exFilts, ref emFilts);

                    mi.Indicators.Add(blankInd);

                    success = wgDB.GetAllIndicatorsForMethod(mc.MethodID);
                    if (success)
                    {
                        foreach (IndicatorContainer ic in wgDB.m_indicatorList)
                        {
                            IndicatorItem ii = new IndicatorItem(ic.IndicatorID, ic.MethodID, ic.Description, ic.ExcitationFilterPosition, ic.EmissionsFilterPosition, ic.SignalType, ref stList, ref exFilts, ref emFilts);

                            mi.Indicators.Add(ii);
                        }
                    }



                    // load all compound plates for the method
                    // add blank Compound Plate container to hold the AddRecord
                    CompoundPlateItem blankCP = new CompoundPlateItem();
                    blankCP.CompoundPlateID = 0;
                    blankCP.MethodID        = mi.MethodID;
                    blankCP.Description     = "";
                    mi.CompoundPlates.Add(blankCP);

                    success = wgDB.GetAllCompoundPlatesForMethod(mc.MethodID);
                    if (success)
                    {
                        foreach (CompoundPlateContainer cpc in wgDB.m_compoundPlateList)
                        {
                            CompoundPlateItem cpi = new CompoundPlateItem();
                            cpi.CompoundPlateID = cpc.CompoundPlateID;
                            cpi.MethodID        = cpc.MethodID;
                            cpi.Description     = cpc.Description;

                            mi.CompoundPlates.Add(cpi);
                        }
                    }
                }
            }



            xamDataGrid.DataContext = VM;
        }
 public bool UpdateIndicatorItem(IndicatorItem item)
 {
     return(_rep.UpdateIndicatorItem(item));
 }
 public bool InsertIndicatorItem(IndicatorItem item)
 {
     return(_rep.InsertIndicatorItem(item));
 }