public Presc getPrescById(String id) { String cmd = "select * from presc where id = '" + id + "'"; DataTable table = db.queryDataTable("select * from presc where id = '" + id + "'"); if (table.Rows.Count == 0) { return null; } DataRow row = table.Rows[0]; object[] items = table.Rows[0].ItemArray; Presc presc = new Presc(); presc.id = row.Field<int>("id"); String patientId = row.Field<String>("patient"); String doctorId = row.Field<String>("doctor"); presc.time = row.Field<DateTime>("time").ToString(); presc.comment = row.Field<String>("comment"); presc.patient = patientDAO.getPatientById(patientId); presc.doctor = doctorDAO.getDoctorById(doctorId); presc.drugCountList = drugCountDAO.getDrugCountById(presc); return presc; }
public List<DrugCount> getDrugCountById(Presc presc) { List<DrugCount> drugCounts = new List<DrugCount>(); DataTable table = db.queryDataTable("select drug, count from drugcount where presc = '" + presc.id + "'"); if (table.Rows.Count == 0) { return drugCounts; } DataRowCollection rows = table.Rows; for (int i = 0; i < rows.Count; i++) { object[] items = table.Rows[i].ItemArray; DrugCount drugCount = new DrugCount(); String drugId = items[0].ToString(); drugCount.count = Convert.ToInt32(items[1].ToString()); drugCount.drug = drugDAO.getDrugById(drugId); drugCount.presc = presc; drugCounts.Add(drugCount); } return drugCounts; }
public bool insertPresc(Presc presc) { bool ret = false; db.beginTransaction(); String cmd = "insert into presc values ('" + presc.patient.id + "', '" + presc.doctor.id + "', '" + DateTime.Now + "', '" + presc.comment + "')"; if (db.update(cmd)) { presc.id = getInsertId(); //插入映射 ret = drugCountDAO.insertDrugCountList(presc.drugCountList); } db.endTransaction(ret); return ret; }
public DrugCount(Presc presc, Drug drug, int count) { this.presc = presc; this.drug = drug; this.count = count; }
private void btnTreat_Click(object sender, EventArgs e) { int index = -1; ; if (gvMain.CurrentRow == null || (index = gvMain.CurrentRow.Index) < 0) { MessageBox.Show("就诊前,请先选择挂号的病人。"); return; } DataGridViewRowCollection rows = gvMain.Rows; String id = rows[index].Cells[0].Value.ToString(); TreatUI treatUI = new TreatUI(); treatUI.patientID = id; DialogResult ret = treatUI.ShowDialog(); if (ret == DialogResult.OK) { this.presc = treatUI.presc; this.btnTreat.Enabled = false; this.btnPay.Enabled = true; } }