Exemplo n.º 1
0
        private void txtCariObat_KeyDown(object sender, KeyEventArgs e)
        {
            // TODO : Cek Retensi dari Sini
            if (e.KeyCode == Keys.Enter)
            {
                List <string> daftarobat   = new List <string>();
                var           dh           = new dataset.yakkumdbTableAdapters.view_rse_fa_obatTableAdapter();
                var           _resepdetail = new dataset.yakkumdbTableAdapters.fa_rx_resep_dTableAdapter();
                dh.Fill(yakkumdb.view_rse_fa_obat);
                DataTable dt = dh.GetData();
                foreach (DataRow r in dt.Rows)
                {
                    daftarobat.Add(r.Field <string>(4));
                }
                _listobat = daftarobat.ToArray();

                _resepdetail.FillByNoRx(yakkumdb.fa_rx_resep_d, lblKodeRtx.Text);
                DataTable     dta         = _resepdetail.GetDataByNoRx(lblKodeRtx.Text);
                List <string> obatdiresep = new List <string>();
                foreach (DataRow rs in dta.Rows)
                {
                    obatdiresep.Add(rs.Field <string>(1));
                }
                _listobatdetil = obatdiresep.ToArray();
                if (_listobat.Contains(txtCariObat.Text.ToUpper()) == false)
                {
                    MessageBox.Show("Pastikan Nama Obat Sesuai !!", "Important Message");
                }
                //else if (_listobatdetil.Contains(txtCariObat.Text.ToUpper()) == false)
                //{ MessageBox.Show("Obat Sudah Berada di Resep, Edit untuk melakukan perubahan."); }
                else
                {
                    var _maxno = (int)_resepdetail.ScalarQueryMaxNoUrutResep(lblKodeRtx.Text) + 1;
                    //MessageBox.Show(_maxno.ToString());
                    _kodeobat = txtCariObat.Text;
                    dosis ds     = new dosis(_kodeobat, lblKodeRtx.Text, _kdokter, _maxno, _kodefornas, "", false);
                    var   result = ds.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        this.view_resepTableAdapter.Fill(this.yakkumdb.view_resep, lblKodeRtx.Text);
                        bs_view_resep.Filter = "vc_kode_rx = '" + lblKodeRtx.Text + "'";
                        dgvResep.Update();
                        dgvResep.Refresh();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void dgvResep_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //MessageBox.Show(e.ColumnIndex.ToString());
            string bt_racikan = this.dgvResep[8, e.RowIndex].Value.ToString();
            var    rxd        = new dataset.yakkumdbTableAdapters.fa_rx_resep_dTableAdapter();
            var    dtracikan  = new dataset.yakkumdbTableAdapters.fa_rx_racikanTableAdapter();
            var    _kdrxd     = this.dgvResep[5, e.RowIndex].Value.ToString();

            if (e.RowIndex < 0)
            {
                return;
            }

            //I suposed you want to handle the event for column at index 1
            if (e.ColumnIndex == 9)
            {
                _kodeobat = this.dgvResep[1, e.RowIndex].Value.ToString();


                if (bt_racikan == "False")
                {
                    dosis ds = new dosis
                                   (_kodeobat,
                                   lblKodeRtx.Text,
                                   _kdokter,
                                   (int)this.dgvResep[7, e.RowIndex].Value,
                                   _kodefornas,
                                   _kdrxd,
                                   true);
                    var result = ds.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        this.view_resepTableAdapter.Fill(this.yakkumdb.view_resep, lblKodeRtx.Text);
                        bs_view_resep.Filter = "vc_kode_rx = '" + lblKodeRtx.Text + "'";
                        dgvResep.Update();
                        dgvResep.Refresh();
                    }
                }
                if (bt_racikan == "True")
                {
                    //MessageBox.Show("Edit Racikan");
                    var temp = 2;

                    // MessageBox.Show(nurs.ToString());
                    Racikan rc = new Racikan(
                        0,
                        _kodefornas,
                        _kodeobat,
                        _kdrxd,
                        lblKodeRtx.Text,
                        this.dgvResep[7, e.RowIndex].Value.ToString(),
                        _kdokter,
                        (int)this.dgvResep[7, e.RowIndex].Value,
                        temp);
                    var result = rc.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        this.view_resepTableAdapter.Fill(this.yakkumdb.view_resep, lblKodeRtx.Text);
                        bs_view_resep.Filter = "vc_kode_rx = '" + lblKodeRtx.Text + "'";
                        dgvResep.Update();
                        dgvResep.Refresh();
                    }
                }

                //MessageBox.Show(this.dgvResep[11, e.RowIndex].Value.ToString());
                // TODO : Edit Event
                //var kdrxd = this.dgvResep[8, e.RowIndex].Value.ToString();
                //var kdrx = this.dgvResep[9, e.RowIndex].Value.ToString();
                //var nourut = Int32.Parse(this.dgvResep[10, e.RowIndex].Value.ToString());
                //var namaobat = this.dgvResep[1, e.RowIndex].Value.ToString();
                //MessageBox.Show(namaobat + kdrx+_kdokter+nourut);
                //dosis ds = new dosis(namaobat, kdrx, _kdokter, nourut);
                //var result = ds.ShowDialog();
                //if (result == DialogResult.OK)
                //{
                //    this.view_resepTableAdapter.Fill(this.yakkumdb.view_resep, lblKodeRtx.Text);
                //    dgvResep.Update();
                //    dgvResep.Refresh();
                //}
            }

            if (e.ColumnIndex == 10)
            {
                // Deleted event
                var val     = this.dgvResep[5, e.RowIndex].Value.ToString();
                var no_urut = Int32.Parse(this.dgvResep[7, e.RowIndex].Value.ToString());
                rxd.DeleteObat(val, no_urut);
                if (bt_racikan == "True")
                {
                    dtracikan.DeleteQueryByKodeRXD(_kdrxd);
                }

                this.view_resepTableAdapter.Fill(this.yakkumdb.view_resep, lblKodeRtx.Text);
                dgvResep.Update();
                dgvResep.Refresh();
                // MessageBox.Show("Deleted! " + val);
            }
        }