public void RefreshBBK(Guid RowID) { DataTable dtRefresh = new DataTable(); using (Database db = new Database(GlobalVar.DBFinance)) { dtRefresh = BBK.ListBBK(db, RowID); } gridBBK.RefreshDataRow(dtRefresh.Rows[0], "RowIDBBK", RowID.ToString()); }
private void cmdDelete_Click(object sender, EventArgs e) { DateTime _Tanggal = (DateTime)gridBBK.SelectedCells[0].OwningRow.Cells["TglBBK"].Value; if (PeriodeClosing.IsKasirClosed(_Tanggal)) { MessageBox.Show("Sudah Closing!"); return; } if (selectedGrid == enumSelectedGrid.DetailSelected) { if (gridGiroIn.SelectedCells.Count > 0) { try { if (MessageBox.Show("Data Ini Akan Dihapus ?", "", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } _rowIDBBK = (Guid)gridBBK.SelectedCells[0].OwningRow.Cells["RowIDBBK"].Value; DeleteGiroInternal(); RefreshBBK(_rowIDBBK); #region "Tambahan" int i = 0; int n = 0; i = gridGiroIn.SelectedCells[0].RowIndex; n = gridGiroIn.SelectedCells[0].ColumnIndex; DataRowView dv = (DataRowView)gridGiroIn.SelectedCells[0].OwningRow.DataBoundItem; DataRow dr = dv.Row; dr.Delete(); _dtGiroIn.AcceptChanges(); gridGiroIn.Focus(); gridGiroIn.RefreshEdit(); if (gridGiroIn.RowCount > 0) { if (i == 0) { gridGiroIn.CurrentCell = gridGiroIn.Rows[0].Cells[n]; gridGiroIn.RefreshEdit(); } else { gridGiroIn.CurrentCell = gridGiroIn.Rows[i - 1].Cells[n]; gridGiroIn.RefreshEdit(); } } #endregion } catch (Exception ex) { Error.LogError(ex); } } } else { if (gridBBK.SelectedCells.Count > 0) { Guid rowIDBBK = (Guid)gridBBK.SelectedCells[0].OwningRow.Cells["RowID"].Value; if ((int)_dtGiroIn.Compute("count(Nomor)", "") > 0) { MessageBox.Show("Masih ada detail"); return; } if (MessageBox.Show("Data Ini Akan Dihapus?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { using (Database db = new Database(GlobalVar.DBFinance)) { BBK.DeleteBBK(db, rowIDBBK); } #region "Tambahan" int i = 0; int n = 0; i = gridBBK.SelectedCells[0].RowIndex; n = gridBBK.SelectedCells[0].ColumnIndex; DataRowView dv = (DataRowView)gridBBK.SelectedCells[0].OwningRow.DataBoundItem; DataRow dr = dv.Row; dr.Delete(); _dtBBK.AcceptChanges(); gridBBK.Focus(); gridBBK.RefreshEdit(); if (gridBBK.RowCount > 0) { if (i == 0) { gridBBK.CurrentCell = gridBBK.Rows[0].Cells[n]; gridBBK.RefreshEdit(); } else { gridBBK.CurrentCell = gridBBK.Rows[i - 1].Cells[n]; gridBBK.RefreshEdit(); } } #endregion } catch (Exception ex) { Error.LogError(ex); } } } } }