Beispiel #1
0
 public AreaDetailReport(MainDataContexts dataContexts,Area reportedArea)
 {
     InitializeComponent();
     _dataContexts = dataContexts;
     _dataSet=new ReportDataSet();
     _reportedArea = reportedArea;
 }
Beispiel #2
0
 public EquipmentManage(MainDataContexts dataContexts,Area area,Equipment manageEquipment, int buttonTag)
 {
     InitializeComponent();
     _dataContexts = dataContexts;
     _manageEquipment = manageEquipment;
     _buttonTag = buttonTag;
     _area = area;
     lbPorts.MultiSelect = true;
     lbCards.MultiSelect = true;
 }
Beispiel #3
0
 private void miAdd_Click(object sender, EventArgs e)
 {
     InputSingleLine inp = new InputSingleLine() {Text = @"Введите название узла"};
     Area selectedArea = AreasTree.SelectedNode != null ? AreasTree.SelectedNode.Tag as Area : null;
     if (inp.ShowDialog(this) == DialogResult.OK)
     {
         if (!string.IsNullOrEmpty(inp.InputLine.Text))
         {
             try
             {
                 Cursor = Cursors.WaitCursor;
                 var pData = _dataContext.Areas.FirstOrDefault(area => area.Description.Equals(inp.InputLine.Text));
                 if (pData == null)
                 {
                     Area newArea = new Area()
                     {
                         AreaId = Guid.NewGuid(),
                         Description = inp.InputLine.Text,
                         ParentAreaId = selectedArea != null ? selectedArea.AreaId : (Guid?) null,
                         ParentArea = selectedArea
                     };
                     _dataContext.Areas.Add(newArea);
                     _dataContext.SaveChanges();
                     RefreshTree();
                     OnHistoryEvent(new HistoryEventArgs("Add AreaDescription", inp.InputLine.Text));
                     OnChanged(EventArgs.Empty);
                     Cursor = Cursors.Default;
                 }
                 else
                 {
                     MessageBox.Show(string.Format(@"Узел '{0}' существует.", inp.InputLine.Text), @"Информация", MessageBoxButtons.OK);
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }
Beispiel #4
0
        public void ReloadData(Area reloadedArea,bool force=false)
        {
            if (reloadedArea == null)
                return;
            if (!force)
                if (reloadedArea == _loadedArea)
                    return;
            _loadedArea = reloadedArea;
            if (!SharedAppData.IsAccesible(ObjectAccessId))
            {
                label1.Text = @"Нет прав для просмотра " + ObjectAccessId.Description;
                label1.ForeColor = Color.Red;
                label2.Text = "";
                label3.Text = "";
                return;
            }
            tbAdd1.Enabled = tbAdd2.Enabled = tbAdd3.Enabled = SharedAppData.IsFlagSet(ObjectAccessId, RightsFlags.Add) ;
            tbEdit1.Enabled = tbEdit2.Enabled = tbEdit3.Enabled = SharedAppData.IsFlagSet(EquipmentManage.ObjectAccessId, RightsFlags.Change) | SharedAppData.IsFlagSet(EquipmentManage.ObjectAccessId, RightsFlags.View);
            tbDelete1.Enabled = tbDelete2.Enabled = tbDelete3.Enabled = SharedAppData.IsFlagSet(ObjectAccessId, RightsFlags.Delete);
            RemoveGridsSelectionHandler();

            #region Set label texts
            label1.Text = @"Оборудование провайдера, установленное на " + reloadedArea.Description;
            label2.Text = @"Оборудование провайдера, установленное у абонента";
            label3.Text = @"Оборудование абонента, установленное на " + reloadedArea.Description;
            #endregion

            Cursor = Cursors.WaitCursor;
            List<Equipment> areaEquipments=new List<Equipment>();
            MiniSplash splash = new MiniSplash
            {
                TaskName = "LoadAreaEquipments",
                Text = "",
                Working = (worker) =>
                {
                    try
                    {
                        if (worker == null) throw new Exception("Invalid background worker process");
                        worker.ReportProgress(0, "Загрузка данных");
                        areaEquipments =
                            _dataContexts.AccEquipmentV2Entities.Equipments.Where(equipment => equipment.Area.AreaId == reloadedArea.AreaId)
                                .Include(equipment => equipment.SideLink)
                                .Include(equipment => equipment.SideLink.CustomerSide)
                                .Include(equipment => equipment.EquipmentPorts.Select(port => port.PortType))
                                .ToList();
                        _dataContexts.AccEquipmentV2Entities.EntityObjectContext.Refresh(RefreshMode.StoreWins, areaEquipments);
                    }
                    catch (Exception)
                    {
                        throw;
                    }

                }
            };
            splash.ShowDialog(this);
            var dataProviderSetProviderAll = areaEquipments.Where(equipment => equipment.ParentEquipment==null & equipment.OwnerType == (int) EquipmentOwner.Provider & equipment.PlaceType == (int) EquipmentSide.ProviderArea).ToList();
            var dataProviderSetClientAll = areaEquipments.Where(equipment => equipment.ParentEquipment == null & equipment.OwnerType == (int)EquipmentOwner.Provider & equipment.PlaceType == (int)EquipmentSide.ClientArea).ToList();
            var dataClientSetProviderAll = areaEquipments.Where(equipment => equipment.ParentEquipment == null & equipment.OwnerType == (int)EquipmentOwner.Client & equipment.PlaceType == (int)EquipmentSide.ProviderArea).ToList();

            gvProviderSetProviderSummary.DataSource = null;
            gvProviderSetClientSummary.DataSource = null;
            gvClientSetProviderSummary.DataSource = null;
            if (dataProviderSetProviderAll.Any())
                gvProviderSetProviderSummary.DataSource = dataProviderSetProviderAll
                    .GroupBy(grp => grp.Description, (key, group) => new {Key = key, Group = group})
                    .Select(item => new EquipmentGridViewItemGrouped {Description = item.Key, Count = item.Group.Count(), GroupedEquipemnts = item.Group.ToList()})
                    .OrderBy(item=>item.Description)
                    .ToList();
            if (dataProviderSetClientAll.Any())
                gvProviderSetClientSummary.DataSource = dataProviderSetClientAll
                    .GroupBy(grp => grp.Description, (key, group) => new {Key = key, Group = group})
                    .Select(item => new EquipmentGridViewItemGrouped {Description = item.Key, Count = item.Group.Count(), GroupedEquipemnts = item.Group.ToList()})
                    .OrderBy(item => item.Description)
                    .ToList();
            if (dataClientSetProviderAll.Any())
                gvClientSetProviderSummary.DataSource = dataClientSetProviderAll
                    .GroupBy(grp => grp.Description, (key, group) => new {Key = key, Group = group})
                    .Select(item => new EquipmentGridViewItemGrouped {Description = item.Key, Count = item.Group.Count(), GroupedEquipemnts = item.Group.ToList()})
                    .OrderBy(item => item.Description)
                    .ToList();
            SetGridsSelectionHandler(true);
            Cursor = Cursors.Default;
        }