Пример #1
0
        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 (_isFromPiutang == false)
                            {
                                BKM.AddDetail(db, _rowIDDetail, _rowID, _recordIDDetail, _recordID, "", "", "", "", "", tbUraian.Text, tbJumlah.Text);
                                frmBKMBrowse frm = new frmBKMBrowse();
                                frm = (frmBKMBrowse)this.Caller;
                                frm.HeaderRowRefresh(_rowID);
                                frm.DetailRowRefresh(_rowIDDetail);
                                frm.FindRowDetail("RowIDD", _rowIDDetail.ToString());
                            }
                            else
                            {
                                BKM.AddDetail(db, _rowIDDetail, _rowID, _recordIDDetail, _recordID, "", "", "", "", "", tbUraian.Text, tbJumlah.Text);
                                BKM.UpdatePinjamanPegawai(db, _rowID, _recordID, _Nip, _Tanggal, "BKM", _noBukti, tbUraian.Text, string.Empty, _jp);

                                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();


                            gbBKMUpdate.Enabled       = true;
                            gbUpdateDetailBKM.Visible = false;
                            dgDetailBKM.Focus();
                        }
                    }
                    else if (detailMode == enumDetailMode.Update)
                    {
                        using (Database db = new Database(GlobalVar.DBFinance))
                        {
                            if (_isFromPiutang == false)
                            {
                                BKM.UpdateBuktiDetail(db, _rowIDDetail, "", tbUraian.Text, tbJumlah.Text);
                                frmBKMBrowse frm = new frmBKMBrowse();
                                frm = (frmBKMBrowse)this.Caller;
                                frm.HeaderRowRefresh(_rowID);
                                frm.DetailRowRefresh(_rowIDDetail);
                                frm.FindRowDetail("RowIDD", _rowIDDetail.ToString());
                            }
                            else
                            {
                                BKM.UpdateBuktiDetail(db, _rowIDDetail, "", tbUraian.Text, tbJumlah.Text);
                                BKM.UpdatePinjamanPegawai(db, _rowID, _recordID, _Nip, _Tanggal, "BKM", _noBukti, tbUraian.Text, string.Empty, _jp);

                                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();

                            gbBKMUpdate.Enabled       = true;
                            gbUpdateDetailBKM.Visible = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
            }
        }
Пример #2
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            if (dgDetailBKM.SelectedCells.Count > 0 && MessageBox.Show("Data akan dihapus?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                _rowIDDetail = (Guid)dgDetailBKM.SelectedCells[0].OwningRow.Cells["rowID"].Value;

                try
                {
                    using (Database db = new Database(GlobalVar.DBFinance))
                    {
                        if (_isFromPiutang == false)
                        {
                            BKM.DeleteBuktiDetail(db, _rowIDDetail);
                            frmBKMBrowse frm = new frmBKMBrowse();
                            frm = (frmBKMBrowse)this.Caller;
                            frm.HeaderRowRefresh(_rowID);
                            frm.FindRowDetail("RowIDD", _rowIDDetail.ToString());
                            frm.DetailDeleteRefresh();
                        }
                        else
                        {
                            BKM.DeleteBuktiDetail(db, _rowIDDetail);
                            BKM.UpdateUraianPinjaman(db, _rowID);
                            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 = dgDetailBKM.SelectedCells[0].RowIndex;
                    n = dgDetailBKM.SelectedCells[0].ColumnIndex;
                    DataRowView dv = (DataRowView)dgDetailBKM.SelectedCells[0].OwningRow.DataBoundItem;

                    DataRow dr = dv.Row;

                    dr.Delete();
                    dtBKMDetail.AcceptChanges();
                    dgDetailBKM.Focus();
                    dgDetailBKM.RefreshEdit();
                    if (dgDetailBKM.RowCount > 0)
                    {
                        if (i == 0)
                        {
                            dgDetailBKM.CurrentCell = dgDetailBKM.Rows[0].Cells[n];
                            dgDetailBKM.RefreshEdit();
                        }
                        else
                        {
                            dgDetailBKM.CurrentCell = dgDetailBKM.Rows[i - 1].Cells[n];
                            dgDetailBKM.RefreshEdit();
                        }
                    }
                    #endregion

                    //DetailRefresh();
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
                finally
                {
                    DetailRefresh();
                    refreshTerbilang();
                }
            }
        }
Пример #3
0
        private void tbTerima_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!");
                    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 = "IN";
                        }
                        else
                        {
                            src = "PIK";
                        }

                        _recordID = BKM.GetRecordIDBukti(_recordID, src);

                        // _noBukti = Numerator.BookNumerator("BKM");
                        _noBukti = Tools.AutoNumbering("NoBukti", "ISADbDepoFinance.dbo.Bukti");
                        _rowID   = Guid.NewGuid();
                        try
                        {
                            using (Database db = new Database(GlobalVar.DBFinance))
                            {
                                BKM.AddHeader(db, _rowID, _rowID, _recordID, _noBukti, "", src, _Tanggal, lookupStafAdm1.Kode, "", "", SecurityManager.UserName, "");

                                if (_isFromPiutang == true)
                                {
                                    BKM.AddPinjamanPegawai(db, _rowID, _recordID, _Nip, _Tanggal, "BKM", _noBukti, "", string.Empty, 0, totalPiutang, _jp);
                                }
                            }

                            tbNoBKM.Text = _noBukti;
                            //_Terima = tbTerima.Text;
                            cmdAdd.Enabled      = true;
                            cmdEdit.Enabled     = true;
                            cmdDelete.Enabled   = true;
                            cmdPrint.Enabled    = true;
                            dgDetailBKM.Enabled = true;

                            if (_isFromPiutang != true)
                            {
                                frmBKMBrowse frm = new frmBKMBrowse();
                                frm = (frmBKMBrowse)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());
                            }

                            dtBKMDetail            = new DataTable();
                            dgDetailBKM.DataSource = dtBKMDetail.DefaultView;
                            dgDetailBKM.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();
                            }
                            frmBKMBrowse frm = new frmBKMBrowse();
                            frm = (frmBKMBrowse)this.Caller;
                            frm.HeaderRowRefresh(_rowID);
                            frm.FindRowHeader("RowID", _rowID.ToString());
                            dgDetailBKM.Focus();
                        }
                        catch (Exception ex)
                        {
                            Error.LogError(ex);
                        }
                    }
                    cmdAdd.PerformClick();
                }
            }
        }