public void Delete(int idDTPFile) { DTPFile dtpFile = getItem(idDTPFile); list.Remove(dtpFile); dtpFile.Delete(); }
public void Add(DTPFile dtpFile) { if (list.Exists(item => item.ID == dtpFile.ID)) { return; } list.Add(dtpFile); }
protected override void loadFromSql() { DataTable dt = _provider.Select("DTPFile"); foreach (DataRow row in dt.Rows) { DTPFile dtpFile = new DTPFile(row); Add(dtpFile); } }
private void FillDgv() { _dgvFile.DataSource = _dtpFileList.ToDataTable(_dtp); _dgvFile.Columns[0].Visible = false; _dgvFile.Columns[1].Width = _dgvFile.Width / 2; _dgvFile.Columns[2].Width = _dgvFile.Width / 2; foreach (DataGridViewRow row in _dgvFile.Rows) { int id = 0; int.TryParse(row.Cells[0].Value.ToString(), out id); DTPFile dtpFile = _dtpFileList.getItem(id); if (dtpFile.File != string.Empty) { row.DefaultCellStyle.BackColor = BBColors.bbGreen3; } } }
private void _dgvFile_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (isCellNoHeader(e.RowIndex)) { int idDTPFile; int.TryParse(_dgvFile.Rows[e.RowIndex].Cells[0].Value.ToString(), out idDTPFile); DTPFile dtpFile = _dtpFileList.getItem(idDTPFile); if ((e.ColumnIndex == 2) && (dtpFile.File != string.Empty)) { WorkWithFiles.OpenFile(dtpFile.File); } else { DTPFile_AddEdit dtpFAE = new DTPFile_AddEdit(dtpFile); if (dtpFAE.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FillDgv(); } } } }
private void btnAddFile_Click(object sender, EventArgs e) { if (tryCopyData()) { _dtp.Save(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; ofd.ShowDialog(); foreach (string file in ofd.FileNames) { DTPFile dtpFile = _dtp.createFile(); dtpFile.Name = Path.GetFileNameWithoutExtension(file); dtpFile.File = file; dtpFile.Save(); _dtpFileList.Add(dtpFile); } FillDgv(); } }
public DTPFile_AddEdit(DTPFile dtpFile) { InitializeComponent(); _dtpFile = dtpFile; }