private void Delete(Guid ROwID_) { string NoBukti_ = Convert.ToDateTime(GVRencana.SelectedCells[0].OwningRow.Cells["TanggalRencana"].Value).ToString("dd-MM-yyyy"); if (MessageBox.Show("Hapus Rencana Tanggal " + NoBukti_ + " ?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { using (Database db = new Database()) { db.Commands.Add(db.CreateCommand("[usp_CF_RencanaGlobal_Detail_DELETE]")); db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, ROwID_)); db.Commands[0].ExecuteNonQuery(); } int i = 0; int n = 0; i = GVRencana.SelectedCells[0].RowIndex; n = GVRencana.SelectedCells[0].ColumnIndex; DataRowView dv = (DataRowView)GVRencana.SelectedCells[0].OwningRow.DataBoundItem; DataRow dr = dv.Row; dr.Delete(); dtH.AcceptChanges(); GVRencana.Focus(); if (GVRencana.RowCount > 0) { if (i == 0) { GVRencana.CurrentCell = GVRencana.Rows[0].Cells[n]; GVRencana.RefreshEdit(); } else { GVRencana.CurrentCell = GVRencana.Rows[i - 1].Cells[n]; GVRencana.RefreshEdit(); } } else { } } catch (Exception ex) { Error.LogError(ex); } } }
private void Delete(Guid ROwID_) { string NoBukti = GVRencana.SelectedCells[0].OwningRow.Cells["TanggalRencana"].Value.ToString(); if (MessageBox.Show("Hapus Rencana Tanggal " + NoBukti + " ?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { using (Database db = new Database()) { db.Commands.Add(db.CreateCommand("[usp_CF_RencanaPembayaranHutangDetail_DELETE]")); db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, ROwID_)); db.Commands[0].ExecuteNonQuery(); } int i = 0; int n = 0; i = GVRencana.SelectedCells[0].RowIndex; n = GVRencana.SelectedCells[0].ColumnIndex; DataRowView dv = (DataRowView)GVRencana.SelectedCells[0].OwningRow.DataBoundItem; DataRow dr = dv.Row; dr.Delete(); dtD.AcceptChanges(); GVRencana.Focus(); if (GVRencana.RowCount > 0) { if (i == 0) { GVRencana.CurrentCell = GVRencana.Rows[0].Cells[n]; GVRencana.RefreshEdit(); } else { GVRencana.CurrentCell = GVRencana.Rows[i - 1].Cells[n]; GVRencana.RefreshEdit(); } dv = (DataRowView)GVPL.SelectedCells[0].OwningRow.DataBoundItem; dr = dv.Row; dr.BeginEdit(); dr["SaldoUSD"] = Convert.ToDouble(dr["NominalUSD"]) - Convert.ToDouble(dtD.Compute("SUM(USDNominal)", "")); dr["SaldoIDR"] = Convert.ToDouble(dr["NominalIDR"]) - Convert.ToDouble(dtD.Compute("SUM(IDRNominal)", "")); GVPL.SelectedCells[0].OwningRow.Cells["SaldoUSD"].Value = dr["SaldoUSD"]; GVPL.SelectedCells[0].OwningRow.Cells["SaldoIDR"].Value = dr["SaldoIDR"]; dr.EndEdit(); dr.AcceptChanges(); dtH.AcceptChanges(); GVPL.RefreshEdit(); } else { dv = (DataRowView)GVPL.SelectedCells[0].OwningRow.DataBoundItem; dr = dv.Row; dr.BeginEdit(); dr["SaldoUSD"] = Convert.ToDouble(dr["NominalUSD"]); dr["SaldoIDR"] = Convert.ToDouble(dr["NominalIDR"]); GVPL.SelectedCells[0].OwningRow.Cells["SaldoUSD"].Value = dr["SaldoUSD"]; GVPL.SelectedCells[0].OwningRow.Cells["SaldoIDR"].Value = dr["SaldoIDR"]; dr.EndEdit(); dr.AcceptChanges(); dtH.AcceptChanges(); GVPL.RefreshEdit(); } } catch (Exception ex) { Error.LogError(ex); } } }