Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtKendaraan.Text == "")
            {
                MessageBox.Show("Kendaraan belum diisi");
                txtKendaraan.Focus();
                return;
            }

            if (txtNomorPolisi.Text == "")
            {
                MessageBox.Show("NomorPolisi belum diisi");
                txtNomorPolisi.Focus();
                return;
            }
            try
            {
                using (Database db = new Database())
                {
                    db.Commands.Add(db.CreateCommand("usp_ArmadaKirim"));
                    db.Commands[0].Parameters.Add(new Parameter("@KodeArmada", SqlDbType.VarChar, txtKodeArmada.Text));
                    db.Commands[0].Parameters.Add(new Parameter("@Kendaraan", SqlDbType.VarChar, txtKendaraan.Text));
                    db.Commands[0].Parameters.Add(new Parameter("@NomorPolisi", SqlDbType.VarChar, txtNomorPolisi.Text));
                    db.Commands[0].Parameters.Add(new Parameter("@TripMeterKM", SqlDbType.Int, txtTripMeterKM.GetIntValue));
                    db.Commands[0].Parameters.Add(new Parameter("@KMPerLiter", SqlDbType.Int, txtKMPerLiter.GetIntValue));
                    db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].Parameters.Add(new Parameter("@Status", SqlDbType.VarChar, "add"));
                    db.Commands[0].ExecuteNonQuery();
                }

                txtKodeArmada.Text = Numerator.BookNumeratorNew("ARK");
                frmArmadaKirim frm = new frmArmadaKirim();
                frm = (frmArmadaKirim)Caller;
                frm.RefreshData();
                this.Close();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }
Example #2
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (!validate())
            {
                return;
            }
            if (updateMode == enumUpdateMode.Header)
            {
                if (frmMode == enumFrmMode.New)
                {
                    try
                    {
                        Guid   _RowID  = Guid.NewGuid();
                        string _BankID = Tools.CreateFingerPrint(GlobalVar.PerusahaanID, SecurityManager.UserInitial);
                        using (Database db = new Database(GlobalVar.DBFinance))
                        {
                            Bank.addBank(db, _RowID, _BankID, tbJenisRek.Text, tbNamaBank.Text, "", tbNoAccount.Text, tbAlamat1.Text, tbAlamat2.Text, tbKota.Text, tbTelepon.Text, tbCusService.Text, tbNoTerakhirBG.Text, tbCheque.Text, "", "IDR", tbSaldo.Text, tbLimitSaldo.Text, (DateTime)SqlDateTime.Null, "", "", "", "", tbNoPerkiraan.Text, tbPerkiraanTP.Text);
                        }
                        frmBukuBankBrowse frm = new frmBukuBankBrowse();
                        frm = (frmBukuBankBrowse)Caller;
                        frm.HeaderRefresh(_RowID);
                        frm.HeaderFindRow("RowIDH", _RowID.ToString());
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Error.LogError(ex);
                    }
                }
                else
                {
                    //SAVE UPDATE HEADER
                    try
                    {
                        using (Database db = new Database(GlobalVar.DBFinance))
                        {
                            db.Commands.Add(db.CreateCommand("usp_Bank_UPDATE"));
                            db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, rowID));
                            db.Commands[0].Parameters.Add(new Parameter("@JRek", SqlDbType.VarChar, tbJenisRek.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@NamaBank", SqlDbType.VarChar, tbNamaBank.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@NoAccount", SqlDbType.VarChar, tbNoAccount.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@Alamat1", SqlDbType.VarChar, tbAlamat1.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@Alamat2", SqlDbType.VarChar, tbAlamat2.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@Kota", SqlDbType.VarChar, tbKota.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@Telp", SqlDbType.VarChar, tbTelepon.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@CService", SqlDbType.VarChar, tbCusService.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@NoGiro", SqlDbType.VarChar, tbNoTerakhirBG.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@NoCheck", SqlDbType.VarChar, tbCheque.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@SaldoAwal", SqlDbType.Money, tbSaldo.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@Limit", SqlDbType.Money, tbLimitSaldo.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@NoPerkiraan", SqlDbType.VarChar, tbNoPerkiraan.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@MainPerkiraan", SqlDbType.VarChar, tbPerkiraanTP.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();
                        }
                        frmBukuBankBrowse frm = new frmBukuBankBrowse();
                        frm = (frmBukuBankBrowse)Caller;
                        frm.HeaderRefresh(rowID);
                        frm.HeaderFindRow("RowIDH", rowID.ToString());
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Error.LogError(ex);
                    }
                }
            }
            else
            {
                if (frmMode == enumFrmMode.New)
                {
                    //SAVE NEW DETAIL
                    DateTime _Tanggal = (DateTime)tbTglBank.DateValue;
                    if (PeriodeClosing.IsKasirClosed(_Tanggal))
                    {
                        MessageBox.Show("Sudah Closing!");
                        return;
                    }
                    rowIDDetail = Guid.NewGuid();
                    string recordID = Tools.CreateFingerPrint(GlobalVar.PerusahaanID, SecurityManager.UserInitial);
                    try
                    {
                        DateTime tglBank = (DateTime)tbTglBank.DateValue;
                        DateTime tglRK   = (DateTime)tbTglRK.DateValue;
                        if (kdTransaksi == "KM1")
                        {
                            nobbk  = Numerator.BookNumeratorNew("BBK");
                            nobgch = Numerator.BookNumerator("BKM");
                            string recordIDBKM       = recordID.TrimEnd() + "B";
                            string recordIDBKMDetail = recordIDBKM;
                            using (Database db = new Database(GlobalVar.DBFinance))
                            {
                                db.BeginTransaction();

                                Bank.AddBankDetail(db, rowIDDetail, Guid.Empty, nobbk, nobgch, rowID, "", tglBank, "BBK", tbKeterangan.Text, "IDR", tbDebet.Text, tbKredit.Text, tglBank, tglRK, "", "", "", "", noPerkiraan, bankID, recordID.TrimEnd() + "T");

                                BKM.AddHeader(db, rowIDDetail, rowIDDetail, recordIDBKM, nobgch, "", "BNK", tglBank, "Mutasi Dari " + namaBank, "", "", SecurityManager.UserName, "");
                                BKM.AddDetail(db, Guid.NewGuid(), rowIDDetail, recordIDBKMDetail, recordIDBKM, "", "", "", "", noPerkiraan, tbKeterangan.Text, tbKredit.Text);
                                db.CommitTransaction();
                            }
                        }
                        else if (kdTransaksi == "KK1")
                        {
                            nobbk  = Numerator.BookNumeratorNew("BBM");
                            nobgch = Numerator.BookNumerator("BKK");


                            string recordIDBKK       = recordID.TrimEnd() + "B";
                            string recordIDBKKDetail = recordIDBKK;
                            using (Database db = new Database(GlobalVar.DBFinance))
                            {
                                db.BeginTransaction();

                                Bank.AddBankDetail(db, rowIDDetail, Guid.Empty, nobbk, nobgch, rowID, "", tglBank, "BBM", tbKeterangan.Text, "IDR", tbDebet.Text, tbKredit.Text, tglBank, tglRK, "", "", "", "", noPerkiraan, bankID, recordID.TrimEnd() + "T");

                                BKK.AddHeader(db, rowIDDetail, rowIDDetail, recordIDBKK, nobgch, "", "BNK", tglBank, "Mutasi Ke " + namaBank, "", "", SecurityManager.UserName, "");
                                BKK.AddDetail(db, Guid.NewGuid(), rowIDDetail, recordIDBKKDetail, recordIDBKK, "", "", "", "", noPerkiraan, tbKeterangan.Text, tbDebet.Text);
                                db.CommitTransaction();
                            }
                        }
                        else if (kdTransaksi == "BM1")
                        {
                            nobbk  = Numerator.BookNumeratorNew("BBK");
                            nobgch = Numerator.BookNumerator("BBM");
                            string noBBKBank2, noBGCHBank2;
                            Guid   LinkRowID = Guid.NewGuid();
                            using (Database db = new Database(GlobalVar.DBFinance))
                            {
                                db.BeginTransaction();

                                Bank.AddBankDetail(db, rowIDDetail, LinkRowID, nobbk, nobgch, rowID, "", tglBank, "BBK", tbKeterangan.Text, "IDR", tbDebet.Text, tbKredit.Text, tglBank, tglRK, "", "", "", "", noPerkiraan, bankID, recordID.TrimEnd() + "T");

                                noBBKBank2  = nobgch;
                                noBGCHBank2 = nobbk;
                                Bank.AddBankDetail(db, LinkRowID, rowIDDetail, noBBKBank2, noBGCHBank2, rowIDBank2, "", tglBank, "BBM", "Mutasi Bank, No : " + noBGCHBank2, "IDR", tbKredit.Text, tbDebet.Text, tglBank, tglRK, "", "", "", "", noPerkiraan, bankID2, recordID.TrimEnd() + "M");
                                db.CommitTransaction();
                            }
                        }
                        else if (kdTransaksi == "BK2")
                        {
                            nobbk  = Numerator.BookNumeratorNew("BBK");
                            nobgch = nobbk;

                            using (Database db = new Database(GlobalVar.DBFinance))
                            {
                                db.BeginTransaction();

                                Bank.AddBankDetail(db, rowIDDetail, Guid.Empty, nobbk, nobgch, rowID, "", tglBank, "BBK", tbKeterangan.Text, "IDR", tbDebet.Text, tbKredit.Text, tglBank, tglRK, "", "", "", "", noPerkiraan, bankID, recordID.TrimEnd() + "T");

                                db.CommitTransaction();
                            }
                        }
                        else if (kdTransaksi == "BM2" || kdTransaksi == "BBM")
                        {
                            nobbk  = Numerator.BookNumeratorNew("BBM");
                            nobgch = nobbk;

                            using (Database db = new Database(GlobalVar.DBFinance))
                            {
                                db.BeginTransaction();

                                Bank.AddBankDetail(db, rowIDDetail, Guid.Empty, nobbk, nobgch, rowID, "", tglBank, "BBM", tbKeterangan.Text, "IDR", tbDebet.Text, tbKredit.Text, tglBank, tglRK, "", "", "", "", noPerkiraan, bankID, recordID.TrimEnd() + "T");

                                db.CommitTransaction();
                            }
                        }



                        frmBukuBankBrowse frm = new frmBukuBankBrowse();
                        frm = (frmBukuBankBrowse)Caller;
                        frm.HeaderRefresh(rowID);
                        frm.HeaderFindRow("RowIDH", rowID.ToString());
                        frm.DetailRefresh(rowIDDetail);
                        frm.DetailFindRow("RowID", rowIDDetail.ToString());
                        this.Close();

                        bool isPrinted = LookupInfoValue.CekPrintBukuBank();
                        if (isPrinted)
                        {
                            frm.cetakLaporan();
                        }
                    }
                    catch (Exception ex)
                    {
                        Error.LogError(ex);
                    }
                }
                else
                {
                    //SAVE UPDATE DETAIL
                    try
                    {
                        tglRK      = (DateTime)tbTglBank.DateValue;
                        keterangan = tbKeterangan.Text;
                        debet      = tbDebet.Text;
                        kredit     = tbKredit.Text;



                        using (Database db = new Database(GlobalVar.DBFinance))
                        {
                            db.Commands.Add(db.CreateCommand("usp_BankDetail_RELASI_UPDATE"));
                            db.Commands[0].Parameters.Add(new Parameter("@jenis", SqlDbType.VarChar, nobgch.Substring(0, 3)));
                            db.Commands[0].Parameters.Add(new Parameter("@RowID2", SqlDbType.UniqueIdentifier, rowID));
                            db.Commands[0].Parameters.Add(new Parameter("@RowIDDetail", SqlDbType.UniqueIdentifier, rowIDDetail));
                            db.Commands[0].Parameters.Add(new Parameter("@NoBKK2", SqlDbType.VarChar, nobbk));
                            db.Commands[0].Parameters.Add(new Parameter("@NoBGCH2", SqlDbType.VarChar, nobgch));
                            db.Commands[0].Parameters.Add(new Parameter("@tglRK2", SqlDbType.DateTime, tglRK));
                            db.Commands[0].Parameters.Add(new Parameter("@keterangan2", SqlDbType.VarChar, keterangan));
                            db.Commands[0].Parameters.Add(new Parameter("@debet2", SqlDbType.Money, debet));
                            db.Commands[0].Parameters.Add(new Parameter("@kredit2", SqlDbType.Money, kredit));
                            db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy2", SqlDbType.VarChar, SecurityManager.UserID));
                            db.BeginTransaction();
                            db.Commands[0].ExecuteNonQuery();
                            db.CommitTransaction();
                        }

                        frmBukuBankBrowse frm = new frmBukuBankBrowse();
                        frm = (frmBukuBankBrowse)Caller;
                        frm.HeaderRefresh(rowID);
                        frm.HeaderFindRow("RowIDH", rowID.ToString());
                        frm.DetailRefresh(rowIDDetail);
                        frm.DetailFindRow("RowID", rowIDDetail.ToString());
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Error.LogError(ex);
                    }
                }
            }
        }
Example #3
0
        private void AddTransaksi()
        {
            _rowIDTransferBank    = Guid.NewGuid();
            _recordIDTransferBank = Tools.CreateFingerPrint(GlobalVar.PerusahaanID, SecurityManager.UserInitial);
            string penyetor  = txtKepada.Text;
            string kasir     = SecurityManager.UserID;
            string noBBK     = string.Empty;
            string MK        = string.Empty;
            string dibukukan = string.Empty;
            string diketahui = string.Empty;
            string namaBank  = lookupBank1.NamaBank;
            string bankID    = lookupBank1.BankID;

            if (_isFromPiutang == true)
            {
                if (_cmbJU == "TRK")
                {
                    noBBK = Numerator.BookNumeratorNew("BBK");
                    MK    = "K";
                    _recordIDTransferBank = _recordIDTransferBank.Trim() + "1";
                }
                else if (_cmbJU == "TRM")
                {
                    noBBK = Numerator.BookNumeratorNew("BBM");
                    MK    = "M";
                    _recordIDTransferBank = _recordIDTransferBank.Trim() + "2";
                }
            }
            else
            {
                noBBK = Numerator.BookNumeratorNew("BBK");
                MK    = "K";
                _recordIDTransferBank = _recordIDTransferBank.Trim() + "4";
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;
                using (Database db = new Database(GlobalVar.DBFinance))
                {
                    Class.TransferBank.addHeader(db,
                                                 _rowIDTransferBank,
                                                 _rowIDTransferBank,
                                                 _recordIDTransferBank,
                                                 DateTime.Now.Date,
                                                 noBBK,
                                                 MK,
                                                 bankID,
                                                 namaBank,
                                                 dibukukan,
                                                 diketahui,
                                                 SecurityManager.UserID,
                                                 penyetor);

                    if (_isFromPiutang == true)
                    {
                        _recordIDTransferBank2 = _recordIDTransferBank.Substring(0, 22) + _jp;
                        Class.TransferBank.AddPinjamanPegawai(
                            db,
                            _rowIDTransferBank,
                            _recordIDTransferBank2,
                            _nip,
                            DateTime.Now.Date,
                            _cmbJU,
                            noBBK,
                            penyetor,
                            string.Empty,
                            0,
                            0,
                            _jp);
                    }
                }

                lblNoBkk.Visible    = true;
                lblNoBkk.Text       = noBBK;
                txtKepada.Enabled   = true;
                lookupBank1.Enabled = false;
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }