Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }