public static void OnUpdateFMainDataGridView(AddUpdateDelete aud, TableFileInfo tableFileInfo, bool isErr = false, bool clearRows = false) { if (UpdateDataGridViewEvent != null) { UpdateDataGridViewEvent(aud, tableFileInfo, isErr, clearRows); } }
private void UpdateDVTableFile(AddUpdateDelete aud, Model.TableFileInfo tableFileInfo, bool isErr = false, bool clearRows = false) { try { if (this.dv_tableList.InvokeRequired) { object[] wrk = { aud, tableFileInfo, isErr, clearRows }; delDataGridView = new DelegateDataGridView(UpdateDVTableFile); this.dv_tableList.Invoke(this.delDataGridView, wrk); } else { if (clearRows) { this.dv_tableList.Rows.Clear(); } else { switch (aud) { case AddUpdateDelete.Add: if (tableFileInfo.TableName != string.Empty) { this.dv_tableList.Rows.Add(); DataGridViewRow r = this.dv_tableList.Rows[this.dv_tableList.Rows.Count - 1]; r.SetValues(tableFileInfo.CheckValue, tableFileInfo.TableName, tableFileInfo.FilePath, tableFileInfo.FileStatus); tableFileInfo.DataRow = r; } break; case AddUpdateDelete.Update: if (tableFileInfo.TableName != string.Empty) //&& tableFileInfo.DataRow != null) { foreach (DataGridViewRow dgvRow in dv_tableList.Rows) { if (tableFileInfo.TableName == (string)dgvRow.Cells[1].Value) { dgvRow.Cells[3].Value = tableFileInfo.FileStatus; continue; } } //DataGridViewRow r = tableFileInfo.DataRow; ////r.SetValues(tableFileInfo.CheckValue, tableFileInfo.TableName, tableFileInfo.FilePath, tableFileInfo.FileStatus); //r.SetValues(r.Cells[0].Value, // r.Cells[1].Value, // r.Cells[2].Value, // tableFileInfo.FileStatus); //if (isErr) // this.dv_tableList.Rows[this.dv_tableList.Rows.IndexOf(r)].Cells[3].Style.ForeColor = Color.Red; } break; case AddUpdateDelete.Delete: if (tableFileInfo.TableName != string.Empty) { this.dv_tableList.Rows.Remove(tableFileInfo.DataRow); } break; default: break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }