private void toolStripMenuItem10_Click(object sender, EventArgs e) { frmInvoiceReport obj = new frmInvoiceReport(); obj.MdiParent = this; obj.Show(); }
private void btnFinishDoc_Click(object sender, EventArgs e) { try { //cap nhat lai thong tin ho so kham if (cbbDoctor.SelectedIndex == -1) { Common.WarningMessageBox("Vui lòng chọn bác sỹ khám"); xtcExam.SelectedTabPageIndex = 0; cbbDoctor.Focus(); return; } string doctor = cbbDoctor.SelectedValue.ToString(); try { var date = DateTime.ParseExact(mtbExamDate.Text, "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture); } catch { Common.ErrorMessageBox("Vui lòng nhập định dạng ngày khám dd/mm/yyyy HH:mm"); xtcExam.SelectedTabPageIndex = 0; mtbExamDate.Focus(); return; } string examdate = mtbExamDate.Text; string diagnostic = actDiagnostic.Text; if (string.IsNullOrEmpty(diagnostic)) { Common.ErrorMessageBox("Vui lòng nhập chẩn đoán"); xtcExam.SelectedTabPageIndex = 0; actDiagnostic.Focus(); return; } string patientno = txtPatientno.Text; try { docno = long.Parse(txtDocno.Text); } catch { Common.ErrorMessageBox("Số hồ sơ không hợp lệ"); } string symptom = actSymptom.Text; string advice = actAdvice.Text; if (new Docs().Confirm(docno, patientno, symptom, diagnostic, advice, examdate, doctor) != 1) { Common.ErrorMessageBox("Lỗi tạo hồ sơ khám"); return; } //----> ket thuc phan cap nhat ho so kham //xu ly don thuoc if ((lstFee == null || lstFee.Where(x => x.type == "D").ToList().Count == 0) && DialogResult.No == Common.ConfirmMessage("Chưa kê thuốc", "Bạn vẫn muốn tiếp tục?")) { xtcExam.SelectedTabPageIndex = 2; return; } if (lstFee != null && lstFee.Where(x => x.type == "D").ToList().Count > 0) { long id = new DrugOrder().Insert(docno, doctor, examdate, examdate); if (id > 0) { var chk = true; foreach (var t in lstFee.Where(x => x.type == "D").ToList()) { var rs = new DrugOrderLine().Insert(id, t.id, t.price, t.quantity, t.usage); if (rs == 0) { chk = false; Common.ErrorMessageBox("Số lượng thuốc không đủ"); break; } if (rs == -1) { chk = false; break; } } if (!chk) { return; } } else { Common.WarningMessageBox("Thêm đơn thuốc thất bại"); return; } } // ket thuc xu ly don thuoc //xu ly cls if (lstFee != null && lstFee.Where(x => x.type == "S").ToList().Count > 0) { long orderid = new FeeOrder().Insert(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), docno, "admin"); if (orderid > 0) { var chk = true; foreach (var item in lstFee.Where(x => x.type == "S").ToList()) { if (new FeeOrderLine().Insert(orderid, item.id, item.quantity, item.price) <= 0) { chk = false; break; } } if (!chk) { Common.ErrorMessageBox("Thêm phí dịch vụ thất bại"); return; } } else { return; } } //---> ket thuc xu ly cls //in đơn thuốc if (ckbDrugPrint.Checked) { frmDrugReport f = new frmDrugReport(); f.PrintOrder(s.SelectValue("clinic_name"), s.SelectValue("clinic_phone"), s.SelectValue("clinic_address"), txtPatientno.Text, txtDocno.Text, DateTime.Now.ToString("dd/MM/yyyy HH:mm"), txtFullname.Text, mtbBirthdate.Text, cbbGender.Text, actAddress.Text, txtPhone.Text, actSymptom.Text, actDiagnostic.Text, actAdvice.Text, cbbDoctor.Text, lstFee.Where(x => x.type == "D").ToList()); f.ShowInTaskbar = false; f.ShowDialog(); } //--->kết thúc in đơn thuốc // in hóa đơn if (ckbPrint.Checked) { frmInvoiceReport frm = new frmInvoiceReport(); frm.Invoice(s.SelectValue("clinic_name"), s.SelectValue("clinic_phone"), s.SelectValue("clinic_address"), txtPatientno.Text, txtDocno.Text, DateTime.Now.ToString("dd/MM/yyyy HH:mm"), txtFullname.Text, mtbBirthdate.Text, cbbGender.Text, actAddress.Text, txtPhone.Text, actSymptom.Text, actDiagnostic.Text, actAdvice.Text, cbbDoctor.Text, lstFee); frm.ShowInTaskbar = false; frm.ShowDialog(); } //----->kết thúc in hóa đơn lstFee = null; dgvFeeList.DataSource = null; dgvFees.DataSource = null; dgvPharmacy.DataSource = null; btnSearch.PerformClick(); SetEnableComponents(false); ResetComponents(); } catch (Exception ex) { Common.ErrorMessageBox("Lỗi kết thúc hồ sơ: " + ex.Message); } }