コード例 #1
0
        private void RefreshData()
        {
            DataTable dt = new DataTable();

            //using (Database db = new Database())
            //{
            //    db.Commands.Add(db.CreateCommand("usp_PenerimaanLeasingNonPenjualanBrowse"));
            //    db.Commands[0].Parameters.Add(new Parameter())
            //}
            dt.Columns.Add("NoBukti", typeof(String));
            dt.Columns.Add("TglIden", typeof(DateTime));
            dt.Columns.Add("JenisTransaksiRowID", typeof(Guid));
            dt.Columns.Add("JenisTransaksi", typeof(String));
            dt.Columns.Add("MataUangRowID", typeof(Guid));
            dt.Columns.Add("MataUang", typeof(String));
            dt.Columns.Add("NominalIden", typeof(Double));
            dt.Columns.Add("Uraian", typeof(String));

            String NoBukti = Numerator.GetNomorDokumen("LEASING_IDENNONPENJUALAN", "", "/LBK/" +
                                                       string.Format("{0:yyMM}", GlobalVar.GetServerDate.Date)
                                                       , 3, false, true);

            dt.Rows.Add(NoBukti, Convert.ToDateTime(GlobalVar.GetServerDate.Date.ToString()), "9657911C-8BD5-4F8B-87A6-0F8391B85502", "Penerimaan dari leasing",
                        "BC17A644-5DBD-4955-A803-378F8C0A915C", "IDR", 0, "Penerimaan Leasing Iden : " + txt_NoPembayaran.Text);

            GV_NonPNJ.DataSource = dt;
        }
コード例 #2
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (validateSave())
            {
                Database db  = new Database();
                Database dbf = new Database(GlobalVar.DBFinanceOto);

                Guid   pengeluaranUangRowID = Guid.NewGuid();
                String bentukPengeluaran    = "";

                switch (cbxBentukPembayaran.SelectedIndex)
                {
                case 0: bentukPengeluaran = "K";
                    break;

                case 1: bentukPengeluaran = "B";
                    break;
                }

                int counterdb  = 0;
                int counterdbf = 0;
                try
                {
                    penerimaanTitipanIdenInsert(ref db, ref counterdb, pengeluaranUangRowID);

                    Database dbfNumerator       = new Database(GlobalVar.DBFinanceOto);
                    String   NoTransPengeluaran = Numerator.GetNomorDokumen(dbfNumerator, "PENGAJUAN_PENGELUARAN_UANG", GlobalVar.PerusahaanID, "/B" + bentukPengeluaran + "K/" +
                                                                            string.Format("{0:yyMM}", GlobalVar.GetServerDate), 4, false, true); // pake ambil numeratornya finance dan coba pake koding yg punya pengeluaranuang insert???

                    pengeluaranUangInsert(ref dbf, ref counterdbf, pengeluaranUangRowID, bentukPengeluaran, NoTransPengeluaran);

                    db.BeginTransaction();
                    dbf.BeginTransaction();
                    int looper = 0;
                    for (looper = 0; looper < counterdb; looper++)
                    {
                        db.Commands[looper].ExecuteNonQuery();
                    }
                    for (looper = 0; looper < counterdbf; looper++)
                    {
                        dbf.Commands[looper].ExecuteNonQuery();
                    }
                    db.CommitTransaction();
                    dbf.CommitTransaction();
                    MessageBox.Show("Data berhasil diproses");
                    this.Close();
                }
                catch (Exception ex)
                {
                    db.RollbackTransaction();
                    dbf.RollbackTransaction();
                    MessageBox.Show("Data gagal diupdate !\n" + ex.Message);
                }
            }
            else
            {
                return;
            }
        }
コード例 #3
0
 private void cmdCLOSE_Click(object sender, EventArgs e)
 {
     dt = new DataTable();
     using (Database db = new Database())
     {
         if (nSisa > 0)
         {
             string cNoBKM = Numerator.GetNomorDokumen("PENERIMAAN_UANG", "",
                                                       "/BKM/" + string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                       , 3, false, true);
             db.Commands.Add(db.CreateCommand("usp_KasbonPenyelesaian_INSERT"));
             db.Commands[0].Parameters.Add(new Parameter("@No_bukti", SqlDbType.Char, cNoBKM));
             db.Commands[0].Parameters.Add(new Parameter("@Debet", SqlDbType.Float, float.Parse(nSisa.ToString())));
             db.Commands[0].Parameters.Add(new Parameter("@Kredit", SqlDbType.Float, float.Parse(0.ToString())));
             db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, "Sisa BS: " + txtNamaPegawai.Text));
         }
         else if (nSisa < 0)
         {
             nSisa = Math.Abs(nSisa);
             string cNoBKK = Numerator.GetNomorDokumen("PENGAJUAN_PENGELUARAN_UANG", "",
                                                       "/BKK/" + string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                       , 3, false, true);
             db.Commands.Add(db.CreateCommand("usp_KasbonPenyelesaian_INSERT"));
             db.Commands[0].Parameters.Add(new Parameter("@No_bukti", SqlDbType.Char, cNoBKK));
             db.Commands[0].Parameters.Add(new Parameter("@Debet", SqlDbType.Float, float.Parse(0.ToString())));
             db.Commands[0].Parameters.Add(new Parameter("@Kredit", SqlDbType.Float, float.Parse(nSisa.ToString())));
             db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, "Kekurangan BS: " + txtNamaPegawai.Text));
         }
         if (nSisa == 0)
         {
         }
         else
         {
             db.Commands[0].Parameters.Add(new Parameter("@KasbonRowId", SqlDbType.UniqueIdentifier, _headRowId));
             db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, _TglNow));
             db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
             dt = db.Commands[0].ExecuteDataTable();
         }
     }
     closeForm();
     this.Close();
 }
コード例 #4
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            bool valid = true;

            if (txtUraian.Text == "")
            {
                Error.ErrorMessage(txtUraian, "isi !!!");
                valid = false;
            }
            if (txtNominal.Text == "")
            {
                Error.ErrorMessage(txtNominal, "isi !!!");
                valid = false;
            }

            if (txtUraian.Text != "" && txtNominal.Text != "" && valid)
            {
                switch (FormMode)
                {
                case enumFormMode.New:
                {
                    string cNo_vju = Numerator.GetNomorDokumen("VOUCHER_JOURNAL", "",
                                                               "/VJU/" + string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                               , 3, false, true);
                    dt = new DataTable();
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_KasbonVJU_INSERT"));
                        db.Commands[0].Parameters.Add(new Parameter("@KasbonRowId", SqlDbType.UniqueIdentifier, _headRowId));
                        db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, txtTanggal.DateValue));
                        db.Commands[0].Parameters.Add(new Parameter("@No_bukti", SqlDbType.Char, cNo_vju));
                        db.Commands[0].Parameters.Add(new Parameter("@JnsKasBonRowID", SqlDbType.UniqueIdentifier, cboJnsKasBon.SelectedValue));
                        db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, txtUraian.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Kredit", SqlDbType.Float, float.Parse(txtNominal.Text.ToString())));
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        dt = db.Commands[0].ExecuteDataTable();
                    }
                    LoadForm();
                    dataGridViewVju.FindRow("No_vju", cNo_vju.PadRight(20));
                    ClearTextBox();
                    txtTanggal.Focus();
                    break;
                }

                case enumFormMode.Update:
                {
                    dt = new DataTable();
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_KasbonVJU_UPDATE"));
                        db.Commands[0].Parameters.Add(new Parameter("@RowId", SqlDbType.UniqueIdentifier, _rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, txtTanggal.DateValue));
                        db.Commands[0].Parameters.Add(new Parameter("@JnsKasBonRowID", SqlDbType.UniqueIdentifier, cboJnsKasBon.SelectedValue));
                        db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, txtUraian.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Kredit", SqlDbType.Float, float.Parse(txtNominal.Text.ToString())));
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        dt = db.Commands[0].ExecuteDataTable();
                    }
                    closeForm();
                    this.Close();
                    break;
                }
                }
            }
        }
コード例 #5
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            if ((formMode != enumFormMode.New) && (string.IsNullOrEmpty(txtVendorID.Text)))
            {
                MessageBox.Show("Kode belum diisi");
                txtVendorID.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtNamaVendor.Text))
            {
                MessageBox.Show("Cabang belum diisi");
                txtNamaVendor.Focus();
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;
                switch (formMode)
                {
                case enumFormMode.New:
                    using (Database db = new Database())
                    {
                        if (string.IsNullOrEmpty(txtVendorID.Text.ToString()))
                        {
                            txtVendorID.Text = Numerator.GetNomorDokumen("KODE_VENDOR", "V", "", 3, true, false);
                        }
                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("usp_Vendor_INSERT"));

                        db.Commands[0].Parameters.Add(new Parameter("@VendorID", SqlDbType.VarChar, txtVendorID.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@NamaVendor", SqlDbType.VarChar, txtNamaVendor.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@TipeVendor", SqlDbType.VarChar, cboTipeVendor.SelectedIndex));
                        db.Commands[0].Parameters.Add(new Parameter("@IsAktif", SqlDbType.Bit, chkIsAktif.Checked));
                        db.Commands[0].Parameters.Add(new Parameter("@Alamat", SqlDbType.VarChar, txtAlamat.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Negara", SqlDbType.VarChar, cboNegara.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@NoTelp", SqlDbType.VarChar, txtNoTelp.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@ContactPerson", SqlDbType.VarChar, txtContactPerson.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        dt = db.Commands[0].ExecuteDataTable();

                        if (dt.Rows.Count > 0)
                        {
                            MessageBox.Show("Vendor ID: " + txtVendorID.Text + " Sudah terdaftar di database");
                            txtVendorID.Text = string.Empty;
                            txtVendorID.Focus();
                            return;
                        }
                    }
                    break;

                case enumFormMode.Update:
                    using (Database db = new Database())
                    {
                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("usp_Vendor_UPDATE"));
                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, _rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@VendorID", SqlDbType.VarChar, txtVendorID.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@NamaVendor", SqlDbType.VarChar, txtNamaVendor.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@TipeVendor", SqlDbType.VarChar, cboTipeVendor.SelectedIndex));
                        db.Commands[0].Parameters.Add(new Parameter("@IsAktif", SqlDbType.Bit, chkIsAktif.Checked));
                        db.Commands[0].Parameters.Add(new Parameter("@Alamat", SqlDbType.VarChar, txtAlamat.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Negara", SqlDbType.VarChar, cboNegara.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@NoTelp", SqlDbType.VarChar, txtNoTelp.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@ContactPerson", SqlDbType.VarChar, txtContactPerson.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();
                    }
                    break;
                }
                this.DialogResult = DialogResult.OK;
                closeForm();
                this.Close();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #6
0
        private void ProsesPembalik(DataRow row, int detail, String _HRecordId, Guid HrowID)
        {
            switch (detail)
            {
            case 0:
                using (Database db = new Database())
                {
                    db.Commands.Clear();
                    db.Commands.Add(db.CreateCommand("[ISAFinanceOtoDbTLA].[dbo].[usp_Journal_INSERT]"));
                    db.Commands[0].Parameters.Add(new Parameter("@PerusahaanRowID", SqlDbType.UniqueIdentifier, new Guid(row["PerusahaanRowID"].ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, HrowID));
                    db.Commands[0].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, _HRecordId));
                    db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, GlobalVar.DateOfServer));
                    db.Commands[0].Parameters.Add(new Parameter("@NoReff", SqlDbType.VarChar, row["ref"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, "Batal - " + row["Uraian"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@Src", SqlDbType.VarChar, row["Src"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@KodeGudang", SqlDbType.VarChar, row["KodeGudang"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@SyncFlag", SqlDbType.Bit, row["SyncFlag"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].ExecuteNonQuery();
                }
                break;

            case 1:
                using (Database db = new Database())
                {
                    db.Commands.Clear();
                    db.Commands.Add(db.CreateCommand("[ISAFinanceOtoDbTLA].[dbo].[usp_JournalDetail_INSERT]")); db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, Guid.NewGuid()));
                    db.Commands[0].Parameters.Add(new Parameter("@HeaderID", SqlDbType.UniqueIdentifier, HrowID));
                    db.Commands[0].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, Tools.CreateFingerPrint()));
                    db.Commands[0].Parameters.Add(new Parameter("@HRecordID", SqlDbType.VarChar, _HRecordId));
                    db.Commands[0].Parameters.Add(new Parameter("@NoPerkiraan", SqlDbType.VarChar, row["NoPerkiraan"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, "Batal - " + row["Uraian"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@Debet", SqlDbType.Money, row["Kredit"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@Kredit", SqlDbType.Money, row["Debet"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@DK", SqlDbType.VarChar, row["DK"].ToString() == "K" ? "D" : "K"));
                    db.Commands[0].Parameters.Add(new Parameter("@NoReff", SqlDbType.VarChar, row["NoReff"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@MataUangRowID", SqlDbType.UniqueIdentifier, new Guid(row["MataUangRowID"].ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@NominalOri", SqlDbType.Money, Convert.ToDouble(row["NominalOri"].ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].ExecuteNonQuery();
                }
                break;

            case 2:
                using (Database db = new Database())
                {
                    Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                    String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                           "/B" + "B" + "M/" +
                                                                           string.Format("{0:yyMM}", GlobalVar.DateOfServer)
                                                                           , 4, false, true);
                    HrowID3 = Guid.NewGuid();
                    db.Commands.Clear();
                    db.Commands.Add(db.CreateCommand("[ISAFinanceOtoDbTLA].[dbo].[usp_PenerimaanUang_INSERT]"));
                    db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, HrowID3));
                    db.Commands[0].Parameters.Add(new Parameter("@NoBukti", SqlDbType.VarChar, NoTransPenerimaan));
                    db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, GlobalVar.DateOfServer));
                    db.Commands[0].Parameters.Add(new Parameter("@TanggalRk", SqlDbType.Date, Convert.ToDateTime(row["TanggalRk"].ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@NoApproval", SqlDbType.VarChar, row["NoApproval"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@PenerimaanDari", SqlDbType.TinyInt, 0));
                    db.Commands[0].Parameters.Add(new Parameter("@PerusahaanKeRowID", SqlDbType.UniqueIdentifier, row["PerusahaanDariRowID"].ToString() != "" ? new Guid(row["PerusahaanDariRowID"].ToString()) : Guid.Empty));
                    db.Commands[0].Parameters.Add(new Parameter("@PerusahaanDariRowID", SqlDbType.UniqueIdentifier, row["PerusahaanKeRowID"].ToString() != "" ? new Guid(row["PerusahaanKeRowID"].ToString()) : Guid.Empty));
                    db.Commands[0].Parameters.Add(new Parameter("@CabangDari", SqlDbType.VarChar, row["CabangKeID"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@CabangKe", SqlDbType.VarChar, row["CabangDariID"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@MataUangRowID", SqlDbType.UniqueIdentifier, new Guid(row["MataUangRowID"].ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@JnsTransaksiRowID", SqlDbType.UniqueIdentifier, new Guid(row["JnsTransaksiRowID"].ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@Nominal", SqlDbType.Money, Convert.ToDouble(row["Nominal"].ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@NominalRp", SqlDbType.Money, Convert.ToDouble(row["NominalRp"].ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, " Batal - " + row["Uraian"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@JnsPenerimaan", SqlDbType.VarChar, row["JnsPenerimaan"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@KasRowID", SqlDbType.UniqueIdentifier, row["KasRowID"].ToString() != "" ?  new Guid(row["KasRowID"].ToString()) : Guid.Empty));
                    db.Commands[0].Parameters.Add(new Parameter("@BankRowID", SqlDbType.UniqueIdentifier, row["RekeningRowID"].ToString() != "" ? new Guid(row["RekeningRowID"].ToString()) : Guid.Empty));
                    db.Commands[0].Parameters.Add(new Parameter("@RekeningRowID", SqlDbType.UniqueIdentifier, row["RekeningRowID"].ToString() != "" ? new Guid(row["RekeningRowID"].ToString()) : Guid.Empty));
                    db.Commands[0].Parameters.Add(new Parameter("@NoCekGiro", SqlDbType.VarChar, row["NoCekGiro"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@KotaGiro", SqlDbType.VarChar, ""));    //row["KotaGiro"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@TanggalGiroCair", SqlDbType.VarChar, row["DueDateGiro"].ToString()));
                    db.Commands[0].Parameters.Add(new Parameter("@JournalRowID", SqlDbType.UniqueIdentifier, HrowID2));
                    db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].ExecuteNonQuery();
                }
                break;
            }
        }
コード例 #7
0
        private void Simpan(Class.enumStatusGiro _GiroStatusNew, string _ketStatus, bool lRekening)
        {
            bool lOk = true;

            DateTime dTgl = GlobalVar.GetServerDate;

            //Guid _rekeningRowID = Guid.Empty;
            switch (_GiroStatusNew)
            {
            case Class.enumStatusGiro.Disetor:
                lOk = ((_GiroStatusLast == Class.enumStatusGiro.Diterima) || (_GiroStatusLast == Class.enumStatusGiro.BatalSetor));
                break;

            case Class.enumStatusGiro.BatalSetor:
                lOk = (_GiroStatusLast == Class.enumStatusGiro.Disetor);
                break;

            case Class.enumStatusGiro.Cair:
                if (_GiroStatusLast != Class.enumStatusGiro.Cair)
                {
                    lOk = true;
                }
                else
                {
                    lOk = ((_GiroStatusLast == Class.enumStatusGiro.Disetor) || (_GiroStatusLast == Class.enumStatusGiro.Cair));
                }

                break;

            case Class.enumStatusGiro.BatalCair:
                lOk = (_GiroStatusLast == Class.enumStatusGiro.Cair);
                break;

            case Class.enumStatusGiro.Ditolak:
                break;

            case Class.enumStatusGiro.Batal:
                break;

            default: lOk = false; break;
            }
            if (lOk)
            {
                dlgProsesGiroStatus dlg = new dlgProsesGiroStatus(_ketStatus, lRekening, MataUangID, _rekeningRowID, _TglJTGiro);
                dlg.ShowDialog();
                lOk = (dlg.DialogResult == DialogResult.Yes);

                if (lOk)
                {
                    dTgl = (DateTime)dlg.dtTanggal.DateValue;

                    if (((DateTime)Tools.isNull(dTgl, DateTime.MinValue) == DateTime.MinValue) || (dTgl < _GiroStatusTanggal))
                    {
                        lOk = false;
                    }

                    if (_ketStatus == "Batal Cair" || _ketStatus == "BatalSetor" || _ketStatus == "Cair" || _ketStatus == "Ditolak")
                    {
                        DataTable dt = new DataTable();
                        using (Database db = new Database())
                        {
                            db.Commands.Add(db.CreateCommand("usp_GetLastRekeningRowIDGiroHistory"));
                            db.Commands[0].Parameters.Add(new Parameter("@NoGiro", SqlDbType.VarChar, lblNoGiro.Text));
                            dt = db.Commands[0].ExecuteDataTable();

                            if (lRekening)
                            {
                                _rekeningRowID = (Guid)dt.Rows[0]["RekeningRowID"];
                            }
                        }
                    }
                    else
                    {
                        if (lRekening)
                        {
                            _rekeningRowID = (Guid)dlg.lookUpRekening1.RekeningRowID;
                        }
                    }
                }
            }

            if (lOk == true)
            {
                try
                {
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_GiroHistory_INSERT"));
                        db.Commands[0].Parameters.Add(new Parameter("@RefID", SqlDbType.UniqueIdentifier, _rowID));

                        // sebelum akhirnya ubah sp
                        //db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, Guid.NewGuid()));

                        if (_GiroStatusNew == Class.enumStatusGiro.Cair)
                        {
                            String   tempBentukPenerimaan = "B";
                            Database dbfNumerator         = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaan    = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                      "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                      string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                      , 4, false, true);

                            // buatin parameter, kirimin numeratornya
                            db.Commands[0].Parameters.Add(new Parameter("@NoBukti", SqlDbType.VarChar, NoTransPenerimaan));
                        }
                        db.Commands[0].Parameters.Add(new Parameter("@JnsGiro", SqlDbType.TinyInt, 1));
                        db.Commands[0].Parameters.Add(new Parameter("@NoGiro", SqlDbType.VarChar, lblNoGiro.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, dTgl));
                        db.Commands[0].Parameters.Add(new Parameter("@StatusGiro", SqlDbType.TinyInt, _GiroStatusNew));
                        if (lRekening)
                        {
                            db.Commands[0].Parameters.Add(new Parameter("@RekeningRowID", SqlDbType.UniqueIdentifier, _rekeningRowID));
                        }
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();

                        RefreshData();
                    }
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
            }
        }
コード例 #8
0
        private void prosesSave()
        {
            Database db = new Database(GlobalVar.DBShowroom);
            Database dbf = new Database(GlobalVar.DBFinanceOto);
            int      counterdb = 0, counterdbf = 0;
            String   bentukPengeluaran    = "";
            Guid     pengeluaranUangRowID = PengeluaranUangRowID;
            String   NoTransPengeluaran;

            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (_jenisPembayaran == "Bank")
                {
                    bentukPengeluaran = "B";
                }
                else
                {
                    bentukPengeluaran = "K";
                }

                _rowID = Guid.NewGuid();


                lblNoTrans = Numerator.NextNumber("NKB");

                // di bawah ini itu ngebentuk Bukti Uang Keluar bukan bukti bayar pembelian !!!
                Database dbfNumerator = new Database(GlobalVar.DBFinanceOto);
                NoTransPengeluaran = Numerator.GetNomorDokumen(dbfNumerator, "PENGAJUAN_PENGELUARAN_UANG", GlobalVar.PerusahaanID, "/B" + bentukPengeluaran + "K/" +
                                                               string.Format("{0:yyMM}", GlobalVar.GetServerDate), 4, false, true);
                pembayaranPembInsert(ref db, ref counterdb, pengeluaranUangRowID);
                pengeluaranUangInsert(ref dbf, ref counterdbf, pengeluaranUangRowID, bentukPengeluaran, NoTransPengeluaran);
                // hmm di penjualan itu biasanya pake notrans transaksinya, ngga buat dari numerator (penerimaan/pengeluaran) baru

                int looper = 0;
                db.BeginTransaction();
                dbf.BeginTransaction();
                for (looper = 0; looper < counterdb; looper++)
                {
                    db.Commands[looper].ExecuteNonQuery();
                }
                for (looper = 0; looper < counterdbf; looper++)
                {
                    dbf.Commands[looper].ExecuteNonQuery();
                }
                db.CommitTransaction();
                dbf.CommitTransaction();
                MessageBox.Show("Data berhasil diproses");
                //if (this.Caller is Kasir.frmPembayaranMPM)
                //{
                //    Kasir.frmPembayaranMPM frmCaller = (Kasir.frmPembayaranMPM)this.Caller;
                //    frmCaller.RefreshData(PengeluaranUangRowID);
                //    frmCaller.refreshDetail();
                //}
                //this.Close();
                refreshPengeluaranUang();
                RefreshDetail();
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
                dbf.RollbackTransaction();
                MessageBox.Show("Data gagal disimpan !\n " + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #9
0
        private void cmdSaveTitipan_Click(object sender, EventArgs e)
        {
            if (validasiInputan())
            {
                Double      decNilaiBGC             = 0;
                Double      decNilaiNominal         = 0;
                int         bentukPembayaran        = 1;
                System.Guid rekeningPembayaranRowID = System.Guid.Empty;
                decNilaiNominal = Convert.ToDouble(txtPembayaran.Text);

                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "transfer")
                {
                    bentukPembayaran        = 2;
                    rekeningPembayaranRowID = lookUpRekening1.RekeningRowID;
                }
                else if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    bentukPembayaran = 3;
                    decNilaiBGC      = Convert.ToDouble(txtPembayaran.Text);
                    decNilaiNominal  = 0;
                }

                if (mode == FormMode.New)
                {
                    int tempTipeTitipan = 0;
                    if (cboTipeTitipan.SelectedIndex == 0)
                    {
                        // berarti yang titipan murni
                        tempTipeTitipan     = 0;
                        txtNoTransaksi.Text = Numerator.NextNumber("NTP");
                        if (txtNoTransaksi.Text == "")
                        {
                            MessageBox.Show("No Transaksi masih kosong");
                            return;
                        }
                    }
                    else if (cboTipeTitipan.SelectedIndex == 1)
                    {
                        // berarti titipan UM
                        tempTipeTitipan     = 1;
                        txtNoTransaksi.Text = "K" + Numerator.NextNumber("NKJ");
                        if (txtNoTransaksi.Text == "")
                        {
                            MessageBox.Show("No Transaksi masih kosong");
                            return;
                        }
                    }

                    System.Guid rowIDNewTitipan = new System.Guid();
                    Guid        penerimaanUangRowID;
                    penerimaanUangRowID   = Guid.NewGuid();
                    rowIDNewTitipan       = System.Guid.NewGuid();
                    _selectedTitipanRowID = rowIDNewTitipan;

                    Database db = new Database();
                    Database dbf = new Database(GlobalVar.DBFinanceOto);
                    int      counterdb = 0, counterdbf = 0;

                    try
                    {
                        PenerimaanTitipanInsert(ref db, ref counterdb, decNilaiNominal, decNilaiBGC, rowIDNewTitipan, rekeningPembayaranRowID, penerimaanUangRowID, tempTipeTitipan);


                        // kalo tipe pembayarannya itu tunai/transfer baru boleh masukkin ke data penerimaanUang
                        if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "tunai" || cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "transfer")
                        {
                            String tempBentukPenerimaan = "";
                            switch (cbxBentukPembayaran.SelectedIndex + 1)
                            {
                            case 1:     // kalau kas
                                tempBentukPenerimaan = "K";
                                break;

                            case 2:     // kalau transfer
                                tempBentukPenerimaan = "B";
                                break;

                            case 3:     // kalau giro
                                tempBentukPenerimaan = "G";
                                break;

                            case 4:     // kalau titipan
                                tempBentukPenerimaan = "K";
                                break;
                            }
                            // buat no trans penerimaanUang nya dulu
                            Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                   "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                   string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                   , 4, false, true);
                            PenerimaanUangInsert(ref dbf, ref counterdbf, decNilaiNominal, rekeningPembayaranRowID, penerimaanUangRowID, NoTransPenerimaan);
                        }

                        db.BeginTransaction();
                        dbf.BeginTransaction();
                        int looper = 0;
                        for (looper = 0; looper < counterdb; looper++)
                        {
                            db.Commands[looper].ExecuteNonQuery();
                        }
                        for (looper = 0; looper < counterdbf; looper++)
                        {
                            dbf.Commands[looper].ExecuteNonQuery();
                        }
                        db.CommitTransaction();
                        dbf.CommitTransaction();

                        MessageBox.Show("Data berhasil ditambahkan");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        db.RollbackTransaction();
                        dbf.RollbackTransaction();
                        Error.LogError(ex);
                        MessageBox.Show("Penambahan penerimaan titipan gagal disimpan : " + ex.Message.ToString());
                    }
                }
                else if (mode == FormMode.Update)
                {
                    Database db        = new Database();
                    int      counterdb = 0;
                    try
                    {
                        PenerimaanTitipanUpdate(ref db, ref counterdb, decNilaiNominal, decNilaiBGC, rekeningPembayaranRowID);
                        db.BeginTransaction();
                        int looper = 0;
                        for (looper = 0; looper < counterdb; looper++)
                        {
                            db.Commands[looper].ExecuteNonQuery();
                        }
                        db.CommitTransaction();
                        MessageBox.Show("Data berhasil diupdate");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        db.RollbackTransaction();
                        Error.LogError(ex);
                        MessageBox.Show("Data gagal diproses : " + ex.Message.ToString());
                    }
                }
            }
        }
コード例 #10
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridViewRow cur = GVMain.SelectedCells[0].OwningRow;
                using (var db = new Database())
                {
                    Guid PenjualanRowID = (Guid)cur.Cells["RowID"].Value;

                    db.Commands.Add(db.CreateCommand("[usp_Penjualan_LIST]"));
                    db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, PenjualanRowID));
                    DataTable dtbl = db.Commands[0].ExecuteDataTable();

                    if (dtbl.Rows.Count <= 0)
                    {
                        MessageBox.Show("Record penjualan tidak di temukan");

                        // refresh view
                        btnShow_Click(null, null);
                        return;
                    }
                    DataRow dcur = dtbl.Rows[0];

                    Guid   MataUangRowID;
                    Guid   JnsTransaksiRowID;
                    Guid   PengeluaranUangRowID = Guid.NewGuid();
                    string bentukKeluaran       = "K";
                    string NoTransPengeluaran   = "";

                    db.Commands.Clear();
                    db.Commands.Add(db.CreateCommand("[usp_MataUang_LIST]"));
                    db.Commands[0].Parameters.Add(new Parameter("@MataUangID", SqlDbType.VarChar, dcur["MataUangID"].ToString()));
                    DataTable tmp1 = db.Commands[0].ExecuteDataTable();
                    MataUangRowID = (Guid)tmp1.Rows[0]["RowID"];

                    using (var fdb = new Database(GlobalVar.DBFinanceOto))
                    {
                        NoTransPengeluaran = Numerator.GetNomorDokumen(fdb, "PENGAJUAN_PENGELUARAN_UANG", GlobalVar.PerusahaanID, "/B" + bentukKeluaran + "K/" + string.Format("{0:yyMM}", GlobalVar.GetServerDate), 4, false, true);

                        fdb.Commands.Clear();
                        fdb.Commands.Add(fdb.CreateCommand("[usp_JnsTransaksi_LIST]"));
                        fdb.Commands[0].Parameters.Add(new Parameter("@isAktif", SqlDbType.Int, 2));
                        fdb.Commands[0].Parameters.Add(new Parameter("@JnsTransaksi", SqlDbType.VarChar, ((int)enumJnsTransaksi.TLABiayaKomisi).ToString()));
                        tmp1 = fdb.Commands[0].ExecuteDataTable();
                        JnsTransaksiRowID = (Guid)tmp1.Rows[0]["RowID"];

                        // force validate record not yet processed
                        db.Commands.Clear();
                        db.Commands.Add(db.CreateCommand("[usp_KomisiPenjualan_LIST]"));
                        db.Commands[0].Parameters.Add(new Parameter("@PJRowID", SqlDbType.UniqueIdentifier, PenjualanRowID));
                        tmp1 = db.Commands[0].ExecuteDataTable();

                        if (tmp1.Rows.Count <= 0)
                        {
                            MessageBox.Show("Record penjualan tidak di temukan");

                            // refresh view
                            btnShow_Click(null, null);
                            return;
                        }
                        else if (tmp1.Rows[0]["IsFixed"].ToString() == "1")
                        {
                            MessageBox.Show("Penjualan telah di proses, tidak dapat di proses ulang");

                            // refresh view
                            btnShow_Click(null, null);
                            return;
                        }

                        // sensitive query
                        db.BeginTransaction();
                        fdb.BeginTransaction();

                        // sensitive case, double wrap
                        try
                        {
                            fdb.Commands.Clear();
                            fdb.Commands.Add(fdb.CreateCommand("[usp_PengeluaranUang_INSERT_SIMPLE]"));
                            fdb.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, PengeluaranUangRowID));
                            fdb.Commands[0].Parameters.Add(new Parameter("@TanggalRk", SqlDbType.Date, GlobalVar.GetServerDate));
                            fdb.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, GlobalVar.GetServerDate));
                            fdb.Commands[0].Parameters.Add(new Parameter("@NoAcc", SqlDbType.VarChar, string.Empty));
                            fdb.Commands[0].Parameters.Add(new Parameter("@NoApproval", SqlDbType.VarChar, string.Empty));
                            fdb.Commands[0].Parameters.Add(new Parameter("@NoBukti", SqlDbType.VarChar, NoTransPengeluaran));
                            fdb.Commands[0].Parameters.Add(new Parameter("@PerusahaanDariRowID", SqlDbType.UniqueIdentifier, GlobalVar.PerusahaanRowID));
                            fdb.Commands[0].Parameters.Add(new Parameter("@CabangDariID", SqlDbType.VarChar, GlobalVar.CabangID));
                            fdb.Commands[0].Parameters.Add(new Parameter("@VendorRowID", SqlDbType.UniqueIdentifier, DBNull.Value));
                            fdb.Commands[0].Parameters.Add(new Parameter("@PerusahaanKeRowID", SqlDbType.UniqueIdentifier, GlobalVar.PerusahaanRowID));
                            fdb.Commands[0].Parameters.Add(new Parameter("@MataUangRowID", SqlDbType.UniqueIdentifier, MataUangRowID));
                            fdb.Commands[0].Parameters.Add(new Parameter("@JnsTransaksiRowID", SqlDbType.UniqueIdentifier, JnsTransaksiRowID));
                            fdb.Commands[0].Parameters.Add(new Parameter("@Nominal", SqlDbType.Money, dcur["BiayaKomisi"]));
                            fdb.Commands[0].Parameters.Add(new Parameter("@NominalRp", SqlDbType.Money, dcur["BiayaKomisi"]));
                            fdb.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, "Biaya Komisi"));
                            fdb.Commands[0].Parameters.Add(new Parameter("@StatusApproval", SqlDbType.TinyInt, 9));
                            fdb.Commands[0].Parameters.Add(new Parameter("@JnsPengeluaran", SqlDbType.VarChar, bentukKeluaran));
                            fdb.Commands[0].Parameters.Add(new Parameter("@JnsPenerimaan", SqlDbType.VarChar, string.Empty));
                            fdb.Commands[0].Parameters.Add(new Parameter("@KasRowID", SqlDbType.UniqueIdentifier, GlobalVar.KasBesarRowID));
                            fdb.Commands[0].Parameters.Add(new Parameter("@PengeluaranKe", SqlDbType.Int, 2));
                            fdb.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));

                            fdb.Commands[0].ExecuteNonQuery();

                            db.Commands.Clear();
                            db.Commands.Add(db.CreateCommand("[usp_Penjualan_UPDATE_KomisiADD]"));
                            db.Commands[0].Parameters.Add(new Parameter("@PenjRowID", SqlDbType.UniqueIdentifier, PenjualanRowID));
                            db.Commands[0].Parameters.Add(new Parameter("@Komisi", SqlDbType.Money, dcur["BiayaKomisi"]));
                            db.Commands[0].Parameters.Add(new Parameter("@PengeluaranUangRowID", SqlDbType.UniqueIdentifier, PengeluaranUangRowID));
                            db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();

                            // flush query if all done good
                            db.CommitTransaction();
                            fdb.CommitTransaction();

                            // refresh view
                            btnShow_Click(null, null);
                        }
                        catch (Exception ex2)
                        {
                            // rollback if something happen
                            db.RollbackTransaction();
                            fdb.RollbackTransaction();

                            MessageBox.Show("Gagal, pesan error:\n" + ex2.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Gagal, pesan error:\n" + ex.Message);

                // refresh view, reduce fail data because record has updated by others
                btnShow_Click(null, null);
            }
        }
コード例 #11
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            bool lproses = true;

            if ((_tipeNota != enumTipeNota.DebitNote) && (_tipeNota != enumTipeNota.CreditNote))
            {
                MessageBox.Show("Tipe Nota (DN/KN) belum dipilih ...");
                lproses = false;
            }

            if (string.IsNullOrEmpty(dtTanggal.Text.ToString()))
            {
                MessageBox.Show("Tanggal belum diinput...");
                lproses = false;
            }
            else
            {
                if (CheckBackDate() == true)
                {
                    MessageBox.Show("Tidak boleh input data lebih dari 2 hari yang lalu");
                    lproses = false;
                }

                //if (dtTanggal.DateValue <= _today.AddDays(-2))
                //{
                //    MessageBox.Show("Tidak boleh input data lebih dari 2 hari yang lalu");
                //    return;
                //}
            }

            if (lproses)
            {
                try {
                    this.Cursor = Cursors.WaitCursor;
                    switch (formMode)
                    {
                    case enumFormMode.New:
                    {
                        txtNoBukti.Text = Numerator.GetNomorDokumen("PENGAJUAN_PENGELUARAN_UANG", "", "/" +
                                                                    ((_tipeNota == enumTipeNota.DebitNote) ? "D" :"K") + "/" +
                                                                    string.Format("{0:yyMM}", dtTanggal.DateValue)
                                                                    , 3, false, true);
                        using (Database db = new Database())
                        {
                            DataTable dt = new DataTable();
                            db.Commands.Add(db.CreateCommand("usp_HubunganIstimewa_INSERT"));
                            db.Commands[0].Parameters.Add(new Parameter("@NoBukti", SqlDbType.VarChar, txtNoBukti.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, dtTanggal.DateValue));
                            db.Commands[0].Parameters.Add(new Parameter("@TipeNota", SqlDbType.TinyInt, _tipeNota));
                            db.Commands[0].Parameters.Add(new Parameter("@CabangDariID", SqlDbType.VarChar, cboCabangDari.SelectedValue));
                            db.Commands[0].Parameters.Add(new Parameter("@CabangKeID", SqlDbType.VarChar, cboCabangKe.SelectedValue));
                            db.Commands[0].Parameters.Add(new Parameter("@KelompokTransaksiRowID", SqlDbType.UniqueIdentifier, cboKelompokTransaksi.SelectedValue));
                            db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            dt = db.Commands[0].ExecuteDataTable();

                            if (dt.Rows.Count > 0)
                            {
                                MessageBox.Show("No. Bukti : '" + txtNoBukti.Text + "' sudah ada...");
                            }
                        }
                    }
                    break;

                    case enumFormMode.Update:
                    {
                        using (Database db = new Database())
                        {
                            db.Commands.Add(db.CreateCommand("usp_HubunganIstimewa_UPDATE"));
                            db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, _rowID));
                            db.Commands[0].Parameters.Add(new Parameter("@NoBukti", SqlDbType.VarChar, txtNoBukti.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, dtTanggal.DateValue));
                            db.Commands[0].Parameters.Add(new Parameter("@TipeNota", SqlDbType.TinyInt, _tipeNota));
                            db.Commands[0].Parameters.Add(new Parameter("@CabangDariID", SqlDbType.VarChar, cboCabangDari.SelectedValue));
                            db.Commands[0].Parameters.Add(new Parameter("@CabangKeID", SqlDbType.VarChar, cboCabangKe.SelectedValue));
                            db.Commands[0].Parameters.Add(new Parameter("@KelompokTransaksiRowID", SqlDbType.UniqueIdentifier, cboKelompokTransaksi.SelectedValue));
                            db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();
                        }
                    }
                    break;
                    }
                }catch (Exception ex) {
                    Error.LogError(ex);
                }
            }
コード例 #12
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            Database db = new Database();
            Database dbf = new Database(GlobalVar.DBFinanceOto);
            int      counterdb = 0, counterdbf = 0;
            String   bentukPengeluaran    = "";
            Guid     pengeluaranUangRowID = Guid.NewGuid();
            String   NoTransPengeluaran;

            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (ValidateSave())
                {
                }
                else
                {
                    return;
                }

                switch (cbxBentukPembayaran.SelectedIndex)
                {
                case 0:     // kalo 0 itu tunai -> K
                    bentukPengeluaran = "K";
                    break;

                case 1:     // kalo 1 itu transfer -> B
                    bentukPengeluaran = "B";
                    break;
                }
                _rowID = Guid.NewGuid();


                lblNoTrans.Text = Numerator.NextNumber("NKB");

                // di bawah ini itu ngebentuk Bukti Uang Keluar bukan bukti bayar pembelian !!!
                Database dbfNumerator = new Database(GlobalVar.DBFinanceOto);
                NoTransPengeluaran = Numerator.GetNomorDokumen(dbfNumerator, "PENGAJUAN_PENGELUARAN_UANG", GlobalVar.PerusahaanID, "/B" + bentukPengeluaran + "K/" +
                                                               string.Format("{0:yyMM}", GlobalVar.GetServerDate), 4, false, true); // pake ambil numeratornya finance dan coba pake koding yg punya pengeluaranuang insert???

                if (Convert.ToDouble(txtNominal.Text) > 0)
                {
                    pembayaranPembInsert(ref db, ref counterdb, pengeluaranUangRowID);
                    pengeluaranUangInsert(ref dbf, ref counterdbf, pengeluaranUangRowID, bentukPengeluaran, NoTransPengeluaran);
                    // hmm di penjualan itu biasanya pake notrans transaksinya, ngga buat dari numerator (penerimaan/pengeluaran) baru
                }

                int looper = 0;
                db.BeginTransaction();
                dbf.BeginTransaction();
                for (looper = 0; looper < counterdb; looper++)
                {
                    db.Commands[looper].ExecuteNonQuery();
                }
                for (looper = 0; looper < counterdbf; looper++)
                {
                    dbf.Commands[looper].ExecuteNonQuery();
                }
                db.CommitTransaction();
                dbf.CommitTransaction();
                MessageBox.Show("Data berhasil diproses");
                this.Close();
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
                dbf.RollbackTransaction();
                MessageBox.Show("Data gagal disimpan !\n " + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #13
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            if (Double.Parse(txtNominal.Text) == 0)
            {
                MessageBox.Show("Nominal harus >=0");
                txtNominal.Focus();
                return;
            }

            if (Double.Parse(txtNominal.Text) > Double.Parse(txtNominalSisa.Text))
            {
                MessageBox.Show("Sisa Nominal hanya " + txtNominalSisa.Text);
                txtNominal.Focus();
                return;
            }

            if (txtUraian.Text == "")
            {
                MessageBox.Show("Uraian harus di isi.");
                txtUraian.Focus();
                return;
            }

            try
            {
                Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                       "/BKM/" +
                                                                       string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                       , 4, false, true);
                Guid _rowID = Guid.NewGuid();
                this.Cursor = Cursors.WaitCursor;
                using (Database db = new Database(GlobalVar.DBShowroom))
                {
                    db.Commands.Add(db.CreateCommand("[usp_PenerimaanUM_INSERT]"));
                    db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, _rowID));
                    db.Commands[0].Parameters.Add(new Parameter("@PenjRowID", SqlDbType.UniqueIdentifier, _rowidP));
                    db.Commands[0].Parameters.Add(new Parameter("@CabangID", SqlDbType.VarChar, GlobalVar.CabangID));
                    db.Commands[0].Parameters.Add(new Parameter("@NoTrans", SqlDbType.VarChar, NoTransPenerimaan));
                    db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, txtUraian.Text));
                    db.Commands[0].Parameters.Add(new Parameter("@KodeTrans", SqlDbType.VarChar, "ADJ"));
                    db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.DateTime, txtTglAdj.DateValue));
                    db.Commands[0].Parameters.Add(new Parameter("@MataUangID", SqlDbType.VarChar, "IDR"));
                    db.Commands[0].Parameters.Add(new Parameter("@Nominal", SqlDbType.Money, Double.Parse(txtNominal.Text)));
                    db.Commands[0].Parameters.Add(new Parameter("@NilaiBG", SqlDbType.Money, 0));
                    db.Commands[0].Parameters.Add(new Parameter("@idrec", SqlDbType.VarChar, Tools.CreateFingerPrintMilliseconds()));
                    db.Commands[0].Parameters.Add(new Parameter("@BentukPembayaran", SqlDbType.SmallInt, 1));
                    db.Commands[0].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].ExecuteNonQuery();
                }

                if (this.Caller is Kasir.frmPenerimaanLeasingBrowse)
                {
                    Kasir.frmPenerimaanLeasingBrowse frmCaller = (Kasir.frmPenerimaanLeasingBrowse) this.Caller;
                    frmCaller.RefreshHeader3(_rowidP.ToString());
                    frmCaller.RefreshDetail(Guid.Empty);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #14
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            DateTimeFormatInfo dfi  = DateTimeFormatInfo.CurrentInfo;
            DateTime           date = GlobalVar.GetServerDate;
            Calendar           cal  = dfi.Calendar;
            int mingguKe            = cal.GetWeekOfYear(date, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

            int bentukPembayaran = 1;

            System.Guid rekeningPembayaranRowID = System.Guid.Empty;

            Database db  = new Database();
            Database dbf = new Database(GlobalVar.DBFinanceOto);

            int counterdb = 0, counterdbf = 0;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (ValidateSave())
                {
                }
                else
                {
                    return;
                }

                Guid penerimaanUangRowID;
                Guid pengeluaranUangRowID;
                penerimaanUangRowID  = Guid.NewGuid();
                pengeluaranUangRowID = Guid.NewGuid();

                Exception exDE = new DataException();
                switch (cboBentukPembayaran.SelectedIndex)
                {
                case 0: bentukPembayaran = 1; break;     // kas

                case 1: bentukPembayaran = 2; break;     // bank

                case 2: bentukPembayaran = 5; break;     // potongan pembelian itu nonkasir

                default: throw (exDE); break;
                }

                if (bentukPembayaran == 2)
                {
                    rekeningPembayaranRowID = lookUpRekening1.RekeningRowID;
                }

                penjualanLogInsert(ref db, ref counterdb);
                if (cboTipe.Text == "DP Subsidi" || cboTipe.Text == "Pengurangan DP Subsidi")
                {
                    DPDetailSubsidiInsert(ref db, ref counterdb);
                }
                else
                {
                    lblNoKwitansi.Text = "K" + Numerator.NextNumber("NKJ");

                    penerimaanUMInsert(ref db, ref counterdb, bentukPembayaran, rekeningPembayaranRowID, penerimaanUangRowID, pengeluaranUangRowID);
                    DPDetailSubsidiInsert(ref db, ref counterdb);

                    // masukkin data ke penerimaan Uang
                    // buat no Bukti PenerimaanUang baru
                    String tempBentukPenerimaan = "";
                    switch (cboBentukPembayaran.SelectedIndex + 1)
                    {
                    case 1:     // kalau kas
                        tempBentukPenerimaan = "K";
                        break;

                    case 2:     // kalau transfer
                        tempBentukPenerimaan = "B";
                        break;

                    case 3:     // kalau giro
                        tempBentukPenerimaan = "G";
                        break;

                    case 4:     // kalau titipan
                        tempBentukPenerimaan = "K";
                        break;
                    }
                    Database dbfNumerator = new Database(GlobalVar.DBFinanceOto);

                    if (cboTipe.SelectedIndex == 0 || cboTipe.SelectedIndex == 1) // DP Subsidi / DP Pelanggan
                    {
                        String NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                             "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                             string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                             , 4, false, true);

                        penerimaanUangInsert(ref dbf, ref counterdbf, rekeningPembayaranRowID, penerimaanUangRowID, NoTransPenerimaan);
                    }
                    else if (cboTipe.SelectedIndex == 2) // Pengembalian DP Pelanggan
                    {
                        String tempBentukPengeluaran = tempBentukPenerimaan;

                        // di bawah ini itu ngebentuk Bukti Uang Keluar untuk komisi!!!
                        String NoTransPengeluaran = Numerator.GetNomorDokumen(dbfNumerator, "PENGAJUAN_PENGELUARAN_UANG", GlobalVar.PerusahaanID, "/B" + tempBentukPengeluaran + "K/" +
                                                                              string.Format("{0:yyMM}", GlobalVar.GetServerDate), 4, false, true); // pake ambil numeratornya finance dan coba pake koding yg punya pengeluaranuang insert???

                        // -- !!!!!!!!!!!!!!!!!!!! tadinya pengeluaranUangRowID itu newGuid !!!, mesti cepet2 dibenerin!!!
                        pengeluaranUangInsert(ref dbf, ref counterdbf, pengeluaranUangRowID, tempBentukPengeluaran, NoTransPengeluaran); // ngga kirim vendor rowid saat komisi
                    }
                }

                updateTambahanUMPelunasan(ref db, ref counterdb);

                db.BeginTransaction();
                dbf.BeginTransaction();
                int looper = 0;
                for (looper = 0; looper < counterdb; looper++)
                {
                    db.Commands[looper].ExecuteNonQuery();
                }
                for (looper = 0; looper < counterdbf; looper++)
                {
                    dbf.Commands[looper].ExecuteNonQuery();
                }
                db.CommitTransaction();
                dbf.CommitTransaction();

                String messageTemp;
                messageTemp = "Data berhasil ditambahkan. \n";

                MessageBox.Show(messageTemp);
                this.Close();
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
                dbf.RollbackTransaction();
                MessageBox.Show("Data gagal ditambahkan !\n " + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #15
0
        private void commandSAVE_Click(object sender, EventArgs e)
        {
            ErrorProvider err = new ErrorProvider();

            if (cboKas.SelectedValue.ToString() == "" || cboKas.SelectedValue.ToString() == Guid.Empty.ToString())
            {
                err.SetError(cboKas, "Pilih Datanya");
                return;
            }

            if (cboPegawai.SelectedValue.ToString() == "")
            {
                err.SetError(cboPegawai, "Pilih Datanya");
                return;
            }
            if (!txtTanggal.DateValue.HasValue)
            {
                err.SetError(txtTanggal, "Isi Datanya");
                return;
            }

            switch (FormMode)
            {
            case enumFormMode.New:
            {
                if (txtNominal.GetDoubleValue <= 0)
                {
                    err.SetError(txtNominal, "Isi Datanya");
                    return;
                }

                cNoBKK = Numerator.GetNomorDokumen("PENGELUARAN_KASBON", "",
                                                   "/BS/" + string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                   , 3, false, true);
                dt = new DataTable();
                using (Database db = new Database())
                {
                    db.Commands.Add(db.CreateCommand("usp_Kasbon_INSERT"));
                    db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, txtTanggal.DateValue));
                    db.Commands[0].Parameters.Add(new Parameter("@KaryawanRowId", SqlDbType.UniqueIdentifier, cboPegawai.SelectedValue));
                    db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, txtUraian.Text));
                    db.Commands[0].Parameters.Add(new Parameter("@No_bukti", SqlDbType.Char, cNoBKK));
                    db.Commands[0].Parameters.Add(new Parameter("@Nominal", SqlDbType.Float, txtNominal.GetDoubleValue));
                    db.Commands[0].Parameters.Add(new Parameter("@KasRowID", SqlDbType.UniqueIdentifier, cboKas.SelectedValue));
                    db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].Parameters.Add(new Parameter("@UnitUsaha", SqlDbType.VarChar, cboUnitUsaha.Text));

                    dt = db.Commands[0].ExecuteDataTable();
                    MessageBox.Show(Messages.Confirm.SaveSuccess);
                }
                closeForm();
                this.Close();
                break;
            }

            case enumFormMode.Update:
            {
                dt = new DataTable();
                using (Database db = new Database())
                {
                    db.Commands.Add(db.CreateCommand("usp_Kasbon_UPDATE"));
                    db.Commands[0].Parameters.Add(new Parameter("@RowId", SqlDbType.UniqueIdentifier, _rowID));
                    db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, txtTanggal.DateValue));
                    db.Commands[0].Parameters.Add(new Parameter("@KaryawanRowId", SqlDbType.UniqueIdentifier, cboPegawai.SelectedValue));
                    db.Commands[0].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, txtUraian.Text));
                    db.Commands[0].Parameters.Add(new Parameter("@Nominal", SqlDbType.Float, float.Parse(txtNominal.Text.ToString())));
                    db.Commands[0].Parameters.Add(new Parameter("@KasRowID", SqlDbType.UniqueIdentifier, cboKas.SelectedValue));
                    db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].Parameters.Add(new Parameter("@UnitUsaha", SqlDbType.VarChar, cboUnitUsaha.Text));

                    dt = db.Commands[0].ExecuteDataTable();
                    MessageBox.Show(Messages.Confirm.UpdateSuccess);
                }
                closeForm();
                this.Close();
                break;
            }
            }
        }
コード例 #16
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (validateSave())
            {
                Database db = new Database(GlobalVar.DBShowroom);
                Database dbf = new Database(GlobalVar.DBFinanceOto);
                int      counterdb = 0, counterdbf = 0;
                try
                {
                    String tempBentukPenerimaan = "";
                    int    bentukpembayaran     = 0;
                    switch (cboBentukPembayaran.SelectedIndex + 1)
                    {
                    case 1:     // kalau kas
                        tempBentukPenerimaan = "K";
                        bentukpembayaran     = 1;
                        break;

                    case 2:     // kalau transfer
                        tempBentukPenerimaan = "B";
                        bentukpembayaran     = 2;
                        break;

                    /*case 3: // kalau giro
                     *  tempBentukPenerimaan = "G";
                     *  bentukpembayaran = 3;
                     *  break;*/     // karena lagi ngga ada giro makanya geser 1
                    case 3:          // kalau titipan
                        tempBentukPenerimaan = "K";
                        bentukpembayaran     = 4;
                        break;
                    }

                    // buat Guid PenerimaanUang untuk Denda nya
                    Guid penerimaanUangRowID_Denda = Guid.NewGuid();
                    Guid penerimaanPBLRowID        = Guid.NewGuid();

                    // Update ke PenerimaanUM / Angsuran data PenerimaanDendanya
                    // ~ penerimaan denda sekarang di tabel penerimaan denda sendiri

                    /*
                     *  if (_src == "Angsuran")
                     *  {
                     *      penerimaanAngsuranUpdateDenda(ref db, ref counterdb, penerimaanUangRowID_Denda);
                     *  }
                     *  else if (_src == "Pelunasan")
                     *  {
                     *      penerimaanUMUpdateDenda(ref db, ref counterdb, penerimaanUangRowID_Denda);
                     *  }
                     */

                    // masukkan ke Penerimaan Denda
                    // yg dimasukkan itu ngga usah dikurangin potongan, dua2 nya itu sendiri2 ngga usah saling mepengaruhi!!!
                    // pas penampilan sama pemrosesan baru diolah data potongannya, pas simpen biasa aja
                    String NoTransDenda = Numerator.NextNumber("NKD");
                    penerimaanDendaInsert(ref db, ref counterdb, PenerimaanDendaNewRowID, _srcRowID, _src,
                                          Convert.ToDouble(txtnominal.Text.ToString()), // ( - Convert.ToDouble(txtpotongan.Text.ToString())
                                          penerimaanPBLRowID, penerimaanUangRowID_Denda, bentukpembayaran, NoTransDenda);
                    // sekarang rowid penerimaanuang untuk denda disimpannya di tabel dendanya

                    // kalo pake titipan ngga perlu masukkin data ke penerimaanUang
                    if (cboBentukPembayaran.Text.ToLower() == "titipan")
                    {
                        // kalo pake titipan cukup masukkin ke titipan iden
                        penerimaanTitipanIdenInsert(ref db, ref counterdb);
                    }
                    else
                    {
                        // hanya buat ke penerimaan uang, kalau nominalnya > 0 pembayarannya
                        if (Convert.ToDouble(Tools.isNull(txtnominal.Text, 0).ToString()) > 0 &&
                            (cboTipeTransaksi.SelectedIndex == 0 || cboTipeTransaksi.SelectedIndex == 1)
                            )
                        {
                            // buat no trans penerimaanUang nya dulu
                            Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                   "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                   string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                   , 4, false, true);
                            penerimaanUangInsert(ref dbf, ref counterdbf, lookUpRekening1.RekeningRowID, penerimaanUangRowID_Denda, lblNoTrans.Text,
                                                 Convert.ToDecimal(txtnominal.Text), // ngga usah dipotong, yg masuk memang sesuai nominal - Convert.ToDecimal(txtpotongan.Text))
                                                 " - Denda", NoTransPenerimaan);
                        }
                        // buat masukkin ke penerimaanUang yang Dendanya
                        if (Convert.ToDouble(Tools.isNull(txtNominalPembulatan.Text, 0).ToString()) > 0 &&
                            (cboTipeTransaksi.SelectedIndex == 0 || cboTipeTransaksi.SelectedIndex == 1))
                        {
                            Database dbfNumeratorsub      = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaanPBL = Numerator.GetNomorDokumen(dbfNumeratorsub, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                      "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                      string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                      , 4, false, true);
                            penerimaanPembulatanInsert(ref dbf, ref counterdbf, lookUpRekening1.RekeningRowID, penerimaanPBLRowID, NoTransPenerimaanPBL);
                        }
                    }

                    db.BeginTransaction();
                    dbf.BeginTransaction();
                    int looper = 0;
                    for (looper = 0; looper < counterdb; looper++)
                    {
                        db.Commands[looper].ExecuteNonQuery();
                    }
                    for (looper = 0; looper < counterdbf; looper++)
                    {
                        dbf.Commands[looper].ExecuteNonQuery();
                    }
                    db.CommitTransaction();
                    dbf.CommitTransaction();
                    MessageBox.Show("Data berhasil diproses.");

                    this.Close();
                }
                catch (Exception ex)
                {
                    db.RollbackTransaction();
                    dbf.RollbackTransaction();
                    MessageBox.Show("Data tidak berhasil diproses. " + ex.Message);
                }
            }
        }
コード例 #17
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            Database dbfsub    = new Database(GlobalVar.DBFinanceOto);
            Database db        = new Database();
            int      Counterdb = 0;

            try
            {
                errorProvider1.Clear();
                if (String.IsNullOrEmpty(txt_KetPembatalan.Text))
                {
                    errorProvider1.SetError(txt_KetPembatalan, "Silakan isi terlebih dahulu alasan pembatalan dan di ACC oleh siapa");
                    return;
                }

                DialogResult dialogResult = MessageBox.Show("Apakah anda Yakin ingin membatalkan penjualan ini", "Penjualan", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
                else
                {
                    String   bentukPengeluaran = "K";
                    String   NoTransPengeluaran;
                    Database dbfNumeratorsub;
                    Database dbfNumerator;
                    Database dbRead;
                    Guid     RowID_BalikJournal    = new Guid();
                    Guid     RowID_BalikJournalHPP = new Guid();

                    //using (db)
                    //{
                    if (txt_BiayaAdministrasi.GetDoubleValue > 0)
                    {
                        dbfNumeratorsub = new Database(GlobalVar.DBFinanceOto);
                        String NoTransPenerimaanBaru = Numerator.GetNomorDokumen(dbfNumeratorsub, "PENERIMAAN_UANG_BIAYA_ADM_BATAL_JUAL", GlobalVar.PerusahaanID,
                                                                                 "/B" + bentukPengeluaran + "M/" +
                                                                                 string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                 , 4, false, true);
                        Guid _JnsTransaksiRowID;

                        using (dbfsub)
                        {
                            DataTable dtfsub = new DataTable();
                            dbfsub.Commands.Add(dbfsub.CreateCommand("usp_JnsTransaksi_LIST"));                                                              //01
                            dbfsub.Commands[0].Parameters.Add(new Parameter("@isAktif", SqlDbType.Int, 2));
                            dbfsub.Commands[0].Parameters.Add(new Parameter("@JnsTransaksi", SqlDbType.VarChar, ((int)enumJnsTransaksi.TLAADM).ToString())); // ADM -> Biaya Adm Penjualan   (30)
                            dtfsub             = dbfsub.Commands[0].ExecuteDataTable();
                            _JnsTransaksiRowID = (Guid)dtfsub.Rows[0]["RowID"];
                        }

                        db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_BiayaAdm"));                                                                     //02
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@NoBukti", SqlDbType.VarChar, NoTransPenerimaanBaru));                          // tadinya newNoTrans txtNoBukti.Text
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@PerusahaanKeRowID", SqlDbType.UniqueIdentifier, GlobalVar.PerusahaanRowID));   // samain
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@PerusahaanDariRowID", SqlDbType.UniqueIdentifier, GlobalVar.PerusahaanRowID)); // samain
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@CabangDari", SqlDbType.VarChar, GlobalVar.CabangID));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@CabangKe", SqlDbType.VarChar, GlobalVar.CabangID));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@MataUangRowID", SqlDbType.UniqueIdentifier, MataUangRowID));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@JnsTransaksi", SqlDbType.UniqueIdentifier, _JnsTransaksiRowID));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@Nominal", SqlDbType.Money, txt_BiayaAdministrasi.GetDoubleValue));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@NominalRp", SqlDbType.Money, txt_BiayaAdministrasi.GetDoubleValue));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@Uraian", SqlDbType.VarChar, "Biaya Administrasi Pembatalan Penjualan NO Trans : " + txt_NoTrans.Text));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@JnsPenerimaan", SqlDbType.VarChar, bentukPengeluaran));           // ini angsuran
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@KasRowID", SqlDbType.UniqueIdentifier, GlobalVar.KasBesarRowID)); // kalo jenisnya kas, kasih KasRowID
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RekeningRowID", SqlDbType.UniqueIdentifier, Guid.Empty));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        //db.Commands[Counterdb].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, "YUSUF"));
                        Counterdb++;
                    }

                    //Perulangan untuk membuat BKK dan insert row ke tabel Delete penerimaan ADM, Angsuran, dan UM
                    foreach (DataRow dr in dt_RowID.Rows)
                    {
                        dbfNumerator       = new Database(GlobalVar.DBFinanceOto);
                        NoTransPengeluaran = Numerator.GetNomorDokumen(dbfNumerator, "PENGAJUAN_PENGELUARAN_UANG", GlobalVar.PerusahaanID, "/B" + bentukPengeluaran + "K/" +
                                                                       string.Format("{0:yyMM}", GlobalVar.GetServerDate), 4, false, true);
                        Guid RowID_BKK = Guid.NewGuid();
                        db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_BatalSave"));         //3
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID_BKK));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@PenerimaanUangRowID", SqlDbType.UniqueIdentifier, dr["PenerimaanUangRowID"]));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@TabelRowID", SqlDbType.UniqueIdentifier, dr["RowID"]));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@NamaTabel", SqlDbType.VarChar, dr["NamaTabel"]));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@NoBKK", SqlDbType.VarChar, NoTransPengeluaran.ToString()));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@CancelBy", SqlDbType.VarChar, SecurityManager.UserID));
                        //db.Commands[Counterdb].Parameters.Add(new Parameter("@CancelBy", SqlDbType.VarChar, "YUSUF"));
                        Counterdb++;
                    }

                    //Balik Journal
                    if (Tools.isNull(dt.Rows[0]["JournalRowID"], "").ToString() != "")
                    {
                        RowID_BalikJournal = Guid.NewGuid();
                        String    RecordIDJournal  = Tools.CreateFingerPrint();
                        DataTable dt_JournalDetail = new DataTable();
                        db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_BalikJournal"));         //4
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@JournalRowID", SqlDbType.UniqueIdentifier, dt.Rows[0]["JournalRowID"]));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID_BalikJournal));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RowIDPenjualan", SqlDbType.UniqueIdentifier, RowID));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, RecordIDJournal));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        Counterdb++;

                        using (dbRead = new Database())
                        {
                            dbRead.Commands.Add(dbRead.CreateCommand("usp_PenjualanBaru_GetJournalDetailRowID"));
                            dbRead.Commands[0].Parameters.Add(new Parameter("@JournalRowID", SqlDbType.UniqueIdentifier, dt.Rows[0]["JournalRowID"]));
                            dt_JournalDetail = dbRead.Commands[0].ExecuteDataTable();
                        }

                        foreach (DataRow dr in dt_JournalDetail.Rows)
                        {
                            db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_BalikJournalDetail"));     //5
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, dr["RowID"]));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RowIDPenjualan", SqlDbType.UniqueIdentifier, RowID_BalikJournal));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@HRecordID", SqlDbType.VarChar, RecordIDJournal));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, Tools.CreateFingerPrint()));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            Counterdb++;
                        }
                    }

                    //Balik JournalHPP
                    if (Tools.isNull(dt.Rows[0]["JournalHPPRowID"], "").ToString() != "")
                    {
                        RowID_BalikJournalHPP = Guid.NewGuid();
                        String    RecordIDJournal  = Tools.CreateFingerPrint();
                        DataTable dt_JournalDetail = new DataTable();

                        db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_BalikJournal"));     //6
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@JournalRowID", SqlDbType.UniqueIdentifier, dt.Rows[0]["JournalHPPRowID"]));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID_BalikJournalHPP));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RowIDPenjualan", SqlDbType.UniqueIdentifier, RowID));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, RecordIDJournal));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        Counterdb++;

                        using (dbRead = new Database())
                        {
                            dbRead.Commands.Add(dbRead.CreateCommand("usp_PenjualanBaru_GetJournalDetailRowID"));
                            dbRead.Commands[0].Parameters.Add(new Parameter("@JournalRowID", SqlDbType.UniqueIdentifier, dt.Rows[0]["JournalRowID"]));
                            dt_JournalDetail = dbRead.Commands[0].ExecuteDataTable();
                        }
                        foreach (DataRow dr in dt_JournalDetail.Rows)
                        {
                            db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_BalikJournalDetail"));     //7
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, dr["RowID"]));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RowIDPenjualan", SqlDbType.UniqueIdentifier, RowID_BalikJournalHPP));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@HRecordID", SqlDbType.VarChar, RecordIDJournal));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, Tools.CreateFingerPrint()));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            Counterdb++;
                        }
                    }

                    //Perulangan untuk menghapus row tabel penerimaan ADM, Angsuran, dan UM
                    foreach (DataRow dr in dt_RowID.Rows)
                    {
                        db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_DELETE_Penerimaan"));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@TabelRowID", SqlDbType.UniqueIdentifier, dr["RowID"]));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@NamaTabel", SqlDbType.VarChar, dr["NamaTabel"]));
                        Counterdb++;
                    }

                    //Pengecekan KomisiRowID dan pembuatan BKM nya
                    if (Tools.isNull(dt.Rows[0]["PengeluaranKomisiRowID"], "").ToString() != "")
                    {
                        dbfNumeratorsub = new Database(GlobalVar.DBFinanceOto);
                        String NoTransPenerimaanBaru = Numerator.GetNomorDokumen(dbfNumeratorsub, "PENERIMAAN_UANG_KOMISI", GlobalVar.PerusahaanID,
                                                                                 "/B" + bentukPengeluaran + "M/" +
                                                                                 string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                 , 4, false, true);

                        db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_PenerimaanKomisi"));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@PengeluaranKomisiRowID", SqlDbType.UniqueIdentifier, (Guid)dt.Rows[0]["PengeluaranKomisiRowID"]));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@NoBKM", SqlDbType.VarChar, NoTransPenerimaanBaru));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        Counterdb++;
                    }

                    #region awal

                    //Cek JournalHPPRowID PembayaranPemb
                    Object JournalHPPRowIDPembayaranPemb;
                    using (dbRead = new Database())
                    {
                        dbRead.Commands.Add(dbRead.CreateCommand("usp_PenjualanBaru_CekJournalHPPRowIDPembayaranPemb"));
                        dbRead.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID));
                        JournalHPPRowIDPembayaranPemb = dbRead.Commands[0].ExecuteScalar();
                    }

                    if (Tools.isNull(JournalHPPRowIDPembayaranPemb, "").ToString() != "")
                    {
                        RowID_BalikJournalHPP = Guid.NewGuid();
                        String    RecordIDJournal  = Tools.CreateFingerPrint();
                        DataTable dt_JournalDetail = new DataTable();
                        db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_BalikJournal"));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@JournalRowID", SqlDbType.UniqueIdentifier, (Guid)JournalHPPRowIDPembayaranPemb));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID_BalikJournalHPP));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RowIDPenjualan", SqlDbType.UniqueIdentifier, RowID));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, RecordIDJournal));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[Counterdb].Parameters.Add(new Parameter("@Keterangan", SqlDbType.VarChar, "UpdateJournalPembayaranPemb"));
                        Counterdb++;

                        using (dbRead = new Database())
                        {
                            dbRead.Commands.Add(dbRead.CreateCommand("usp_PenjualanBaru_GetJournalDetailRowID"));
                            dbRead.Commands[0].Parameters.Add(new Parameter("@JournalRowID", SqlDbType.UniqueIdentifier, dt.Rows[0]["JournalRowID"]));
                            dt_JournalDetail = dbRead.Commands[0].ExecuteDataTable();
                        }

                        foreach (DataRow dr in dt_JournalDetail.Rows)
                        {
                            db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_BalikJournalDetail"));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, dr["RowID"]));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RowIDPenjualan", SqlDbType.UniqueIdentifier, RowID_BalikJournalHPP));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@HRecordID", SqlDbType.VarChar, RecordIDJournal));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@RecordID", SqlDbType.VarChar, Tools.CreateFingerPrint()));
                            db.Commands[Counterdb].Parameters.Add(new Parameter("@CreatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            Counterdb++;
                        }
                    }

                    #endregion

                    //Menyimpan data penjualan ke PenjualanDeleted kemudian data penjualan menghapusnya
                    db.Commands.Add(db.CreateCommand("usp_PenjualanBaru_SaveDelete"));
                    db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID));
                    db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID_BalikJournal", SqlDbType.UniqueIdentifier, RowID_BalikJournal));
                    db.Commands[Counterdb].Parameters.Add(new Parameter("@RowID_BalikJournalHPP", SqlDbType.UniqueIdentifier, RowID_BalikJournalHPP));
                    db.Commands[Counterdb].Parameters.Add(new Parameter("@KetBatal", SqlDbType.VarChar, txt_KetPembatalan.Text));
                    db.Commands[Counterdb].Parameters.Add(new Parameter("@DeletedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    Counterdb++;

                    db.BeginTransaction();
                    for (int i = 0; i < Counterdb; i++)
                    {
                        db.Commands[i].ExecuteNonQuery();
                    }
                    db.CommitTransaction();

                    MessageBox.Show("Anda berhasil membatalkan penjualan.");

                    if (this.Caller is frmPenjualanBrowseTLA)
                    {
                        frmPenjualanBrowseTLA frmCaller = (frmPenjualanBrowseTLA)this.Caller;
                        frmCaller.RefreshData();
                    }
                    else
                    if (this.Caller is frmPenjualanBrowseADS)
                    {
                        frmPenjualanBrowseADS frmCaller = (frmPenjualanBrowseADS)this.Caller;
                        frmCaller.RefreshData();
                    }
                    else
                    if (this.Caller is frmPenjualanBrowse)
                    {
                        frmPenjualanBrowse frmCaller = (frmPenjualanBrowse)this.Caller;
                        frmCaller.RefreshData();
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
                Error.LogError(ex);
            }
            finally
            {
            }
        }
コード例 #18
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (validateSave())
            {
                Database db = new Database(GlobalVar.DBShowroom);
                Database dbf = new Database(GlobalVar.DBFinanceOto);
                int      counterdb = 0, counterdbf = 0;
                try
                {
                    String tempBentukPenerimaan = "";
                    int    bentukpembayaran     = 0;
                    switch (cboBentukPembayaran.SelectedIndex)
                    {
                    case 0:     // kalau kas
                        tempBentukPenerimaan = "K";
                        bentukpembayaran     = 1;
                        break;

                    case 1:     // kalau transfer
                        tempBentukPenerimaan = "B";
                        bentukpembayaran     = 2;
                        break;

                    case 2:     // kalau giro
                        tempBentukPenerimaan = "G";
                        bentukpembayaran     = 3;
                        break;  // karena lagi ngga ada giro makanya geser 1

                    case 3:     // kalau titipan
                        tempBentukPenerimaan = "K";
                        bentukpembayaran     = 4;
                        break;
                    }
                    if (tempBentukPenerimaan == "G" || bentukpembayaran == 3) // maka giro
                    {
                        String NoTransTitipan = Numerator.NextNumber("NTP");
                        penerimaanTitipanInsert(ref db, ref counterdb, PenerimaanUMBungaNewRowID, bentukpembayaran, NoTransTitipan);
                    }
                    else
                    {
                        // buat Guid PenerimaanUang untuk UMBunga nya
                        Guid penerimaanUangRowID_UMBunga = Guid.NewGuid();
                        Guid penerimaanPBLRowID          = Guid.NewGuid();

                        String NoTransUMBunga = Numerator.NextNumber("NKU");
                        // masukkan ke Penerimaan UMBunga
                        penerimaanUMBungaInsert(ref db, ref counterdb, PenerimaanUMBungaNewRowID, _penerimaanUMRowID,
                                                Convert.ToDouble(txtnominal.Text.ToString()), // ( - Convert.ToDouble(txtpotongan.Text.ToString())
                                                penerimaanPBLRowID, penerimaanUangRowID_UMBunga, bentukpembayaran, NoTransUMBunga);

                        // kalo pake titipan ngga perlu masukkin data ke penerimaanUang
                        if (cboBentukPembayaran.Text.ToLower() == "titipan")
                        {
                            // kalo pake titipan cukup masukkin ke titipan iden
                            penerimaanTitipanIdenInsert(ref db, ref counterdb);
                        }
                        else
                        {
                            // hanya buat ke penerimaan uang, kalau nominalnya > 0 pembayarannya
                            if (Convert.ToDouble(Tools.isNull(txtnominal.Text, 0).ToString()) > 0 &&
                                (cboTipeTransaksi.SelectedIndex == 0 || cboTipeTransaksi.SelectedIndex == 1)
                                )
                            {
                                // buat no trans penerimaanUang nya dulu
                                Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                                String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                       "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                       string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                       , 4, false, true);
                                penerimaanUangInsert(ref dbf, ref counterdbf, lookUpRekening1.RekeningRowID, penerimaanUangRowID_UMBunga, lblNoTrans.Text,
                                                     Convert.ToDecimal(txtnominal.Text), // ngga usah dipotong, yg masuk memang sesuai nominal - Convert.ToDecimal(txtpotongan.Text))
                                                     " - UMBunga", NoTransPenerimaan);
                            }
                            // buat masukkin ke Pembulatan
                            if (Convert.ToDouble(Tools.isNull(txtNominalPembulatan.Text, 0).ToString()) > 0)
                            {
                                Database dbfNumeratorsub      = new Database(GlobalVar.DBFinanceOto);
                                String   NoTransPenerimaanPBL = Numerator.GetNomorDokumen(dbfNumeratorsub, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                          "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                          string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                          , 4, false, true);
                                penerimaanPembulatanInsert(ref dbf, ref counterdbf, lookUpRekening1.RekeningRowID, penerimaanPBLRowID, NoTransPenerimaanPBL);
                            }
                        }
                    }

                    db.BeginTransaction();
                    dbf.BeginTransaction();
                    int looper = 0;
                    for (looper = 0; looper < counterdb; looper++)
                    {
                        db.Commands[looper].ExecuteNonQuery();
                    }
                    for (looper = 0; looper < counterdbf; looper++)
                    {
                        dbf.Commands[looper].ExecuteNonQuery();
                    }
                    db.CommitTransaction();
                    dbf.CommitTransaction();
                    MessageBox.Show("Data berhasil diproses.");

                    this.Close();
                }
                catch (Exception ex)
                {
                    db.RollbackTransaction();
                    dbf.RollbackTransaction();
                    MessageBox.Show("Data tidak berhasil diproses. " + ex.Message);
                }
            }
        }
コード例 #19
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (ValidateSave())
            {
                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    MessageBox.Show("Tidak bisa menggunakan giro!");
                    return;
                }

                Database db = new Database();
                Database dbf = new Database(GlobalVar.DBFinanceOto);
                int      counterdb = 0, counterdbf = 0;
                Guid     PenerimaanUMRowID   = Guid.NewGuid();
                Guid     PenerimaanUangRowID = Guid.NewGuid();
                _rowID = PenerimaanUMRowID;
                int    bentukPembayaran = 1;
                string bentukPenerimaan = "K";
                switch (cbxBentukPembayaran.SelectedIndex)
                {
                case 0:     // kalau kas
                    bentukPenerimaan = "K";
                    bentukPembayaran = 1;
                    break;

                case 1:      // kalau transfer
                    bentukPenerimaan = "B";
                    bentukPembayaran = 2;
                    break;

                case 2:      // kalau giro
                    bentukPenerimaan = "G";
                    bentukPembayaran = 3;
                    break;

                case 3:      // kalau potongan pembelian
                    bentukPenerimaan = "K";
                    bentukPembayaran = 5;
                    break;
                }

                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "potongan pembelian")
                {
                }
                else if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    // NTP untuk kode dokumen titipan , seperti giro
                    txtNoTrans.Text  = Numerator.NextNumber("NTP");
                    bentukPembayaran = 3;
                }
                else
                {
                    // NKJ untuk kode dokumen non giro
                    txtNoTrans.Text = "K" + Numerator.NextNumber("NKJ");
                }

                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                    {
                        penerimaanTitipanInsert(ref db, ref counterdb, PenerimaanUMRowID, bentukPembayaran);
                    }
                    else
                    {
                        penerimaanUMInsert(ref db, ref counterdb, PenerimaanUMRowID, bentukPembayaran, PenerimaanUangRowID);

                        if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "potongan pembelian")
                        {
                            penerimaanPotonganPembelian(ref db, ref counterdb);
                        }
                        else
                        {
                            Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                   "/B" + bentukPenerimaan.Trim() + "M/" +
                                                                                   string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                   , 4, false, true);
                            penerimaanUangInsert(ref dbf, ref counterdbf, PenerimaanUangRowID, NoTransPenerimaan);
                        }
                    }

                    db.BeginTransaction();
                    dbf.BeginTransaction();
                    int looper = 0;
                    for (looper = 0; looper < counterdb; looper++)
                    {
                        db.Commands[looper].ExecuteNonQuery();
                    }
                    for (looper = 0; looper < counterdbf; looper++)
                    {
                        dbf.Commands[looper].ExecuteNonQuery();
                    }
                    db.CommitTransaction();
                    dbf.CommitTransaction();

                    String messageTemp;
                    messageTemp = "Data berhasil ditambahkan. \n";
                    MessageBox.Show(messageTemp);
                    this.Close();
                }
                catch (Exception ex)
                {
                    db.RollbackTransaction();
                    dbf.RollbackTransaction();
                    MessageBox.Show("Data gagal ditambahkan !\n " + ex.Message);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
コード例 #20
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            DateTimeFormatInfo dfi   = DateTimeFormatInfo.CurrentInfo;
            DateTime           date  = GlobalVar.GetServerDate;
            Calendar           cal   = dfi.Calendar;
            int     mingguKe         = cal.GetWeekOfYear(date, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
            Decimal decNilaiBGC      = 0;
            Decimal decNilaiNominal  = 0;
            int     bentukPembayaran = 1;

            System.Guid rekeningPembayaranRowID = System.Guid.Empty;

            Database db = new Database();
            Database dbf = new Database(GlobalVar.DBFinanceOto);
            int      counterdb = 0, counterdbf = 0;

            try
            {
                if (ValidateSave())
                {
                }
                else
                {
                    return;
                }

                this.Cursor     = Cursors.WaitCursor;
                decNilaiNominal = Convert.ToDecimal(txtNominal.Text);

                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "transfer")
                {
                    bentukPembayaran        = 2;
                    rekeningPembayaranRowID = lookUpRekening1.RekeningRowID;
                }
                else if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    bentukPembayaran = 3;
                    decNilaiBGC      = Convert.ToDecimal(txtNominal.Text);
                    decNilaiNominal  = 0;
                }

                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    // NTP untuk kode dokumen titipan , seperti giro
                    lblNoTrans.Text = Numerator.NextNumber("NTP");
                }
                else
                {
                    // NKJ untuk kode dokumen non giro
                    lblNoTrans.Text = "K" + Numerator.NextNumber("NKJ");
                }

                Guid penerimaanUangRowID;
                Guid penerimaanPBLRowID;
                penerimaanPBLRowID  = Guid.NewGuid();
                penerimaanUangRowID = Guid.NewGuid();

                if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                {
                    penerimaanTitipanInsert(ref db, ref counterdb, decNilaiBGC);
                }
                else
                {
                    penerimaanAdministrasiInsert(ref db, ref counterdb, decNilaiBGC, decNilaiNominal, rekeningPembayaranRowID, penerimaanUangRowID, penerimaanPBLRowID);

                    //pembayaran ambil dari titipan
                    if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "titipan")
                    {
                        penerimaanTitipanIdenInsert(ref db, ref counterdb);
                    }
                    // selain pembayaran dari giro dan titipan buat data penerimaan uang
                    if (cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "titipan" || cbxBentukPembayaran.SelectedItem.ToString().ToLower() == "giro")
                    {
                    }
                    else
                    {
                        // hanya insert ke penerimaan uang kalo bukan giro dan bukan titipan

                        // buat no Bukti PenerimaanUang baru
                        String tempBentukPenerimaan = "";

                        switch (bentukPembayaran)
                        {
                        case 1:     // kalau kas
                            tempBentukPenerimaan = "K";
                            break;

                        case 2:     // kalau transfer
                            tempBentukPenerimaan = "B";
                            break;

                        case 3:     // kalau giro
                            tempBentukPenerimaan = "G";
                            break;

                        case 4:     // kalau titipan
                            tempBentukPenerimaan = "K";
                            break;
                        }
                        Database dbfNumerator      = new Database(GlobalVar.DBFinanceOto);
                        String   NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                               "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                               string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                               , 4, false, true);

                        penerimaanUangInsert(ref dbf, ref counterdbf, rekeningPembayaranRowID, penerimaanUangRowID, NoTransPenerimaan);

                        // kalo nominal pembulatannya ngga 0, masukkin juga ke penerimaanUang
                        if (Convert.ToDouble(Tools.isNull(txtNominalPembulatan.Text, 0).ToString()) > 0)
                        {
                            Database dbfNumeratorsub      = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaanPBL = Numerator.GetNomorDokumen(dbfNumeratorsub, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                      "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                      string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                      , 4, false, true);

                            penerimaanPembulatanInsert(ref dbf, ref counterdbf, rekeningPembayaranRowID, penerimaanPBLRowID, NoTransPenerimaanPBL);
                        }
                    }
                }
                db.BeginTransaction();
                dbf.BeginTransaction();
                int looper = 0;
                for (looper = 0; looper < counterdb; looper++)
                {
                    db.Commands[looper].ExecuteNonQuery();
                }
                for (looper = 0; looper < counterdbf; looper++)
                {
                    dbf.Commands[looper].ExecuteNonQuery();
                }
                db.CommitTransaction();
                dbf.CommitTransaction();
                MessageBox.Show("Data berhasil ditambahkan");
                this.Close();
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
                dbf.RollbackTransaction();
                MessageBox.Show("Data gagal ditambahkan !\n " + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }