Ejemplo n.º 1
0
 public static IEnumerable <int> GetSoftwareIDsBySoftMaker(int idSoftMaker)
 {
     return(from softwareRow in FilterRows(SoftwareDataModel.GetInstance().Select())
            join softVersionRow in FilterRows(SoftVersionsDataModel.GetInstance().Select())
            on softwareRow.Field <int>("ID Software") equals softVersionRow.Field <int>("ID Software")
                where softwareRow.Field <int>("ID SoftMaker") == idSoftMaker
            select softVersionRow.Field <int>("ID Version"));
 }
        public SearchSoftwareForm()
        {
            InitializeComponent();
            var softwares  = SoftwareDataModel.GetInstance();
            var softMakers = SoftMakersDataModel.GetInstance();
            var softTypes  = SoftTypesDataModel.GetInstance();

            softwares.Select();
            softMakers.Select();
            softTypes.Select();

            var vSoftMakers = new BindingSource
            {
                DataMember = "SoftMakers",
                DataSource = DataSetManager.DataSet
            };

            var vSoftTypes = new BindingSource
            {
                DataMember = "SoftTypes",
                DataSource = DataSetManager.DataSet
            };

            comboBoxSoftwareMaker.DataSource    = vSoftMakers;
            comboBoxSoftwareMaker.ValueMember   = "ID SoftMaker";
            comboBoxSoftwareMaker.DisplayMember = "SoftMaker";

            comboBoxSoftwareType.DataSource    = vSoftTypes;
            comboBoxSoftwareType.ValueMember   = "ID SoftType";
            comboBoxSoftwareType.DisplayMember = "SoftType";

            foreach (Control control in Controls)
            {
                control.KeyDown += (sender, e) =>
                {
                    var comboBox = sender as ComboBox;
                    if (comboBox != null && comboBox.DroppedDown)
                    {
                        return;
                    }
                    switch (e.KeyCode)
                    {
                    case Keys.Enter:
                        vButtonSearch_Click(sender, e);
                        break;

                    case Keys.Escape:
                        DialogResult = DialogResult.Cancel;
                        break;
                    }
                }
            }
            ;
        }
Ejemplo n.º 3
0
        public override void LoadData()
        {
            dataGridView.AutoGenerateColumns = false;
            DockAreas   = WeifenLuo.WinFormsUI.Docking.DockAreas.Document;
            _softwareDm = SoftwareDataModel.GetInstance();
            _softTypes  = SoftTypesDataModel.GetInstance();
            _softMakers = SoftMakersDataModel.GetInstance();

            // Ожидаем дозагрузки, если это необходимо
            _softwareDm.Select();
            _softTypes.Select();
            _softMakers.Select();

            var ds = DataSetManager.DataSet;

            _vSoftTypes = new BindingSource
            {
                DataMember = "SoftTypes",
                DataSource = ds
            };

            _vSoftMakers = new BindingSource
            {
                DataMember = "SoftMakers",
                DataSource = ds
            };

            _vSoftware = new BindingSource();
            _vSoftware.CurrentItemChanged += v_software_CurrentItemChanged;
            _vSoftware.DataMember          = "Software";
            _vSoftware.DataSource          = ds;
            _vSoftware.Filter              = StaticFilter;
            if (!string.IsNullOrEmpty(StaticFilter) && !string.IsNullOrEmpty(DynamicFilter))
            {
                _vSoftware.Filter += " AND ";
            }
            _vSoftware.Filter += DynamicFilter;

            DataBind();

            _softwareDm.Select().RowChanged += SoftwareViewport_RowChanged;
            _softwareDm.Select().RowDeleted += SoftwareViewport_RowDeleted;

            dataGridView.RowCount = _vSoftware.Count;
            SetViewportCaption();
            ViewportHelper.SetDoubleBuffered(dataGridView);
            _isEditable = true;
        }
Ejemplo n.º 4
0
 private void PreLoadData()
 {
     toolStripProgressBar.Maximum = 13;
     DepartmentsDataModel.GetInstance(toolStripProgressBar, 1);
     DevicesDataModel.GetInstance(toolStripProgressBar, 1);
     SoftwareDataModel.GetInstance(toolStripProgressBar, 1);
     SoftVersionsDataModel.GetInstance(toolStripProgressBar, 1);
     SoftInstallationsDataModel.GetInstance(toolStripProgressBar, 1);
     SoftInstallatorsDataModel.GetInstance(toolStripProgressBar, 1);
     SoftLicDocTypesDataModel.GetInstance(toolStripProgressBar, 1);
     SoftLicensesDataModel.GetInstance(toolStripProgressBar, 1);
     SoftLicKeysDataModel.GetInstance(toolStripProgressBar, 1);
     SoftLicTypesDataModel.GetInstance(toolStripProgressBar, 1);
     SoftMakersDataModel.GetInstance(toolStripProgressBar, 1);
     SoftSuppliersDataModel.GetInstance(toolStripProgressBar, 1);
     SoftTypesDataModel.GetInstance(toolStripProgressBar, 1);
 }
        private static bool EditingNewRecordModel(string table)
        {
            switch (table)
            {
            case "Software":
                return(SoftwareDataModel.GetInstance().EditingNewRecord);

            case "SoftLicenses":
                return(SoftLicensesDataModel.GetInstance().EditingNewRecord);

            case "SoftInstallations":
                return(SoftInstallationsDataModel.GetInstance().EditingNewRecord);

            default:
                return(false);
            }
        }
Ejemplo n.º 6
0
        public static IEnumerable <int> GetLicenseIDsByCondition(Func <DataRow, bool> condition, EntityType entity)
        {
            var software     = FilterRows(SoftwareDataModel.GetInstance().Select());
            var softVersions = FilterRows(SoftVersionsDataModel.GetInstance().Select());
            var departments  = from departmentsRow in FilterRows(DepartmentsDataModel.GetInstance().SelectVisibleDepartments())
                               where departmentsRow.Field <bool>("AllowSelect")
                               select departmentsRow.Field <int>("ID Department");

            var licenses = from licensesRow in FilterRows(SoftLicensesDataModel.GetInstance().Select())
                           where departments.Contains(licensesRow.Field <int>("ID Department"))
                           select licensesRow;
            var result = from softwareRow in software
                         join softVersionRow in softVersions
                         on softwareRow.Field <int>("ID Software") equals softVersionRow.Field <int>("ID Software")
                         join licensesRow in licenses
                         on softVersionRow.Field <int>("ID Version") equals licensesRow.Field <int>("ID Version")
                             where entity == EntityType.Software ? condition(softwareRow) :
                         entity == EntityType.SoftVersion ? condition(softVersionRow) :
                         entity == EntityType.License && condition(licensesRow)
                         select licensesRow.Field <int>("ID License");

            return(result);
        }
Ejemplo n.º 7
0
        protected override void Calculate(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            DmLoadState = DataModelLoadState.Loading;
            if (e == null)
            {
                throw new DataModelException("Не передана ссылка на объект DoWorkEventArgs в классе CalcDataModelSoftwareConcat");
            }
            var config = (CalcAsyncConfig)e.Argument;
            // Фильтруем удаленные строки
            IEnumerable <DataRow> software;
            IEnumerable <DataRow> versions;

            if (config.Entity == EntityType.Software)
            {
                software = DataModelHelper.FilterRows(SoftwareDataModel.GetInstance().Select(), config.Entity,
                                                      config.IdObject);
                versions = DataModelHelper.FilterRows(SoftVersionsDataModel.GetInstance().Select(), config.Entity,
                                                      config.IdObject);
            }
            else if (config.Entity == EntityType.SoftVersion)
            {
                software = DataModelHelper.FilterRows(SoftwareDataModel.GetInstance().Select(), EntityType.Unknown,
                                                      null);
                versions = DataModelHelper.FilterRows(SoftVersionsDataModel.GetInstance().Select(), config.Entity,
                                                      config.IdObject);
            }
            else
            {
                software = DataModelHelper.FilterRows(SoftwareDataModel.GetInstance().Select(), EntityType.Unknown,
                                                      null);
                versions = DataModelHelper.FilterRows(SoftVersionsDataModel.GetInstance().Select(), EntityType.Unknown,
                                                      null);
            }
            // Вычисляем агрегационную информацию
            var result = from softwareRow in software
                         join versionRow in versions
                         on softwareRow.Field <int>("ID Software") equals versionRow.Field <int>("ID Software")
                         select new
            {
                id_version  = versionRow.Field <int>("ID Version"),
                id_software = versionRow.Field <int>("ID Software"),
                software    = softwareRow.Field <string>("Software") +
                              (versionRow.Field <string>("Version") == null ? "" : " " + versionRow.Field <string>("Version"))
            };
            // Заполняем таблицу изменений
            var table = InitializeTable();

            table.BeginLoadData();
            result.ToList().ForEach(x =>
            {
                table.Rows.Add(x.id_version, x.id_software, x.software);
            });
            table.EndLoadData();
            if (!DataSetManager.DataSet.Tables.Contains(TableName))
            {
                DataSetManager.AddTable(table);
            }
            else
            {
                DataSetManager.DataSet.Merge(table);
            }
            // Возвращаем результат
            e.Result = table;
        }