/// <summary> /// Получает список идентификаторов неиспользованных ключей. Для корпоративных и электронных лицензий возвращает все ключи, для локальных только неиспользованные /// </summary> /// <param name="idLicense">Идентификатор лицензии</param> /// <returns>Список идентификаторов ключей</returns> public static IEnumerable <int> LicKeyIdsNotUsed(int idLicense) { return(from licenseKeyRow in FilterRows(SoftLicKeysDataModel.GetInstance().Select()) join licenseRow in FilterRows(SoftLicensesDataModel.GetInstance().Select()) on licenseKeyRow.Field <int?>("ID License") equals licenseRow.Field <int?>("ID License") join licenseTypeRow in FilterRows(SoftLicTypesDataModel.GetInstance().Select()) on licenseRow.Field <int?>("ID LicType") equals licenseTypeRow.Field <int?>("ID LicType") join installationRow in FilterRows(SoftInstallationsDataModel.GetInstance().Select()) on licenseKeyRow.Field <int?>("ID LicenseKey") equals installationRow.Field <int?>("ID LicenseKey") into jg from jgRow in jg.DefaultIfEmpty() where licenseKeyRow.Field <int?>("ID License") == idLicense && (jgRow == null || licenseTypeRow.Field <bool?>("LicKeyDuplicateAllowed") == true) select licenseKeyRow.Field <int>("ID LicenseKey")); }
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); }
public override void LoadData() { dataGridView.AutoGenerateColumns = false; DockAreas = WeifenLuo.WinFormsUI.Docking.DockAreas.Document; _softLicTypes = SoftLicTypesDataModel.GetInstance(); //Ожидаем дозагрузки данных, если это необходимо _softLicTypes.Select(); _vSoftLicTypes = new BindingSource { DataMember = "SoftLicTypes", DataSource = DataSetManager.DataSet }; //Инициируем колонки snapshot-модели for (var i = 0; i < _softLicTypes.Select().Columns.Count; i++) { _snapshotSoftLicTypes.Columns.Add(new DataColumn( _softLicTypes.Select().Columns[i].ColumnName, _softLicTypes.Select().Columns[i].DataType)); } //Загружаем данные snapshot-модели из original-view for (var i = 0; i < _vSoftLicTypes.Count; i++) { _snapshotSoftLicTypes.Rows.Add(DataRowViewToArray((DataRowView)_vSoftLicTypes[i])); } _vSnapshotSoftLicTypes = new BindingSource { DataSource = _snapshotSoftLicTypes }; _vSnapshotSoftLicTypes.CurrentItemChanged += v_snapshotSoftLicTypes_CurrentItemChanged; dataGridView.DataSource = _vSnapshotSoftLicTypes; idSoftLicType.DataPropertyName = "ID LicType"; softLicType.DataPropertyName = "LicType"; softLicKeyDuplicateAllowed.DataPropertyName = "LicKeyDuplicateAllowed"; dataGridView.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; dataGridView.CellValidated += dataGridView_CellValidated; //События изменения данных для проверки соответствия реальным данным в модели dataGridView.CellValueChanged += dataGridView_CellValueChanged; //Синхронизация данных исходные->текущие _softLicTypes.Select().RowChanged += SoftLicTypesViewport_RowChanged; _softLicTypes.Select().RowDeleting += SoftLicTypesViewport_RowDeleting; _softLicTypes.Select().RowDeleted += SoftLicTypesViewport_RowDeleted; }
public SearchLicensesForm() { InitializeComponent(); var softMakers = SoftMakersDataModel.GetInstance(); var softTypes = SoftTypesDataModel.GetInstance(); var softSuppliers = SoftSuppliersDataModel.GetInstance(); var softLicTypes = SoftLicTypesDataModel.GetInstance(); var softLicDocTypes = SoftLicDocTypesDataModel.GetInstance(); var departments = DepartmentsDataModel.GetInstance(); // Ожидаем дозагрузки, если это необходимо softMakers.Select(); softTypes.Select(); softSuppliers.Select(); softLicTypes.Select(); softLicDocTypes.Select(); departments.Select(); var vSoftMakers = new BindingSource { DataMember = "SoftMakers", DataSource = DataSetManager.DataSet }; var vSoftTypes = new BindingSource { DataMember = "SoftTypes", DataSource = DataSetManager.DataSet }; var vSoftSuppliers = new BindingSource { DataMember = "SoftSuppliers", DataSource = DataSetManager.DataSet }; var vSoftLicTypes = new BindingSource { DataMember = "SoftLicTypes", DataSource = DataSetManager.DataSet }; var vSoftLicDocTypes = new BindingSource { DataMember = "SoftLicDocTypes", DataSource = DataSetManager.DataSet }; _vDepartments = new BindingSource { DataSource = departments.SelectVisibleDepartments() }; comboBoxDepartmentID.DataSource = _vDepartments; comboBoxDepartmentID.ValueMember = "ID Department"; comboBoxDepartmentID.DisplayMember = "Department"; comboBoxSoftwareMaker.DataSource = vSoftMakers; comboBoxSoftwareMaker.ValueMember = "ID SoftMaker"; comboBoxSoftwareMaker.DisplayMember = "SoftMaker"; comboBoxSupplierID.DataSource = vSoftSuppliers; comboBoxSupplierID.ValueMember = "ID Supplier"; comboBoxSupplierID.DisplayMember = "Supplier"; comboBoxSoftwareType.DataSource = vSoftTypes; comboBoxSoftwareType.ValueMember = "ID SoftType"; comboBoxSoftwareType.DisplayMember = "SoftType"; comboBoxLicType.DataSource = vSoftLicTypes; comboBoxLicType.ValueMember = "ID LicType"; comboBoxLicType.DisplayMember = "LicType"; comboBoxLicDocType.DataSource = vSoftLicDocTypes; comboBoxLicDocType.ValueMember = "ID DocType"; comboBoxLicDocType.DisplayMember = "DocType"; comboBoxOpBuyLicenseDate.SelectedIndex = 0; comboBoxOpExpireLicenseDate.SelectedIndex = 0; foreach (Control control in Controls) { control.KeyDown += (sender, e) => { var comboBox = sender as ComboBox; if (comboBox != null && comboBox.DroppedDown) { return; } if (e.KeyCode == Keys.Enter) { vButtonSearch_Click(sender, e); } else if (e.KeyCode == Keys.Escape) { DialogResult = DialogResult.Cancel; } } } ; }
public override void SaveRecord() { dataGridView.EndEdit(); _syncViews = false; var list = SoftLicTypesFromViewport(); if (!ValidateViewportData(list)) { _syncViews = true; return; } for (var i = 0; i < list.Count; i++) { var row = _softLicTypes.Select().Rows.Find(list[i].IdLicType); if (row == null) { var idSoftLicType = SoftLicTypesDataModel.Insert(list[i]); if (idSoftLicType == -1) { _syncViews = true; return; } ((DataRowView)_vSnapshotSoftLicTypes[i])["ID LicType"] = idSoftLicType; _softLicTypes.Select().Rows.Add(DataRowViewToArray((DataRowView)_vSnapshotSoftLicTypes[i])); } else { if (RowToSoftLicType(row) == list[i]) { continue; } if (SoftLicTypesDataModel.Update(list[i]) == -1) { _syncViews = true; return; } row["LicType"] = list[i].LicType == null ? DBNull.Value : (object)list[i].LicType; row["LicKeyDuplicateAllowed"] = list[i].LicKeyDuplicateAllowed == null ? DBNull.Value : (object)list[i].LicKeyDuplicateAllowed; } } list = SoftLicTypesFromView(); for (var i = 0; i < list.Count; i++) { var rowIndex = -1; for (var j = 0; j < dataGridView.Rows.Count; j++) { if ((dataGridView.Rows[j].Cells["idSoftLicType"].Value != null) && !string.IsNullOrEmpty(dataGridView.Rows[j].Cells["idSoftLicType"].Value.ToString()) && ((int)dataGridView.Rows[j].Cells["idSoftLicType"].Value == list[i].IdLicType)) { rowIndex = j; } } if (rowIndex == -1) { if (SoftLicTypesDataModel.Delete(list[i].IdLicType.Value) == -1) { _syncViews = true; return; } _softLicTypes.Select().Rows.Find(list[i].IdLicType).Delete(); } } _syncViews = true; MenuCallback.EditingStateUpdate(); }