private async void ButtonDeleteRow_Click(object sender, EventArgs e) { try { if (DataGridView.SelectedCells.Count == 0) { MessageBoxTemplates.InfoSync(_labels.GetLabel("SelectBeforeRemove")); return; } var res = MessageBox.Show(_labels.GetLabel("WarningBeforeRemove"), "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (res == DialogResult.Cancel) { return; } foreach (DataGridViewCell selCell in DataGridView.SelectedCells) { _ic.Samples.Remove(Data.Where(s => s.ToString() == SetKey && s.A_Sample_ID == selCell.OwningRow.Cells["A_Sample_ID"].Value.ToString()).FirstOrDefault()); DataGridView.Rows.Remove(selCell.OwningRow); } await _ic.SaveChangesAsync(); } catch (Exception ex) { MessageBoxTemplates.ErrorSync(ex.Message); } }
private void DataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= DataGridView.Rows.Count) { return; } if (e.RowIndex == -1) { return; } if (DataGridView.Rows[e.RowIndex].IsNewRow) { return; } ButtonSaveToDB.Enabled = true; var cell = DataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]; var column = DataGridView.Columns[e.ColumnIndex]; if (column.Name == "A_Longitude" || column.Name == "A_Latitude") { if (cell.Value == null) { MessageBoxTemplates.InfoSync($"Value of {column.Name} is empty and doesn't match with template: <->00.00000<0>"); return; } if (cell.Value.ToString().Length > 9) { MessageBoxTemplates.InfoSync($"Value of {column.Name} is to long for db {cell.Value.ToString().Length}. Should be 9."); return; } var reg = new System.Text.RegularExpressions.Regex(@"[-]{0,1}\d{1,2}.\d{1,6}"); if (!reg.IsMatch(cell.Value.ToString())) { MessageBoxTemplates.InfoSync($"Format of {column.Name} doesn't match with template: <->00.00000<0>"); return; } if (!double.TryParse(cell.Value.ToString(), out _)) { MessageBoxTemplates.InfoSync($"Format of {column.Name} doesn't match with template: <->00.00000<0>"); return; } } }
private async void ExportFromExcelButton_Click(object sender, EventArgs e) { MessageBoxTemplates.InfoSync("Functional would soon be added"); }