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); } }
private void btnSave_Click(object sender, EventArgs e) { switch (cekkelengkapan()) { case false: //MessageBox.Show("Salah"); break; case true: //MessageBox.Show("Benar"); var dt = new dataset.yakkumdbTableAdapters.fa_rx_racikanTableAdapter(); dt.DeleteQueryByKodeRXD(_koderxd); for (int i = 0; i < dgvRacik.RowCount - 1; i++) { dt.InsertQuery( _koderxd, i + 1, dgvRacik.Rows[i].Cells[5].Value.ToString(), dgvRacik.Rows[i].Cells[1].Value.ToString(), dgvRacik.Rows[i].Cells[2].Value.ToString(), dgvRacik.Rows[i].Cells[3].Value.ToString() ); //if (dgvRacik.Rows[i].Cells[2].Value.ToString() == "" || string.IsNullOrEmpty(dgvRacik.Rows[i].Cells[3].Value as string)) //{ // MessageBox.Show("Masukan Obat Racikan"); //} //else //{ //dt.InsertQuery( // _koderxd, // i + 1, // dgvRacik.Rows[i].Cells[5].Value.ToString(), // dgvRacik.Rows[i].Cells[1].Value.ToString(), // dgvRacik.Rows[i].Cells[2].Value.ToString(), // dgvRacik.Rows[i].Cells[3].Value.ToString() //); //} } var dh = new dataset.yakkumdbTableAdapters.fa_rx_resep_dTableAdapter(); if (_template == 2) { dh.UpdateQuery( Double.Parse(txtJumlah.Text), cmbSatuan.Text, txtdd1.Text, txtdd2.Text, cmbSatuanDosis.Text, txtSignalain.Text, _koderxd, _nourut ); } else { dh.InsertQuery (_koderx, _koderxd, "999999", _kracik, true, txtSignalain.Text, _btIter, _jmliter, false, Int32.Parse(txtJumlah.Text), _kdokter, _nourut, txtdd1.Text, txtdd2.Text, cmbSatuan.Text, _namaracikan, cmbSatuanDosis.Text ); } this.DialogResult = DialogResult.OK; this.Close(); break; } //if(cekkelengkapan() == false) { MessageBox.Show("Salah"); } //if (cekkelengkapan() == true) //{ //} ////if (txtJumlah.Text == "") ////{ //// MessageBox.Show("Masukkan Jumlah Racikan"); ////} ////if(cmbSatuanDosis.SelectedIndex == -1) ////{ //// MessageBox.Show("Pilih Satuan Dosis"); ////} //else //{ //} }