public void RefreshRowDataGridDetail(Guid RowID_) { DataTable dt = new DataTable(); DataTable dtRefresh; using (Database db = new Database()) { db.Commands.Add(db.CreateCommand("usp_CF_RencanaPembayaranHutangDetail_List")); db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID_)); dtRefresh = db.Commands[0].ExecuteDataTable(); } if (dtRefresh.Rows.Count > 0) { GVRencana.RefreshDataRow(dtRefresh.Rows[0], "RowID", RowID_.ToString()); GVRencana.FindRow("RowID3", RowID_.ToString()); dtD.AcceptChanges(); DataRowView dv = (DataRowView)GVPL.SelectedCells[0].OwningRow.DataBoundItem; DataRow 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(); } }
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); } } }