Beispiel #1
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (CabangDKN.Text == "")
            {
                MessageBox.Show("Cabang belum diisi.");
                CabangDKN.Focus();
                return;
            }

            if (tbRpIdentifikasi.GetDoubleValue == 0)
            {
                MessageBox.Show("Rp Identifikasi Tidak Boleh 0.");
                tbRpIdentifikasi.Focus();
                return;
            }

            if (tbRpIdentifikasi.GetDoubleValue > jumlah)
            {
                MessageBox.Show("Rp Identifikasi Tidak Boleh lebih dari " + jumlah.ToString("#,###"));
                tbRpIdentifikasi.Focus();
                return;
            }

            cabang = CabangDKN.Text;
            double rpIdentifikasi = tbRpIdentifikasi.GetDoubleValue;

            DataTable dtCek = new DataTable();

            dtCek = DKN.CekLinkDKN(refRowIDHeader, cabang);


            Guid   _rowID    = new Guid();
            String _recordID = "";

            using (Database db = new Database(GlobalVar.DBFinance))
            {
                db.BeginTransaction();
                if (dtCek.Rows.Count == 0)
                {
                    _rowID    = Guid.NewGuid();
                    _recordID = refRecordIDHeader.Trim() + cabang.Substring(0, 2);
                    DKN.DKNInsert(db, _rowID, _recordID, DK, refTipe, CD, src, DateTime.Today, cabang, refNoBukti, refRowIDHeader);
                }
                else
                {
                    DataTable dtCekDet = new DataTable();
                    dtCekDet = dtCek.Copy();
                    dtCekDet.DefaultView.RowFilter = "RefRowID='" + refRowIDDetail.ToString() + "'";
                    if (dtCekDet.DefaultView.Count > 0)
                    {
                        MessageBox.Show("Sudah Pernah Link ke Cabang " + cabang + ".");
                        return;
                    }
                    _rowID    = (Guid)dtCek.Rows[0][0];
                    _recordID = dtCek.Rows[0][1].ToString();
                }
                DKN.DKNDetailInsert(db, _rowID, _recordID, noPerkiraan, uraian, rpIdentifikasi, refRowIDDetail, refRecordIDDetail.Trim() + cabang.Substring(0, 2));

                DKN.UpdateKodeLink(db, refRowIDDetail, "#", namaSP, "");
                db.CommitTransaction();
            }
            this.Close();
        }
Beispiel #2
0
        private void cmdHI_Click(object sender, EventArgs e)
        {
            string noPerkiraan = gridDetail.SelectedCells[0].OwningRow.Cells["dtlNoPerkiraan"].Value.ToString();
            Guid   _rowIDH     = (Guid)gridHeader.SelectedCells[0].OwningRow.Cells["hdrRowID"].Value;
            string tipe        = gridHeader.SelectedCells[0].OwningRow.Cells["hdrTipe"].Value.ToString();
            Guid   _rowIDD     = (Guid)gridDetail.SelectedCells[0].OwningRow.Cells["dtlRowID"].Value;
            Double jumlah      = Convert.ToDouble(gridDetail.SelectedCells[0].OwningRow.Cells["dtlDebet"].Value.ToString());
            Double jumlahLink  = 0;
            Double jumlahSisa  = 0;
            string _recordIDH  = gridHeader.SelectedCells[0].OwningRow.Cells["hdrRecordID"].Value.ToString();
            string _recordIDD  = gridDetail.SelectedCells[0].OwningRow.Cells["dtlRecordID"].Value.ToString();
            string namaSP      = "usp_VoucherJournalDetail_Update";
            string _noPerk;

            if (tipe.Trim() != "UM")
            {
                return;
            }

            try
            {
                //CEK PERNAH LINK?
                string _kode = gridDetail.SelectedCells[0].OwningRow.Cells["dtlLKode"].Value.ToString().Trim();
                if (_kode != "") //PERNAH LINK
                {
                    //AMBIL DATA LINK, CEK JUMLAH YG PERNAH D LINK
                    DataTable dtCek = new DataTable();
                    dtCek      = DKN.CekLinkDKNDetail(_rowIDD);
                    jumlahLink = Convert.ToDouble(dtCek.Compute("Sum(Jumlah)", ""));
                    // JIKA JUMLAH SUDAH FULL, UNLINK?
                    if (jumlahLink >= jumlah)
                    {
                        if (MessageBox.Show("Sudah di Link Full. \nHapus Link?", "Hapus Link DKN", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            //UNLINK DKN
                            using (Database db = new Database(GlobalVar.DBName))
                            {
                                db.BeginTransaction();
                                DKN.UnlinkDKN(db, _rowIDD);
                                DKN.UpdateKodeLink(db, _rowIDD, "", namaSP, "?");
                                db.CommitTransaction();
                            }
                            MessageBox.Show("Unlink DKN Berhasil.");
                            return;
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                _noPerk = Perkiraan.GetPerkiraanKoneksiDetail("HI11").Rows[0]["NoPerkiraan"].ToString();

                if (noPerkiraan != _noPerk)
                {
                    if (MessageBox.Show("No Perkiraan Bukan No Perkiraan HI.\nUbah No Perkiraan Menjadi No Perkiraan HI?\n" + _noPerk, "", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        using (Database db = new Database(GlobalVar.DBName))
                        {
                            db.Commands.Add(db.CreateCommand("usp_VoucherJournalDetail_Update"));
                            db.Commands[0].Parameters.Add(new Parameter("@NoPerkiraan", SqlDbType.VarChar, _noPerk));
                            db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowIDD));
                            db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();
                        }

                        RefreshDetail();
                        FindRowDetail("dtlRowID", _rowIDD.ToString());
                        noPerkiraan = _noPerk;
                    }
                    else
                    {
                        return;
                    }
                }

                DateTime tglBukti = (DateTime)gridHeader.SelectedCells[0].OwningRow.Cells["hdrTglVoucher"].Value;
                string   noBukti  = gridHeader.SelectedCells[0].OwningRow.Cells["hdrNoVoucher"].Value.ToString();
                string   uraian   = gridDetail.SelectedCells[0].OwningRow.Cells["dtlKeterangan"].Value.ToString();
                jumlahSisa = jumlah - jumlahLink;
                frmBuktiHILink frm = new frmBuktiHILink(this, "D", "VJU", "E", "IND", tglBukti, noBukti, _rowIDH, noPerkiraan, uraian, jumlahSisa, _rowIDD, "usp_VoucherJournalDetail_Update", _recordIDH, _recordIDD);
                frm.ShowDialog();
            }
            catch (SqlException ex)
            {
                Error.LogError(ex);
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }
Beispiel #3
0
        private void cmdHI_Click(object sender, EventArgs e)
        {
            try
            {
                string noPerkiraan = dgDetailBKK.SelectedCells[0].OwningRow.Cells["noPerkiraan"].Value.ToString();
                Guid   _rowIDH     = (Guid)dgHeaderBKK.SelectedCells[0].OwningRow.Cells["rowID"].Value;
                Guid   _rowIDD     = (Guid)dgDetailBKK.SelectedCells[0].OwningRow.Cells["rowIDD"].Value;
                string _recordIDH  = dgHeaderBKK.SelectedCells[0].OwningRow.Cells["RecordID"].Value.ToString();
                string _recordIDD  = dgDetailBKK.SelectedCells[0].OwningRow.Cells["RecordIDD"].Value.ToString();
                Double jumlah      = Convert.ToDouble(dgDetailBKK.SelectedCells[0].OwningRow.Cells["Jumlah"].Value);
                Double jumlahLink  = 0;
                Double jumlahSisa  = 0;
                string namaSP      = "usp_BuktiDetail_Update";

                //CEK PERNAH LINK?
                string _kode = dgDetailBKK.SelectedCells[0].OwningRow.Cells["Kode"].Value.ToString().Trim();
                if (_kode != "") //PERNAH LINK
                {
                    //AMBIL DATA LINK, CEK JUMLAH YG PERNAH D LINK
                    DataTable dtCek = new DataTable();
                    dtCek      = DKN.CekLinkDKNDetail(_rowIDD);
                    jumlahLink = Convert.ToDouble(dtCek.Compute("Sum(Jumlah)", ""));
                    // JIKA JUMLAH SUDAH FULL, UNLINK?
                    DialogResult dr = MessageBox.Show("Sudah di Link. \nBatalkan Link?", "Hapus Link DKN", MessageBoxButtons.YesNoCancel);
                    if (dr == DialogResult.Yes)
                    {
                        //UNLINK DKN
                        using (Database db = new Database(GlobalVar.DBFinance))
                        {
                            db.BeginTransaction();
                            DKN.UnlinkDKN(db, _rowIDD);
                            DKN.UpdateKodeLink(db, _rowIDD, "", namaSP, "?");
                            db.CommitTransaction();
                        }
                        MessageBox.Show("Unlink DKN Berhasil.");
                        DetailRowRefresh(_rowIDD);
                        return;
                    }
                    else if (dr == DialogResult.No)
                    {
                        if (jumlahLink >= jumlah)
                        {
                            MessageBox.Show("Sudah Link Full. \nTidak bisa tambah link.");
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                string _noPerk;
                _noPerk = Perkiraan.GetPerkiraanKoneksiDetail("HI11").Rows[0]["NoPerkiraan"].ToString();
                if (noPerkiraan != _noPerk)
                {
                    if (MessageBox.Show("No Perkiraan Bukan No Perkiraan HI.\nUbah No Perkiraan Menjadi No Perkiraan HI?\n" + _noPerk, "", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        using (Database db = new Database(GlobalVar.DBFinance))
                        {
                            db.Commands.Add(db.CreateCommand("usp_BuktiDetail_Update"));
                            db.Commands[0].Parameters.Add(new Parameter("@NoPerkiraan", SqlDbType.VarChar, _noPerk));
                            db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowIDD));
                            db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();
                        }

                        DetailRowRefresh(_rowIDD);
                        noPerkiraan = _noPerk;
                    }
                    else
                    {
                        return;
                    }
                }

                DateTime tglBukti = (DateTime)dgHeaderBKK.SelectedCells[0].OwningRow.Cells["tglBukti"].Value;
                string   noBukti  = dgHeaderBKK.SelectedCells[0].OwningRow.Cells["noBukti"].Value.ToString();
                string   uraian   = dgDetailBKK.SelectedCells[0].OwningRow.Cells["Uraian"].Value.ToString();
                jumlahSisa = jumlah - jumlahLink;
                frmBuktiHILink frm = new frmBuktiHILink(this, "D", "BKK", "E", "IND", tglBukti, noBukti, _rowIDH, noPerkiraan, uraian, jumlahSisa, _rowIDD, namaSP, _recordIDH, _recordIDD);
                frm.ShowDialog();

                DetailRowRefresh(_rowIDD);
            }
            catch (SqlException ex)
            {
                Error.LogError(ex);
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }