public WindowCheck(Session session, CheckTypes checkType) { InitializeComponent(); #region Initialize _session = session; _db = session.GetDbManager(); _checkType = checkType; listBoxCheck.MouseDoubleClick += ListBoxCheckMouseDoubleClick; listBoxCheck.SelectionChanged += ListBoxCheckSelectionChanged; buttonCancel.Click += ButtonCancelClick; buttonSubmit.Click += ButtonSubmitClick; _session.GetDocument().DocProjected += DbDocProjected; _checkList = new List<Check>(); try { _checkList.AddRange(_session.GetDocument().GetCheckList(_checkType)); } catch (AssortmentDBException e) { MessageBox.Show(e.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning); } listBoxCheck.ItemsSource = _checkList; #endregion #region Initialize Background Worker _worker = new BackgroundWorker(); _worker.DoWork += WorkerDoWork; _worker.RunWorkerCompleted += WorkerRunWorkerCompleted; _worker.ProgressChanged += WorkerProgressChanged; #endregion if (_checkList.Count == 0) return; _checkList[0].Status = CheckStatuses.Executing; _nCheck = 0; if (!_worker.IsBusy) _worker.RunWorkerAsync(); else { MessageBox.Show("Проверки уже запущены", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public WindowRowOriented(Session session, PivotGridControl pivotGridControl1) { InitializeComponent(); #region Initialize _session = session; _closeWithoutCheck = false; _db = _session.GetDbManager(); _doc = _session.GetDocument(); //ThemeManager.SetThemeName(this, "Office2007Silver"); ThemeManager.SetThemeName(this, "DeepBlue"); WindowState = WindowState.Maximized; Closing += WindowSecondaryClosing; _doc.DocProjected += DbDocProjected; var desc = _doc.Description; Title = "Документ: " + (desc ?? "не создан") + " (" + _doc.Id + ", " + DocTypes.Description(_doc.DocType) + ")"; //Title = "Документ: " + (desc.Equals("") ? "не создан" : desc) + " (" + _doc.Id + ", " + (_doc.DocType == DocTypes.Operative ? "Оперативный" : "Обычный") + ")"; try { _db.FillDataTableCustom(Table.TableSupplier.Name, Table.TableSupplier.SelectClause, Table.TableSupplier.KeyFields, false); } catch (AssortmentException ex) { MessageBox.Show(Table.TableSupplier + ": " + ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* if (_db.FillDataTableCustom(Table.TableSupplier.Name, Table.TableSupplier.SelectClause, Table.TableSupplier.KeyFields, false) == false) { MessageBox.Show("Ошибка при формировании источника: " + _db.Error, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } */ #endregion #region Initialize PivotGrid Control try { _db.FillDataTableCustom(Table.TableRowSource); } catch (AssortmentException ex) { MessageBox.Show(Table.TableRowSource + ": " + ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* if (_db.FillDataTableCustom(Table.TableRowSource) == false) { MessageBox.Show("Ошибка при формировании источника: " + _db.Error, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } */ _pivotGridControl2.DataSource = _db.DataTableGet(Table.TableRowSource.Name).DefaultView; _pivotGridControl2.HiddenFieldList += PivotGridControl2HiddenFieldList; var dimensions = _db.GetTableDefinition(Table.TableRowSource.DBName); if (dimensions == null) { MessageBox.Show("Список измерений для данной таблицы пуст", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } else { _pivotGridControl2.InitializeControl(dimensions, _db); } _pivotGridControl2.InitializeLayout(pivotGridControl1); _pivotGridControl2.ShowRowTotals = false; _pivotGridControl2.ShowColumnTotals = false; _pivotGridControl2.ShowColumnGrandTotals = false; _pivotGridControl2.ShowRowGrandTotals = false; _pivotGridControl2.CellClickInputData += PivotGridControl2CellClickInputData; _pivotGridControl2.BestFit(); #endregion }
public WindowCheckError(Session session, CheckTypes checkType, Check check) { WhRestExistsCheckNewDoc += WhRestExistsCheckNewDocHandler; _session = session; _check = check; InitializeComponent(); this.DataContext = check; Title = check.Desc; if (_check.ProcedureName == "global_wh_rest_exists") { var menuItemSaveDoc = new MenuItem{Header="Создать документ"}; menuItemSaveDoc.Click += menuItemSaveDoc_Click; menuMain.Items.Add(menuItemSaveDoc); } Width = 750; Height = 650; _db = session.GetDbManager(); #region Initialize Control //gridControl1.AutoPopulateColumns = true; gridControl1.DataSource = _db.DataTableGet(check.ProcedureName).DefaultView; if (check.TableName != null) { List<Column> columns; try { columns = _db.GetTableDefinition(check.TableName); /* columns = _db.GetTableDefinition(check.TableName ?? (checkType == CheckTypes.Local ? "y_assortment_doc_detail" : "y_assortment_united_sec_gtt")); */ } catch (AssortmentException e) { MessageBox.Show(e.Message, "Ошибка детализации", MessageBoxButton.OK, MessageBoxImage.Error); return; } //var src = new DataTable("SRC"); foreach (var column in columns) { if (column.Name == "PARAMS") { var table = _db.DataTableGet(check.ProcedureName); var maxColumn = 0; /* foreach (DataColumn col in table.Columns) { if (col.ColumnName != "PARAMS" && col.ColumnName.Contains("PARAM"))table.Columns.Remove(col); } */ for (int i = 1; i < 30; i++) { try { table.Columns.Remove("PARAM" + i); } catch { } } foreach (DataRow row in table.Rows) { var rowParams = row["PARAMS"].ToString(); var qty = rowParams.Split(';').Length; if (qty > maxColumn) maxColumn = qty; } for (int i = 1; i <= maxColumn; i++) { table.Columns.Add("PARAM" + i); gridControl1.Columns.Add(new GridColumn { FieldName = "PARAM" + i, Header = "Параметр " + i, AllowEditing = DefaultBoolean.False }); } foreach (DataRow row in table.Rows) { var rowParams = row["PARAMS"].ToString(); var rowParamsArray = rowParams.Split(';'); for (int i = 1; i <= rowParamsArray.Length; i++) { row["PARAM" + i] = rowParamsArray[i - 1]; } } } else { //src.Columns.Add(new DataColumn(column.Name)); gridControl1.Columns.Add(new GridColumn { FieldName = column.Name, Header = column.Desc, AllowEditing = DefaultBoolean.False }); } } } else { switch (checkType) { case CheckTypes.Local: { gridControl1.Columns.Add(new GridColumn { FieldName = "ITEM", Header = "Товар", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEM_DESC", Header = "Наименование", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "LOC", Header = "Магазин", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_LOC_DESC", Header = "Название", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "ACTION", Header = "Действие", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "SUPPLIER", Header = "Поставщик", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEMLOC_SUPPLIER_DESC", Header = "Название", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "SUPPLIER_NEW", Header = "Поставщик (новый)", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEMLOC_SUPPLIER_DESC_NEW", Header = "Название", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "ORDERPLACE", Header = "Место заказа", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "ORDERPLACE_NEW", Header = "Место заказа (новое)", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "SOURCEMETHOD", Header = "Тип поставки", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "SOURCEMETHOD_NEW", Header = "Тип поставки (новый)", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "SOURCEWH", Header = "Склад поставки", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "SOURCEWH_NEW", Header = "Склад поставки (новый)", AllowEditing = DefaultBoolean.False }); break; } case CheckTypes.Global: { gridControl1.Columns.Add(new GridColumn { FieldName = "ITEM", Header = "Товар", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEM_DESC", Header = "Наименование", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "LOC", Header = "Магазин", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_LOC_DESC", Header = "Название", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEMLOC_SUPPLIER_NEW", Header = "Поставщик", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEMLOC_SUPPLIER_DESC_NEW", Header = "Имя", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEMLOC_SOURCEMETHOD_NEW", Header = "Способ поставки", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEMLOC_SOURCEWH_NEW", Header = "Склад поставки", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "DIM_ITEMLOC_ORDERPLACE_NEW", Header = "Место заказа", AllowEditing = DefaultBoolean.False }); gridControl1.Columns.Add(new GridColumn { FieldName = "ACTION", Header = "Действие", AllowEditing = DefaultBoolean.False }); break; } } } #endregion }