public GroupView(SveraGr sveraGr, SveraGrFormDataBase grFromDataBase) { InitializeComponent(); if (Svera.Properties.Settings.Default.GroupViewSize != new Size(0, 0)) { this.Size = Svera.Properties.Settings.Default.GroupViewSize; } if (Svera.Properties.Settings.Default.GroupViewLocation != new Point(0, 0)) { this.Location = Svera.Properties.Settings.Default.GroupViewLocation; } if (sveraGr.ColList.Count > 0) { DataGridViewColumn[] dataGridColSver = new DataGridViewColumn[sveraGr.ColList.Count]; ColumnNames colName; for (int i = 0; i <= sveraGr.ColList.Count - 1; i++) { colName = sveraGr.ColList[i]; if (colName.dataColType == typeof(DataGridViewButtonColumn)) { DataGridViewButtonColumn bb = new DataGridViewButtonColumn(); bb.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; bb.FlatStyle = FlatStyle.Flat; dataGridColSver[i] = bb; } else { dataGridColSver[i] = new DataGridViewTextBoxColumn(); } dataGridColSver[i].Name = colName.nameColumn; dataGridColSver[i].HeaderText = colName.textColumn; dataGridColSver[i].SortMode = DataGridViewColumnSortMode.NotSortable; if (colName.readOnly == true) { dataGridColSver[i].ReadOnly = true; } } DopFunctions.SetDoubleBuffered(sverPDataGrid); sverPDataGrid.Columns.AddRange(dataGridColSver); sverPDataGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; sverPDataGrid.Columns[SveraCl.Naim].DefaultCellStyle.WrapMode = DataGridViewTriState.True; } if (grFromDataBase != null) { List <DetalizedCl.IdAndKol> KolAndId = sveraGr.HashOutKolAndId(grFromDataBase.GroupId); if (KolAndId != null && KolAndId.Count > 0) { DataGridViewRow[] dtr = new DataGridViewRow[KolAndId.Count]; int chet = 0; foreach (DetalizedCl.IdAndKol klId in KolAndId) { int ind = sveraGr.FromDataBase.FindIndex(n => n.IdBase == klId.Id); if (ind > -1) { dtr[chet] = new DataGridViewRow(); dtr[chet].CreateCells(sverPDataGrid); dtr[chet].Cells[sverPDataGrid.Columns[SveraGr.EdIzm].Index].Value = sveraGr.FromDataBase[ind].EdIzm; dtr[chet].Cells[sverPDataGrid.Columns[SveraGr.Enum].Index].Value = klId.Kolic; dtr[chet].Cells[sverPDataGrid.Columns[SveraGr.Naim].Index].Value = sveraGr.FromDataBase[ind].GetNaim(); chet += 1; } } sverPDataGrid.Rows.AddRange(dtr); } } SizeChange(); }
private void prinat_Click(object sender, EventArgs e) { try { DetalizedCl detUse = null; if (ComboDate.SelectedIndex > -1) { SveraGrFormDataBase sveraGrDb = ComboDate.SelectedItem as SveraGrFormDataBase; FromDataBase svGr = sveraGr.FromDataBase.FirstOrDefault(sv => sv.IdBase == sveraGrDb.NaimId); bool ins = false; int ind = -1; if (sveraGr.FromDataBaseCl.Count > 0) { ind = sveraGr.FromDataBaseCl.FindIndex(cp => cp.IdBase == sveraGrDb.NaimId); if (ind > -1) { } else { ins = true; } } else { ins = true; } if (ins == true) { sveraGr.AddRowinFromBase(svGr); sveraGr.UpdateDetalized(sveraGr.Detalized); } if (ind == -1) { ind = sveraGr.FromDataBaseCl.FindIndex(cp => cp.IdBase == sveraGrDb.NaimId); } sveraGr.FromDataBaseCl[ind].ElGroup = YesNoDif.Yes; sveraGr.FromDataBaseCl[ind].PosicUse = YesNoDif.Yes; sveraGr.FromDataBaseCl[ind].Detail = SveraParam.Detalization[(int)SveraClass.detalizationEnum.Detail]; sveraGr.FromDataBaseCl[ind].DetailW = SveraParam.Detalization[(int)SveraClass.detalizationEnum.DetailSum]; if (sveraGr.Detalized != null && sveraGr.Detalized.Count > 0) { detUse = sveraGr.Detalized.First(d => d.IdBase == svGr.IdBase); detUse.Check = true; } if (sveraGrDb.GroupId != null && sveraGrDb.GroupId != "") { List <DetalizedCl.IdAndKol> KolAndId = sveraGr.HashOutKolAndId(sveraGrDb.GroupId); if (KolAndId != null && KolAndId.Count > 0) { foreach (DetalizedCl.IdAndKol klId in KolAndId) { int indsec = sveraGr.FromDataBaseCl.FindIndex(n => n.IdBase == klId.Id); FromDataBase svGrKol = sveraGr.FromDataBase.FirstOrDefault(sv => sv.IdBase == klId.Id); if (indsec > -1) { klId.Id = sveraGr.FromDataBaseCl[indsec].Id; } else { sveraGr.AddRowinFromBase(svGrKol); indsec = sveraGr.FromDataBaseCl.Count - 1; klId.Id = sveraGr.FromDataBaseCl[sveraGr.FromDataBaseCl.Count - 1].Id; } sveraGr.FromDataBaseCl[indsec].ElGroup = YesNoDif.No; sveraGr.FromDataBaseCl[indsec].PosicUse = YesNoDif.No; } if (detUse != null) { detUse.AddRows(KolAndId); } } } sveraGr.UpdateGroup(); updateCheck(sveraGr.Detalized); if (detUse != null) { checkGroup.SelectedIndex = sveraGr.Detalized.FindIndex(d => d.Id == detUse.Id); } } else { MessageBox.Show("Необходимо выбрать шаблон из базы", "База данных", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); if (ex.InnerException != null) { MessageBox.Show(ex.InnerException.ToString()); } } }