private void cmdSave_Click(object sender, EventArgs e) { totalPiutang = tbJumlah.GetDoubleValue + tbTotal.GetDoubleValue; if ((tbUraian.Text != "") && (tbJumlah.Text != "")) { try { if (detailMode == enumDetailMode.New) { _recordIDDetail = Tools.CreateFingerPrint(GlobalVar.PerusahaanID, SecurityManager.UserInitial); _rowIDDetail = Guid.NewGuid(); using (Database db = new Database(GlobalVar.DBFinance)) { if (linkPembelian) { BKK.AddDetail(db, _rowIDDetail, _rowID, _recordIDDetail, _recordID, "", "", "", tbAcc.Text, "".Trim().Equals("") ? "?" : "", tbUraian.Text, tbJumlah.Text); } else if (_isFromPiutang == false) { BKK.AddDetail(db, _rowIDDetail, _rowID, _recordIDDetail, _recordID, "", "", "", tbAcc.Text, "".Trim().Equals("")? "?":"", tbUraian.Text, tbJumlah.Text); frmBKKBrowse frm = new frmBKKBrowse(); frm = (frmBKKBrowse)this.Caller; frm.HeaderRowRefresh(_rowID); frm.DetailRowRefresh(_rowIDDetail); frm.FindRowDetail("RowIDD", _rowIDDetail.ToString()); } else { db.BeginTransaction(); BKK.AddDetail(db, _rowIDDetail, _rowID, _recordIDDetail, _recordID, "", "", "", tbAcc.Text, "", tbUraian.Text, tbJumlah.Text); BKK.UpdatePinjamanPegawai(db, _rowID, _recordID, _Nip, _Tanggal, "BKK", _noBukti, tbUraian.Text, string.Empty, _jp); db.CommitTransaction(); Kasir.frmPiutangKaryawan frmUtang = new Kasir.frmPiutangKaryawan(); frmUtang = (frmPiutangKaryawan)this.Caller; frmUtang.RefreshPegawai(_Nip); frmUtang.FindRowPegawsai("NIP", _Nip); //frmUtang.RefreshPiutang(_rowID); frmUtang.RefreshPiutang(); frmUtang.FindRowPiutang("RowID", _rowID.ToString()); } tbUraian.Text = ""; tbJumlah.Text = "0"; tbAcc.Text = ""; DetailRowRefresh(_rowIDDetail); FindRowDetail("rowID", _rowIDDetail.ToString()); refreshTerbilang(); gbBKKUpdate.Enabled = true; gbUpdateDetailBKK.Visible = false; dgDetailBKK.Focus(); } } else if (detailMode == enumDetailMode.Update) { using (Database db = new Database(GlobalVar.DBFinance)) { if (linkPembelian) { BKK.UpdateBuktiDetail(db, _rowIDDetail, "", tbUraian.Text, tbJumlah.Text); } else if (_isFromPiutang == false) { BKK.UpdateBuktiDetail(db, _rowIDDetail, "", tbUraian.Text, tbJumlah.Text); frmBKKBrowse frm = new frmBKKBrowse(); frm = (frmBKKBrowse)this.Caller; frm.HeaderRowRefresh(_rowID); frm.DetailRowRefresh(_rowIDDetail); } else { db.BeginTransaction(); BKK.UpdateBuktiDetail(db, _rowIDDetail, "", tbUraian.Text, tbJumlah.Text); BKK.UpdatePinjamanPegawai(db, _rowID, _recordID, _Nip, _Tanggal, "BKK", _noBukti, tbUraian.Text, string.Empty, _jp); db.CommitTransaction(); Kasir.frmPiutangKaryawan frmUtang = new Kasir.frmPiutangKaryawan(); frmUtang = (frmPiutangKaryawan)this.Caller; frmUtang.RefreshPegawai(_Nip); frmUtang.FindRowPegawsai("NIP", _Nip); frmUtang.RefreshPiutang(_rowID); frmUtang.FindRowPiutang("RowID", _rowID.ToString()); } tbUraian.Text = ""; //"" = "?"; tbJumlah.Text = "0"; DetailRowRefresh(_rowIDDetail); refreshTerbilang(); gbBKKUpdate.Enabled = true; gbUpdateDetailBKK.Visible = false; } } } catch (Exception ex) { Error.LogError(ex); } } }
private void cmdDelete_Click(object sender, EventArgs e) { if (dgDetailBKK.SelectedCells.Count > 0 && MessageBox.Show("Data akan dihapus?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { _rowIDDetail = (Guid)dgDetailBKK.SelectedCells[0].OwningRow.Cells["rowID"].Value; try { using (Database db = new Database(GlobalVar.DBFinance)) { if (linkPembelian) { BKK.DeleteBuktiDetail(db, _rowIDDetail); } else if (_isFromPiutang == false) { BKK.DeleteBuktiDetail(db, _rowIDDetail); frmBKKBrowse frm = new frmBKKBrowse(); frm = (frmBKKBrowse)this.Caller; frm.HeaderRowRefresh(_rowID); frm.FindRowDetail("RowIDD", _rowIDDetail.ToString()); frm.DetailDeleteRefresh(); } else { db.BeginTransaction(); BKK.DeleteBuktiDetail(db, _rowIDDetail); BKK.UpdateUraianPinjaman(db, _rowID); db.CommitTransaction(); Kasir.frmPiutangKaryawan frmUtang = new Kasir.frmPiutangKaryawan(); frmUtang = (frmPiutangKaryawan)this.Caller; frmUtang.RefreshPegawai(_Nip); frmUtang.FindRowPegawsai("NIP", _Nip); frmUtang.RefreshPiutang(_rowID); frmUtang.FindRowPiutang("RowID", _rowID.ToString()); } } #region "Tambahan" int i = 0; int n = 0; i = dgDetailBKK.SelectedCells[0].RowIndex; n = dgDetailBKK.SelectedCells[0].ColumnIndex; DataRowView dv = (DataRowView)dgDetailBKK.SelectedCells[0].OwningRow.DataBoundItem; DataRow dr = dv.Row; dr.Delete(); dtBKKDetail.AcceptChanges(); dgDetailBKK.Focus(); dgDetailBKK.RefreshEdit(); if (dgDetailBKK.RowCount > 0) { if (i == 0) { dgDetailBKK.CurrentCell = dgDetailBKK.Rows[0].Cells[n]; dgDetailBKK.RefreshEdit(); } else { dgDetailBKK.CurrentCell = dgDetailBKK.Rows[i - 1].Cells[n]; dgDetailBKK.RefreshEdit(); } } #endregion //Korban editan // DetailRefresh(); } catch (Exception ex) { Error.LogError(ex); } finally { refreshTerbilang(); } } }
private void tbKepada_Leave(object sender, EventArgs e) { string src = ""; if (lookupStafAdm1.Kode != "" & lookupStafAdm1.Kode != "[CODE]") { _Tanggal = (DateTime)tbTanggal.DateValue; if (PeriodeClosing.IsKasirClosed(_Tanggal)) { MessageBox.Show("Sudah Closing! Tidak Bisa Tambah Data."); return; } if (MessageBox.Show("Data Akan Disimpan?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (formMode == enumFormMode.New) { _recordID = Tools.CreateFingerPrint(GlobalVar.PerusahaanID, SecurityManager.UserInitial); if (_isFromPiutang != true) { src = "OUT"; } else { src = "PIK"; } _recordID = BKK.GetRecordIDBukti(_recordID, src); _rowID = Guid.NewGuid(); //_noBukti = Tools.AutoNumbering("NoBukti", "ISADbDepoFinance.dbo.Bukti"); _noBukti = Numerator.BookNumerator("BKK"); try { using (Database db = new Database(GlobalVar.DBFinance)) { db.BeginTransaction(); BKK.AddHeader(db, _rowID, _rowID, _recordID, _noBukti, "", src, _Tanggal, lookupStafAdm1.Kode, "", "", SecurityManager.UserName, ""); if (_isFromPiutang == true) { BKK.AddPinjamanPegawai(db, _rowID, _recordID, _Nip, _Tanggal, "BKK", _noBukti, "", string.Empty, totalPiutang, 0, _jp); } db.CommitTransaction(); } tbNoBKK.Text = _noBukti; _Kepada = lookupStafAdm1.Kode; cmdAdd.Enabled = true; cmdEdit.Enabled = true; cmdDelete.Enabled = true; cmdPrint.Enabled = true; dgDetailBKK.Enabled = true; if (linkPembelian) { //cmdAdd.Enabled = false; } else if (_isFromPiutang != true) { frmBKKBrowse frm = new frmBKKBrowse(); frm = (frmBKKBrowse)this.Caller; frm.HeaderRowRefresh(_rowID); frm.FindRowHeader("RowID", _rowID.ToString()); } else { Kasir.frmPiutangKaryawan frmUtang = new Kasir.frmPiutangKaryawan(); frmUtang = (frmPiutangKaryawan)this.Caller; frmUtang.RefreshPegawai(_Nip); frmUtang.FindRowPegawsai("NIP", _Nip); frmUtang.RefreshPiutang(_rowID); frmUtang.FindRowPiutang("RowID", _rowID.ToString()); } dtBKKDetail = new DataTable(); dgDetailBKK.DataSource = dtBKKDetail.DefaultView; dgDetailBKK.Focus(); } catch (Exception ex) { Error.LogError(ex); } } else if (formMode == enumFormMode.Update) { try { using (Database db = new Database(GlobalVar.DBFinance)) { db.Commands.Add(db.CreateCommand("usp_Bukti_UPDATE")); db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowID)); db.Commands[0].Parameters.Add(new Parameter("@Kepada", SqlDbType.VarChar, lookupStafAdm1.Kode)); db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID)); db.Commands[0].ExecuteNonQuery(); } frmBKKBrowse frm = new frmBKKBrowse(); frm = (frmBKKBrowse)this.Caller; frm.HeaderRowRefresh(_rowID); dgDetailBKK.Focus(); } catch (Exception ex) { Error.LogError(ex); } } cmdAdd.PerformClick(); } } }