Exemplo n.º 1
0
        private void ClearForm()
        {
            txtIdObat.Text     = "";
            id_pasien          = "";
            id_reservasi       = "";
            txtNamaPasien.Text = "";
            txtUmur.Text       = "";
            txtJenkel.Text     = "";
            txtGol.Text        = "";
            txtKeluhan.Text    = "";
            txtPekerjaan.Text  = "";
            txtNamaObat.Text   = "";
            txtJumlahObat.Text = "";
            txtSatuan.Text     = "";
            txtKeterangan.Text = "";

            dtResep.Rows.Clear();
            dataResep.ItemsSource = dtResep.DefaultView;

            DataTable dtReservasi = Kenko.getData("sp_Transaksi_Reservasi_GetData", id_dokter);

            dataReservasi.ItemsSource = dtReservasi.DefaultView;

            dataRiwayat.ItemsSource = new DataTable().DefaultView;

            DataTable dtObat = Kenko.getData("sp_Obat_Read", "");

            dataObat.ItemsSource = dtObat.DefaultView;
        }
Exemplo n.º 2
0
        private void TransaksiPembelian_Loaded(object sender, RoutedEventArgs e)
        {
            DataTable dt = Kenko.getData("sp_Kategori_Read", "");

            listKategori.ItemsSource       = dt.DefaultView;
            listKategori.DisplayMemberPath = "nama_kategori";
            listKategori.SelectedValuePath = "id_kategori";

            dtKeranjang = new DataTable();
            dtKeranjang.Columns.Add("id_obat");
            dtKeranjang.Columns.Add("nama_obat");
            dtKeranjang.Columns.Add("tgl_exp");
            dtKeranjang.Columns.Add("jumlah");
            dtKeranjang.Columns.Add("harga_total");
            dtKeranjang.Columns.Add("harga_beli");
            dtKeranjang.Columns.Add("harga_jual");

            txtKasir.Text        = "Samodra";
            txtTglTransaksi.Text = DateTime.Now.ToString("dd-MM-yyyy");

            DataTable dtSupplier = Kenko.getData("sp_Supplier_Read", "");

            cmbSupplier.ItemsSource       = dtSupplier.DefaultView;
            cmbSupplier.DisplayMemberPath = "nama_supplier";
            cmbSupplier.SelectedValuePath = "id_supplier";

            DataTable dtObat = Kenko.getData("sp_Obat_Read", "");

            dataMaster.ItemsSource = dtObat.DefaultView;
        }
Exemplo n.º 3
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext;
                FormObat    formObat    = new FormObat("Edit", dataRowView[1].ToString());

                formObat.txtNamaObat.Text           = dataRowView[2].ToString();
                formObat.cmbKategori.SelectedValue  = dataRowView[3].ToString();
                formObat.cmbSatuan.SelectedValue    = dataRowView[4].ToString();
                formObat.txtTglExpired.SelectedDate = DateTime.Parse(dataRowView[6].ToString());
                formObat.txtStok.Text      = dataRowView[7].ToString();
                formObat.txtHargaBeli.Text = Kenko.getNumber1(dataRowView[8].ToString());
                formObat.txtHargaJual.Text = Kenko.getNumber1(dataRowView[9].ToString());
                formObat.txtHet.Text       = Kenko.getNumber1(dataRowView[10].ToString());
                formObat.txtProdusen.Text  = dataRowView[11].ToString();
                formObat.txtDeskripsi.Text = dataRowView[12].ToString();

                formObat.ShowDialog();

                RefreshDataGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Exemplo n.º 4
0
        private void saveObat(DataRow row, string no_pembelian)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);

            SqlCommand cmd = new SqlCommand("sp_Transaksi_Beli_Obat", connection);

            cmd.CommandType = CommandType.StoredProcedure;

            string id_obat2 = Kenko.generateId("OB", "sp_Obat_GetLast");

            cmd.Parameters.AddWithValue("no_pembelian", no_pembelian);
            cmd.Parameters.AddWithValue("id_obat1", row["id_obat"].ToString());
            cmd.Parameters.AddWithValue("id_obat2", id_obat2);
            cmd.Parameters.AddWithValue("nama_obat", row["nama_obat"].ToString());
            cmd.Parameters.AddWithValue("tgl_expired", row["tgl_exp"].ToString());
            cmd.Parameters.AddWithValue("jumlah_beli", row["jumlah"].ToString());
            cmd.Parameters.AddWithValue("harga_beli", row["harga_beli"].ToString());
            cmd.Parameters.AddWithValue("harga_jual", row["harga_jual"].ToString());
            cmd.Parameters.AddWithValue("total_harga", Kenko.getNumber(row["harga_total"].ToString()));


            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();

                connection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data gagal disimpan : " + ex.Message, "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 5
0
        private void AddPrintData(string no_penjualan)
        {
            StrukDataset.PenjualanRow penjualanRow = penjualans.NewPenjualanRow();
            penjualanRow.no_penjualan  = no_penjualan;
            penjualanRow.nama_kasir    = txtKasir.Text;
            penjualanRow.tgl_beli      = DateTime.Now;
            penjualanRow.nama_member   = txtNamaMember.Text;
            penjualanRow.total_harga   = lblSubtotal.Content.ToString();
            penjualanRow.total_item    = lblJumlahBarang.Content.ToString();
            penjualanRow.total         = lblTotalPembayaran.Text;
            penjualanRow.poin_terpakai = Convert.ToInt32(txtPoin.Text);
            penjualanRow.tunai         = Kenko.formatCurrency(double.Parse(Kenko.getNumber2(txtBayar.Text)));
            penjualanRow.kembalian     = lblKembalian.Content.ToString();

            penjualans.AddPenjualanRow(penjualanRow);

            foreach (DataRow row in dtPenjualan.Rows)
            {
                double harga = double.Parse(Kenko.getNumber(row["harga"].ToString()));
                StrukDataset.Detail_PenjualanRow detail_PenjualanRow = detail_Penjualans.NewDetail_PenjualanRow();
                detail_PenjualanRow.nama_obat = row["nama_obat"].ToString();
                detail_PenjualanRow.jumlah    = row["jumlah"].ToString();
                detail_PenjualanRow.harga     = Kenko.formatCurrency(harga);
                detail_Penjualans.AddDetail_PenjualanRow(detail_PenjualanRow);
            }
        }
Exemplo n.º 6
0
 private void ClearDokter()
 {
     //cmbDokter.SelectedIndex = 0;
     txtSpesialisasi.Text  = "";
     lblAntrian.Text       = Kenko.getAntrian();
     lblNamaDokter.Content = "-";
     txtKeluhan.Text       = "";
 }
Exemplo n.º 7
0
        private void btnTambahGrid_Click(object sender, RoutedEventArgs e)
        {
            DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext;

            FormBeliObat fbo = new FormBeliObat(dataRowView[2].ToString(), dataRowView[1].ToString());

            fbo.ShowDialog();


            if (fbo.result)
            {
                double total = fbo.jumlah_beli * fbo.harga_beli;

                if (dtKeranjang.Rows.Count > 0)
                {
                    bool found = false;
                    for (int i = 0; i < dtKeranjang.Rows.Count; i++)
                    {
                        DataRow row = dtKeranjang.Rows[i];
                        if (row["id_obat"].ToString() == dataRowView[1].ToString() && row["tgl_exp"].ToString() == fbo.tgl_exp)
                        {
                            row["jumlah"]      = Convert.ToInt32(row["jumlah"].ToString()) + Convert.ToInt32(fbo.jumlah_beli);
                            row["harga_total"] = Kenko.formatCurrency(Convert.ToDouble(Kenko.getNumber(row["harga_total"].ToString())) + total);


                            jumlahBarang            = jumlahBarang + Convert.ToInt32(fbo.jumlah_beli);
                            subtotal                = subtotal + total;
                            lblJumlahBarang.Content = jumlahBarang;
                            lblSubtotal.Content     = Kenko.formatCurrency(subtotal);
                            lblTotalPembayaran.Text = Kenko.formatCurrency(subtotal);
                            found = true;
                        }
                    }

                    if (!found)
                    {
                        jumlahBarang = jumlahBarang + Convert.ToInt32(fbo.jumlah_beli);
                        subtotal     = subtotal + total;
                        dtKeranjang.Rows.Add(fbo.id_obat, fbo.nama_obat, fbo.tgl_exp, fbo.jumlah_beli, Kenko.formatCurrency(total), fbo.harga_beli, fbo.harga_jual);
                        lblJumlahBarang.Content = jumlahBarang;
                        lblSubtotal.Content     = Kenko.formatCurrency(subtotal);
                        lblTotalPembayaran.Text = Kenko.formatCurrency(subtotal);
                    }
                }
                else
                {
                    jumlahBarang = jumlahBarang + Convert.ToInt32(fbo.jumlah_beli);
                    subtotal     = subtotal + total;
                    dtKeranjang.Rows.Add(fbo.id_obat, fbo.nama_obat, fbo.tgl_exp, fbo.jumlah_beli, Kenko.formatCurrency(total), fbo.harga_beli, fbo.harga_jual);
                    lblJumlahBarang.Content = jumlahBarang;
                    lblSubtotal.Content     = Kenko.formatCurrency(subtotal);
                    lblTotalPembayaran.Text = Kenko.formatCurrency(subtotal);
                }

                dataKeranjang.ItemsSource = dtKeranjang.DefaultView;
            }
        }
Exemplo n.º 8
0
        private void listKategori_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int    index      = listKategori.SelectedIndex;
            string idkategori = listKategori.SelectedValue.ToString();

            SelectedMenuChange(index);

            dataMaster.ItemsSource = Kenko.getData("sp_Obat_GetKategori", idkategori).DefaultView;
        }
Exemplo n.º 9
0
        private void TransaksiReservasi_Loaded(object sender, RoutedEventArgs e)
        {
            dataMaster.ItemsSource = Kenko.getData("sp_Pasien_Read", "").DefaultView;

            cmbDokter.ItemsSource       = Kenko.getData("sp_Dokter_Read", "").DefaultView;
            cmbDokter.SelectedValuePath = "id_dokter";
            cmbDokter.DisplayMemberPath = "nama_dokter";

            txtKasir.Text        = Application.Current.Properties["nama"].ToString();
            txtTglTransaksi.Text = DateTime.Now.ToString("dd-MM-yyyy");
            lblAntrian.Text      = Kenko.getAntrian();
        }
Exemplo n.º 10
0
        private void btnHapusGrid_Click(object sender, RoutedEventArgs e)
        {
            DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext;

            subtotal                = subtotal - double.Parse(dataRowView[3].ToString());
            jumlahBarang            = jumlahBarang - int.Parse(dataRowView[2].ToString());
            lblSubtotal.Content     = Kenko.formatCurrency(subtotal);
            lblJumlahBarang.Content = jumlahBarang;
            dtPenjualan.Rows.Remove(dataRowView.Row);
            dataPenjualan.ItemsSource = dtPenjualan.DefaultView;
            lblTotalPembayaran.Text   = "0";
        }
Exemplo n.º 11
0
        private void btnBayar_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);

            SqlCommand cmd = new SqlCommand("sp_Transaksi_Penjualan", connection);

            cmd.CommandType = CommandType.StoredProcedure;

            string id_user      = Application.Current.Properties["id"].ToString();
            string no_penjualan = Kenko.generateId("PJ", "sp_Transaksi_Penjualan_GetLast");

            cmd.Parameters.AddWithValue("no_penjualan", no_penjualan);
            cmd.Parameters.AddWithValue("tgl_beli", DateTime.Now);
            cmd.Parameters.AddWithValue("total_harga", Convert.ToDouble(Kenko.getNumber(lblTotalPembayaran.Text)));
            cmd.Parameters.AddWithValue("id_member", (txtPoin.IsEnabled == true) ? (object)txtIdMember.Text : DBNull.Value);
            cmd.Parameters.AddWithValue("poin_terpakai", txtPoin.Text);
            cmd.Parameters.AddWithValue("id_user", id_user);


            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();

                connection.Close();

                foreach (DataRow row in dtPenjualan.Rows)
                {
                    cmd             = new SqlCommand("sp_Transaksi_Penjualan_Detail", connection);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("no_penjualan", no_penjualan);
                    cmd.Parameters.AddWithValue("id_obat", row["id_obat"].ToString());
                    cmd.Parameters.AddWithValue("jumlah", row["jumlah"].ToString());
                    cmd.Parameters.AddWithValue("total_harga", Kenko.getNumber(row["harga"].ToString()));

                    connection.Open();
                    cmd.ExecuteNonQuery();
                    connection.Close();
                }

                MessageBox.Show("Data berhasil disimpan!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                AddPrintData(no_penjualan);
                StrukPreview strukPreview = new StrukPreview(penjualans, detail_Penjualans);
                strukPreview.Close();
                NewTransaksi();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data gagal disimpan : " + ex.Message, "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 12
0
        private void btnHapusGrid_Click(object sender, RoutedEventArgs e)
        {
            DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext;


            subtotal                = subtotal - double.Parse(Kenko.getNumber(dataRowView[4].ToString()));
            jumlahBarang            = jumlahBarang - int.Parse(dataRowView[3].ToString());
            lblSubtotal.Content     = "0";
            lblJumlahBarang.Content = jumlahBarang;
            dtKeranjang.Rows.Remove(dataRowView.Row);
            dataKeranjang.ItemsSource = dtKeranjang.DefaultView;
            lblTotalPembayaran.Text   = "0";
        }
Exemplo n.º 13
0
        private void cmbDokter_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataTable dt = Kenko.getData("sp_Dokter_GetDokter", cmbDokter.SelectedValue.ToString());

            if (dt.Rows.Count > 0)
            {
                txtSpesialisasi.Text  = dt.Rows[0]["spesialisasi"].ToString();
                lblNamaDokter.Content = dt.Rows[0]["nama_dokter"].ToString();
            }
            else
            {
                MessageBox.Show("Data tidak ditemukan", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 14
0
        private void NewTransaksi()
        {
            dtKeranjang.Rows.Clear();
            lblSubtotal.Content     = 0;
            lblJumlahBarang.Content = 0;

            lblTotalPembayaran.Text   = "0";
            cmbSupplier.SelectedIndex = -1;

            string idkategori = listKategori.SelectedValue.ToString();

            subtotal     = 0;
            jumlahBarang = 0;

            dataMaster.ItemsSource = Kenko.getData("sp_Obat_GetKategori", idkategori).DefaultView;
        }
Exemplo n.º 15
0
 private void txtPoin_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (int.Parse(txtJumlahPoin.Text) < int.Parse(txtPoin.Text))
         {
             MessageBox.Show("Poin tidak mencukupi", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         else
         {
             double total = subtotal - double.Parse(txtPoin.Text);
             lblTotalPembayaran.Text = Kenko.formatCurrency(total);
             MessageBox.Show(txtPoin.Text + " telah berhasil digunakan", "Berhasil", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
 }
Exemplo n.º 16
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (cmbSupplier.SelectedIndex < 0)
            {
                MessageBox.Show("Silahkan pilih supplier terlebih dahulu", "Informasi", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else if (dtKeranjang.Rows.Count <= 0)
            {
                MessageBox.Show("Silahkan isi keranjang pembelian.", "Informasi", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);

                SqlCommand cmd = new SqlCommand("sp_Transaksi_Pembelian", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                string no_pembelian = Kenko.generateId("PB", "sp_Transaksi_Pembelian_GetLast");

                cmd.Parameters.AddWithValue("no_pembelian", no_pembelian);
                cmd.Parameters.AddWithValue("total_harga", Kenko.getNumber(lblTotalPembayaran.Text));
                cmd.Parameters.AddWithValue("id_supplier", cmbSupplier.SelectedValue);
                cmd.Parameters.AddWithValue("id_user", 2);


                try
                {
                    connection.Open();
                    cmd.ExecuteNonQuery();

                    connection.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Data gagal disimpan : " + ex.Message, "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                foreach (DataRow row in dtKeranjang.Rows)
                {
                    saveObat(row, no_pembelian);
                }

                MessageBox.Show("Data pembelian berhasil ditambahkan", "Berhasil", MessageBoxButton.OK, MessageBoxImage.Information);

                NewTransaksi();
            }
        }
Exemplo n.º 17
0
        private void TransaksiPenjualan_Loaded(object sender, RoutedEventArgs e)
        {
            DataTable dt = Kenko.getData("sp_Kategori_Read", "");

            cmbKategori.ItemsSource       = dt.DefaultView;
            cmbKategori.DisplayMemberPath = "nama_kategori";
            cmbKategori.SelectedValuePath = "id_kategori";

            dtPenjualan = new DataTable();
            dtPenjualan.Columns.Add("id_obat");
            dtPenjualan.Columns.Add("nama_obat");
            dtPenjualan.Columns.Add("jumlah");
            dtPenjualan.Columns.Add("harga");

            txtKasir.Text        = Application.Current.Properties["nama"].ToString();
            txtTglTransaksi.Text = DateTime.Now.ToString("dd-MM-yyyy");
        }
Exemplo n.º 18
0
        private bool validateAll()
        {
            bool namaPasien = Kenko.fieldRequired(txtNamaPasien.Text, lblNamaPasien);
            bool alamat     = Kenko.fieldRequired(txtAlamat.Text, lblAlamat);
            bool noTelp     = Kenko.fieldMin(txtNoTelp.Text, lblNoTelp, 11);
            bool tglLahir   = Kenko.dateRequired(txtTglLahir, lblTgl);
            bool jenkel     = Kenko.toggleRequired(lblJenkel, (bool)rdLaki.IsChecked, (bool)rdPerempuan.IsChecked);

            if (namaPasien && alamat && noTelp && tglLahir && jenkel)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 19
0
        private void TransaksiResep_Loaded(object sender, RoutedEventArgs e)
        {
            string id_dokter = Application.Current.Properties["id"].ToString();

            DataTable dtReservasi = Kenko.getData("sp_Transaksi_Reservasi_GetData", id_dokter);

            dataReservasi.ItemsSource = dtReservasi.DefaultView;

            DataTable dtObat = Kenko.getData("sp_Obat_Read", "");

            dataObat.ItemsSource = dtObat.DefaultView;

            dtResep = new DataTable();
            dtResep.Columns.Add("id_obat");
            dtResep.Columns.Add("nama_obat");
            dtResep.Columns.Add("jumlah");
            dtResep.Columns.Add("keterangan");
        }
Exemplo n.º 20
0
        private void NewTransaksi()
        {
            Baru();
            dtPenjualan.Rows.Clear();
            lblSubtotal.Content     = 0;
            lblJumlahBarang.Content = 0;
            txtPoin.Text            = "";
            lblTotalPembayaran.Text = "0";
            txtBayar.Text           = "";
            lblKembalian.Content    = 0;
            btnBayar.IsEnabled      = false;
            string idkategori = "";

            subtotal     = 0;
            jumlahBarang = 0;

            dataMaster.ItemsSource = Kenko.getData("sp_Obat_GetKategori", idkategori).DefaultView;
        }
Exemplo n.º 21
0
        private void txtBayar_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                double totalPembayaran = Convert.ToDouble(Kenko.getNumber(lblTotalPembayaran.Text));
                double bayar           = double.Parse(Kenko.getNumber2(txtBayar.Text));
                if (bayar < totalPembayaran)
                {
                    MessageBox.Show("Uang pembayaran tidak mencukupi", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    double kembalian = double.Parse(Kenko.getNumber2(txtBayar.Text)) - totalPembayaran;
                    lblKembalian.Content = Kenko.formatCurrency(kembalian);

                    btnBayar.IsEnabled = true;
                }
            }
        }
Exemplo n.º 22
0
        private void btnTambahReservasi_Click(object sender, RoutedEventArgs e)
        {
            DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext;

            id_pasien = dataRowView[4].ToString();

            id_reservasi = dataRowView[1].ToString();

            txtNamaPasien.Text = dataRowView[9].ToString();
            txtJenkel.Text     = dataRowView[10].ToString();
            txtUmur.Text       = dataRowView[16].ToString();
            txtPekerjaan.Text  = dataRowView[12].ToString();
            txtGol.Text        = dataRowView[11].ToString();

            txtKeluhan.Text = dataRowView[6].ToString();

            DataTable pasien = Kenko.getData("sp_Transaksi_Reservasi_GetPasien", id_pasien);

            dataRiwayat.ItemsSource = pasien.DefaultView;
        }
Exemplo n.º 23
0
        private void btnDaftar_Click(object sender, RoutedEventArgs e)
        {
            if (id_pasien.Text == "ID Pasien" || id_pasien.Text == "")
            {
                MessageBox.Show("Silahkan pilih pasien terlebih dahulu.", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (cmbDokter.SelectedIndex < 0)
            {
                MessageBox.Show("Silahkan pilih dokter terlebih dahulu.", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);

                SqlCommand cmd = new SqlCommand("sp_Transaksi_Reservasi", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("no_reservasi", Kenko.generateId("RV", "sp_Transaksi_Reservasi_GetLast"));
                cmd.Parameters.AddWithValue("id_dokter", cmbDokter.SelectedValue.ToString());
                cmd.Parameters.AddWithValue("id_pasien", id_pasien.Text);
                cmd.Parameters.AddWithValue("keterangan", txtKeluhan.Text);

                try
                {
                    connection.Open();
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Reservasi berhasil.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    connection.Close();
                    ClearForm();
                    formReadOnly(false);
                    ClearDokter();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Data gagal disimpan : " + ex.Message, "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemplo n.º 24
0
        private void btnCariMember_Click(object sender, RoutedEventArgs e)
        {
            if (txtIdMember.Text == "")
            {
                MessageBox.Show("Isi ID Member terlebih dahulu.", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                DataTable dt = Kenko.getData("sp_Member_GetMember", txtIdMember.Text);

                if (dt.Rows.Count > 0)
                {
                    txtIdMember.IsReadOnly = true;
                    txtNamaMember.Text     = dt.Rows[0]["nama"].ToString();
                    txtJumlahPoin.Text     = dt.Rows[0]["poin"].ToString();
                    txtPoin.IsEnabled      = true;
                }
                else
                {
                    MessageBox.Show("Data tidak ditemukan", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemplo n.º 25
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!validateAll())
            {
                MessageBox.Show("Data gagal disimpan", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);

                SqlCommand cmd = new SqlCommand("sp_Pasien_Create", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("nama_pasien", txtNamaPasien.Text);
                cmd.Parameters.AddWithValue("jenis_kelamin", Kenko.getJenkel(rdLaki));
                cmd.Parameters.AddWithValue("tgl_lahir", Kenko.FormatLocalDate(txtTglLahir.Text));
                cmd.Parameters.AddWithValue("alamat", txtAlamat.Text);
                cmd.Parameters.AddWithValue("no_telp", txtNoTelp.Text);
                cmd.Parameters.AddWithValue("golongan_darah", getGol());
                cmd.Parameters.AddWithValue("pekerjaan", String.IsNullOrEmpty(txtPekerjaan.Text) ? DBNull.Value : (object)txtPekerjaan.Text);

                try
                {
                    connection.Open();
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Data berhasil disimpan!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    connection.Close();
                    ClearForm();

                    dataMaster.ItemsSource = Kenko.getData("sp_Pasien_Read", "").DefaultView;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Data gagal disimpan : " + ex.Message, "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemplo n.º 26
0
 private void RefreshDataGrid(string cari = "")
 {
     dataMaster.ItemsSource = Kenko.getData("sp_User_Read", cari).DefaultView;
 }
Exemplo n.º 27
0
 private void txtJumlah_PreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     Kenko.numberOnlyInput(e);
 }
Exemplo n.º 28
0
        private void cmbKategori_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string idkategori = cmbKategori.SelectedValue.ToString();

            dataMaster.ItemsSource = Kenko.getData("sp_Obat_GetKategori", idkategori).DefaultView;
        }
Exemplo n.º 29
0
 private void txtBayar_TextChanged(object sender, TextChangedEventArgs e)
 {
     Kenko.textFieldCurrencyFormat(txtBayar, "");
 }
Exemplo n.º 30
0
        private void btnTambahGrid_Click(object sender, RoutedEventArgs e)
        {
            DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext;

            //Mengambil content dari dataMaster kolom 5 (jumlah)
            ContentPresenter jml = dataMaster.Columns[5].GetCellContent(dataRowView) as ContentPresenter;

            var myTemplate = jml.ContentTemplate;

            //Cek apakah myTemplate null atau tidak
            if (myTemplate != null)
            {
                TextBox jumlah = myTemplate.FindName("txtJumlah", jml) as TextBox;

                // Jika jumlah kosong
                if (jumlah.Text == "")
                {
                    MessageBox.Show("Silahkan isi jumlah beli terlebih dahulu.", "Informasi", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    // Jika stok kurang dari text jumlah
                    if (Convert.ToInt32(dataRowView[7].ToString()) < Convert.ToInt32(jumlah.Text))
                    {
                        MessageBox.Show("Stok tidak mencukupi.", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        // Menghitung total, text  jumlah * dengan harga jual
                        double total = Double.Parse(jumlah.Text) * Double.Parse(dataRowView[9].ToString());

                        // Jika keranjang ada barangnya
                        if (dtPenjualan.Rows.Count > 0)
                        {
                            bool found = false;
                            for (int i = 0; i < dtPenjualan.Rows.Count; i++)
                            {
                                DataRow row = dtPenjualan.Rows[i];
                                //jika obat dari keranjang == obat dari datagrid obat
                                if (row["id_obat"].ToString() == dataRowView[1].ToString())
                                {
                                    int jumlahPembelianKeranjang = Convert.ToInt32(row["jumlah"].ToString()) + Convert.ToInt32(jumlah.Text);

                                    // Jika jumlah pembelian di keranjang melebihi yang ada di database
                                    if (jumlahPembelianKeranjang > Convert.ToInt32(dataRowView[7].ToString()))
                                    {
                                        MessageBox.Show("Stok tidak mencukupi.", "Gagal", MessageBoxButton.OK, MessageBoxImage.Error);
                                    }
                                    else
                                    {
                                        row["jumlah"] = jumlahPembelianKeranjang;
                                        row["harga"]  = Convert.ToDouble(Kenko.getNumber(row["harga"].ToString())) + total;

                                        jumlahBarang            = jumlahBarang + Convert.ToInt32(jumlah.Text);
                                        subtotal                = subtotal + total;
                                        lblJumlahBarang.Content = jumlahBarang;
                                        lblSubtotal.Content     = Kenko.formatCurrency(subtotal);
                                        lblTotalPembayaran.Text = Kenko.formatCurrency(subtotal);
                                    }
                                    found = true;
                                }
                            }

                            //Jika tidak ada di keranjang, maka data langsung ditambahkan ke row baru,
                            //tidak mengakumulasikan jumlah barang dari keranjang
                            if (!found)
                            {
                                jumlahBarang = jumlahBarang + Convert.ToInt32(jumlah.Text);
                                subtotal     = subtotal + total;
                                dtPenjualan.Rows.Add(dataRowView[1].ToString(), dataRowView[2].ToString(), jumlah.Text, Kenko.formatCurrency(total));
                                lblJumlahBarang.Content = jumlahBarang;
                                lblSubtotal.Content     = Kenko.formatCurrency(subtotal);
                                lblTotalPembayaran.Text = Kenko.formatCurrency(subtotal);
                            }
                        }
                        else
                        {
                            jumlahBarang = jumlahBarang + Convert.ToInt32(jumlah.Text);
                            subtotal     = subtotal + total;

                            //Menambahkan baris ke dtPenjualan
                            dtPenjualan.Rows.Add(dataRowView[1].ToString(), dataRowView[2].ToString(), jumlah.Text, Kenko.formatCurrency(total));
                            lblJumlahBarang.Content = jumlahBarang;
                            lblSubtotal.Content     = Kenko.formatCurrency(subtotal);
                            lblTotalPembayaran.Text = Kenko.formatCurrency(subtotal);
                        }

                        dataPenjualan.ItemsSource = dtPenjualan.DefaultView;
                        jumlah.Text = "0";
                    }
                }
            }
            else
            {
                MessageBox.Show("Silahkan isi jumlah beli terlebih dahulu.", "Informasi", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }