当前位置: 首页>>代码示例>>C#>>正文


C# BindingList.SingleOrDefault方法代码示例

本文整理汇总了C#中BindingList.SingleOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# BindingList.SingleOrDefault方法的具体用法?C# BindingList.SingleOrDefault怎么用?C# BindingList.SingleOrDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BindingList的用法示例。


在下文中一共展示了BindingList.SingleOrDefault方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateImagesInfoGrid

        private void UpdateImagesInfoGrid()
        {
            string selectedRowFileName = string.Empty;
            if (ImagesInfoGrid.SelectedRows.Count != 0)
                selectedRowFileName = ((ImageFileData)ImagesInfoGrid.SelectedRows[0].DataBoundItem).FileName;
            IEnumerable<ImageFileData> imagesInfo = manager.GetAllImagesInfo(true);
            if (imagesInfo == null)
                return;
            ImagesInfoGrid.Rows.Clear();
            var bindingList = new BindingList<ImageFileData>(new List<ImageFileData>(imagesInfo));
            ImagesInfoGrid.Invoke(new MethodInvoker(delegate() { ImagesInfoGrid.DataSource = bindingList; }));

            ImageFileData rowObject = bindingList.SingleOrDefault(p => p.FileName.Equals(selectedRowFileName));
            if (rowObject != null)
                ImagesInfoGrid.Rows[bindingList.IndexOf(rowObject)].Selected = true;
        }
开发者ID:duda92,项目名称:ImageService,代码行数:16,代码来源:ImageServiceClientForm.cs

示例2: CreateRemoveSensorButtonTemplate

        public FrameworkElementFactory CreateRemoveSensorButtonTemplate(PlantsArea area,
            BindingList<DataGridSensorView> dataGridSensorViews,
            BindingList<DataGridServiceScheduleView> dataGridServiceScheduleViews,
            Func<PlantsArea, Sensor, ServiceSchedule, bool> removeSensor)
        {
            FrameworkElementFactory buttonTemplate = new FrameworkElementFactory(typeof (Button));
            buttonTemplate.SetValue(ContentControl.ContentProperty, "X");
            buttonTemplate.AddHandler(
                ButtonBase.ClickEvent,
                new RoutedEventHandler((o, e) =>
                {
                    DataGridSensorView dataGridSensorView = ((FrameworkElement) o).DataContext as DataGridSensorView;
                    if (dataGridSensorView != null)
                    {
                        if (dataGridSensorViews.Count(s => s.Measurable == dataGridSensorView.Measurable) == 0)
                        {
                            MessageBox.Show(
                                $"'{dataGridSensorView.Measurable}': sensor with such measurable does not exist");
                            return;
                        }

                        ServiceState serviceState = area.PlantServicesStates.ServicesStates.SingleOrDefault(
                            state => state.IsFor(dataGridSensorView.Measurable));

                        if (serviceState != null)
                        {
                            DataGridServiceScheduleView dataGridServiceScheduleView =
                                dataGridServiceScheduleViews.SingleOrDefault(
                                    s => s.ServiceName == serviceState.ServiceName);

                            ServiceSchedule serviceSchedule =
                                area.ServicesSchedulesStates.ServicesSchedules.SingleOrDefault(
                                    schedule => schedule.ServiceName == serviceState.ServiceName);

                            removeSensor(area, dataGridSensorView.Sensor, serviceSchedule);

                            dataGridSensorViews.Remove(dataGridSensorView);
                            dataGridServiceScheduleViews.Remove(dataGridServiceScheduleView);
                        }
                    }
                    OnRefreshControls();
                })
                );
            return buttonTemplate;
        }
开发者ID:LexaGal,项目名称:Plants,代码行数:45,代码来源:FrameworkElementFactoriesBuilder.cs

示例3: DeleteConcreteEntities

        public void DeleteConcreteEntities(BindingList<TestForGrid> testGrids, BindingList<SpecimenForGrid> specimenGrids, BindingList<TubeForGrid> tubeGrids, BindingList<IndicationForGrid> indicationGrids, string orderNumber)
        {
            var oldConcreteTests = OrderService.FindConcreteTestsByOrder(orderNumber);
            foreach (var oldConcreteTest in oldConcreteTests)
            {
                if (!testGrids.Any(testGrid => testGrid.ConcreteCode == oldConcreteTest.Code))
                {
                    OrderService.DeleteConcreteTest(oldConcreteTest.Code);
                }
            }

            var oldConcreteSpecimens = OrderService.FindConcreteSpecimensByOrder(orderNumber);
            foreach (var oldConcreteSpecimen in oldConcreteSpecimens)
            {
                if (specimenGrids.SingleOrDefault<SpecimenForGrid>(specimenGrid => specimenGrid.ConcreteCode == oldConcreteSpecimen.Code) == null)
                {
                    OrderService.DeleteConcreteSpecimen(oldConcreteSpecimen.Code);
                }
            }

            var oldConcreteTubes = OrderService.FindConcreteTubesByOrder(orderNumber);
            foreach (var oldConcreteTube in oldConcreteTubes)
            {
                if (tubeGrids.SingleOrDefault<TubeForGrid>(tubeGrid => tubeGrid.ConcreteCode == oldConcreteTube.Code) == null)
                {
                    OrderService.DeleteConcreteTube(oldConcreteTube.Code);
                }
            }

            var oldConcreteIndications = OrderService.FindConcreteIndicationsByOrder(orderNumber);
            foreach (var oldConcreteIndication in oldConcreteIndications)
            {
                if (indicationGrids.SingleOrDefault<IndicationForGrid>(indicationGrid => indicationGrid.ConcreteCode == oldConcreteIndication.Code) == null)
                {
                    OrderService.DeleteConcreteIndication(oldConcreteIndication.Code);
                }
            }
        }
开发者ID:abonSerg,项目名称:Clinic,代码行数:38,代码来源:NewOrderModel.cs

示例4: CheckForConstrains

        public string CheckForConstrains(BindingList<SpecimenForGrid> specimenGrids, BindingList<TubeForGrid> tubeGrids, BindingList<TestForGrid> testGrids, BindingList<IndicationForGrid> indicationGrids)
        {
            if (!(specimenGrids.Count == 0) && !(tubeGrids.Count == 0) && !(tubeGrids.Count == 0))
            {
                int errorTestGridCount = testGrids.Where(testGrid => string.IsNullOrEmpty(testGrid.Code))
                                                  .Count();

                int errorTubeGridCount = tubeGrids.Where(tubeGrid => string.IsNullOrEmpty(tubeGrid.Code) || string.IsNullOrEmpty(tubeGrid.Tests))
                                                  .Count();

                int errorSpecimenGridCount = specimenGrids.Where(specimenGrid => string.IsNullOrEmpty(specimenGrid.Code) || specimenGrid.Volume < 1 || string.IsNullOrEmpty(specimenGrid.Tubes))
                                                          .Count();
                int errorIndicationGridCount = indicationGrids.Where(indicationGrid => string.IsNullOrEmpty(indicationGrid.Code))
                                                              .Count();

                if ((errorTestGridCount == 0) && (errorTubeGridCount == 0) && (errorSpecimenGridCount == 0) && (errorIndicationGridCount == 0))
                {
                    bool breakFlag = false;
                    string returnValue = string.Empty;
                    foreach (var specimenGrid in specimenGrids)
                    {
                        string[] tubesId = new string[0];
                        if (!breakFlag)
                        {
                            string tubesString = specimenGrid.Tubes;
                            tubesId = tubesString.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                        }
                        else
                        {
                            return returnValue;
                        }

                        foreach (var tubeId in tubesId)
                        {
                            var dtoSpecimenTubeAttach = new DtoSpecimenTubeAttach()
                            {
                                ConcreteSpecimen = new DtoConcreteSpecimen()
                                {
                                    CollectedDt = specimenGrid.CollectedDt,
                                    Volume = specimenGrid.Volume,
                                },

                                ConcreteTube = new DtoConcreteTube()
                                {
                                    ReceivedDt = tubeGrids.SingleOrDefault<TubeForGrid>(tube => tube.Id == tubeId).ReceivedDt,
                                    Tube = new DtoTube2()
                                    {
                                        Volume = new TubeServiceClient().GetTubeByCode(tubeGrids.Single<TubeForGrid>(tube => tube.Id == tubeId).Code).Volume
                                    }
                                }
                            };
                            if (dtoSpecimenTubeAttach.ConcreteTube.ReceivedDt > dtoSpecimenTubeAttach.ConcreteSpecimen.CollectedDt ||
                                (dtoSpecimenTubeAttach.ConcreteTube.ReceivedDt > DateTime.Now) ||
                                (dtoSpecimenTubeAttach.ConcreteSpecimen.CollectedDt > DateTime.Now))
                            {
                                breakFlag = true;
                                returnValue = "Invalid Date!";
                                break;
                            }
                            else if (dtoSpecimenTubeAttach.ConcreteTube.Tube.Volume < dtoSpecimenTubeAttach.ConcreteSpecimen.Volume)
                            {
                                breakFlag = true;
                                returnValue = "Invalid Specimen Volume!";
                                break;
                            }
                            else
                            {
                                returnValue = string.Empty;
                            }
                        }
                    }
                    return returnValue;

                }
                else
                {
                    return "Check validity of grids!";
                }
            }
            else
            {
                return "Fill all mandatory grids!";
            }
        }
开发者ID:abonSerg,项目名称:Clinic,代码行数:84,代码来源:NewOrderModel.cs

示例5: AddTestTubeAttch

 public void AddTestTubeAttch(BindingList<TubeForGrid> tubeGrids, BindingList<TestForGrid> testGrids)
 {
     foreach (var tubeGrid in tubeGrids)
     {
         string testsString = tubeGrid.Tests;
         string[] testCods = testsString.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
         foreach (var testCode in testCods)
         {
             string concreteTestCode = testGrids.SingleOrDefault<TestForGrid>(testGrid => testGrid.Code == testCode).ConcreteCode;
             var dtoTestTubeAttach = new DtoTestTubeAttach()
             {
                 DtoConctereTube = new DtoConcreteTube()
                 {
                     Id = OrderService.GetConcreteTubeByCode(tubeGrid.ConcreteCode).Id
                 },
                 DtoConcreteTest = new DtoConcreteTest1()
                 {
                     Id = OrderService.GetConcreteTestByCode(concreteTestCode).Id
                 }
             };
             OrderService.AddTestTubeAttach(dtoTestTubeAttach);
         }
     }
 }
开发者ID:abonSerg,项目名称:Clinic,代码行数:24,代码来源:NewOrderModel.cs

示例6: AddSpecimenTubeAttch

        public void AddSpecimenTubeAttch(BindingList<SpecimenForGrid> specimenGrids, BindingList<TubeForGrid> tubeGrids)
        {
            foreach (var specimenGrid in specimenGrids)
            {
                string tubesString = specimenGrid.Tubes;
                string[] tubesId = tubesString.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var tubeId in tubesId)
                {
                    string concreteTubeCode = tubeGrids.SingleOrDefault<TubeForGrid>(tubeGrid => tubeGrid.Id == tubeId).ConcreteCode;
                    var dtoSpecimenTubeAttach = new DtoSpecimenTubeAttach()
                    {
                        ConcreteSpecimen = new DtoConcreteSpecimen()
                        {
                            Id = OrderService.GetConcreteSpecimenByCode(specimenGrid.ConcreteCode).Id
                        },

                        ConcreteTube = new DtoConcreteTube()
                        {
                            Id = OrderService.GetConcreteTubeByCode(concreteTubeCode).Id
                        }
                    };
                    OrderService.AddSpecimenTubeAttach(dtoSpecimenTubeAttach);
                }
            }
        }
开发者ID:abonSerg,项目名称:Clinic,代码行数:25,代码来源:NewOrderModel.cs


注:本文中的BindingList.SingleOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。