Exemplo n.º 1
0
        public void BukaTransaksiNonRWI(string kodeUnit, string nomorTransaksi, DateTime tglKunjungan)
        {
            Koneksi koneksi = new Koneksi();
            DCMedismartToolsDataContext context          = koneksi.DataContext;
            TransactionScope            transactionScope = new TransactionScope();

            using (transactionScope)
            {
                try
                {
                    var selectedKunjungan = (from k in context.KUNJUNGANs
                                             where k.KD_PASIEN == pasien.KD_PASIEN &&
                                             k.TGL_MASUK == tglKunjungan
                                             select k
                                             ).FirstOrDefault();

                    var selectedTransaksi = (from transaksi in context.TRANSAKSIs
                                             where transaksi.KD_PASIEN == pasien.KD_PASIEN &&
                                             transaksi.NO_TRANSAKSI == nomorTransaksi
                                             select transaksi
                                             ).FirstOrDefault();

                    selectedKunjungan.TGL_KELUAR = null;
                    selectedKunjungan.JAM_KELUAR = null;

                    selectedTransaksi.CO_STATUS = false;
                    selectedTransaksi.TGL_CO    = null;

                    context.SubmitChanges();

                    transactionScope.Complete();

                    MessageBox.Show("Transaksi sudah dibuka", "Information");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    context.Dispose();
                    transactionScope.Dispose();
                }
            }
        }
Exemplo n.º 2
0
        public void BukaTransaksiRWI(string kodeUnit, string nomorTransaksi, DateTime tanggalMasuk)
        {
            Koneksi koneksi = new Koneksi();
            DCMedismartToolsDataContext context          = koneksi.DataContext;
            TransactionScope            transactionScope = new TransactionScope();

            KUNJUNGAN selectedKunjungan;
            TRANSAKSI selectedTransaksi;
            NGINAP    selectedNginap;

            using (transactionScope)
            {
                try
                {
                    selectedKunjungan = (from k in context.KUNJUNGANs
                                         where k.KD_PASIEN == pasien.KD_PASIEN &&
                                         k.TGL_MASUK.Date == tanggalMasuk.Date
                                         select k
                                         ).FirstOrDefault();

                    selectedTransaksi = (from transaksi in context.TRANSAKSIs
                                         where transaksi.KD_PASIEN == pasien.KD_PASIEN &&
                                         transaksi.KD_UNIT == kodeUnit &&
                                         transaksi.NO_TRANSAKSI == nomorTransaksi && transaksi.CO_STATUS == true
                                         select transaksi
                                         ).FirstOrDefault();

                    selectedNginap = (from nginap in context.NGINAPs
                                      where nginap.KD_PASIEN == pasien.KD_PASIEN &&
                                      nginap.TGL_INAP == selectedTransaksi.TGL_TRANSAKSI &&
                                      nginap.TGL_KELUAR == selectedTransaksi.TGL_CO
                                      select nginap
                                      ).FirstOrDefault();

                    KAMAR_INDUK selectedKamarInduk = (from kamarInduk in context.KAMAR_INDUKs
                                                      where kamarInduk.NO_KAMAR == selectedNginap.NO_KAMAR
                                                      select kamarInduk
                                                      ).FirstOrDefault();

                    selectedKunjungan.TGL_KELUAR = null;
                    selectedKunjungan.JAM_KELUAR = null;

                    selectedTransaksi.CO_STATUS = false;
                    selectedTransaksi.TGL_CO    = null;

                    selectedNginap.TGL_KELUAR = null;
                    selectedNginap.JAM_KELUAR = null;
                    selectedNginap.AKHIR      = true;

                    PASIEN_INAP pasienInap = new PASIEN_INAP();
                    pasienInap.KD_KASIR     = "02";
                    pasienInap.KD_UNIT      = kodeUnit;
                    pasienInap.NO_TRANSAKSI = selectedTransaksi.NO_TRANSAKSI;
                    pasienInap.NO_KAMAR     = selectedNginap.NO_KAMAR;
                    pasienInap.KD_SPESIAL   = selectedNginap.KD_SPESIAL;

                    context.PASIEN_INAPs.InsertOnSubmit(pasienInap);

                    selectedKamarInduk.DIGUNAKAN++;

                    context.SubmitChanges();

                    transactionScope.Complete();

                    MessageBox.Show("Transaksi sudah dibuka", "Information");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    context.Dispose();
                    transactionScope.Dispose();
                }
            }
        }