private void rd_luu_Click(object sender, EventArgs e) { if (dgv_thuoc.Rows.Count > 0) { int now = dgv_danhsachck.CurrentCell.RowIndex; int k = int.Parse(dgv_thuoc.Rows[now].Cells[0].Value.ToString()); int MaBN = int.Parse(PHIEUKHAMBENH_BUS.LoadChoKham().Rows[k - 1][0].ToString()); int MaBE = HAMPHU_BUS.FMaBenh(txt_dudoan.Text); PHIEUKHAMBENH_DTO PKB = new PHIEUKHAMBENH_DTO(MaBN, MaBE, txt_trieuchung.Text); PHIEUKHAMBENH_BUS.ThemPhieuKhamBenh(PKB); foreach (DataGridViewRow row in dgv_thuoc.Rows) { if (row.Cells[1].Value != null) { int MaTH = HAMPHU_BUS.FMaThuoc(row.Cells[1].Value.ToString()); int MaDV = HAMPHU_BUS.FMaDonVi(row.Cells[2].Value.ToString()); int MaCD = HAMPHU_BUS.FMaCachDung(row.Cells[4].Value.ToString()); int MaPK = HAMPHU_BUS.FMaPhieuKham(MaBN, MaBE); CT_PHIEUKHAMBENH_DTO CTPKB = new CT_PHIEUKHAMBENH_DTO(MaPK, MaTH, MaDV, int.Parse(row.Cells[3].Value.ToString()), MaCD); CT_PHIEUKHAMBENH_BUS.ThemChiTiet(CTPKB); } } HOADON_BUS.TaoHoaDon(MaBN); CTHD_BUS.TaoCTHoaDon(MaBN); int n = dgv_danhsachck.Rows.Count; for (int i = 1; i < n; i++) { dgv_danhsachck.Rows.RemoveAt(0); } LoadData(); dgv_danhsachck_SelectionChanged(sender, e); luu = 1; rd_luu_MouseLeave(sender, e); timer1.Start(); timer1.Enabled = true; lbl_thongbao.ForeColor = Color.Red; lbl_thongbao.Text = "Lưu thành công"; timer1_Tick(sender, e); } else { if (txt_trieuchung.Text == "" || txt_dudoan.Text == "") { DevComponents.DotNetBar.MessageBoxEx.Show("Bạn chưa nhập đầy đủ thông tin của một phiếu khám bệnh!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (txt_trieuchung.Text == "") { txt_trieuchung.Focus(); } else { txt_dudoan.Focus(); } } else { DevComponents.DotNetBar.MessageBoxEx.Show("Bạn chưa nhập chi tiết phiếu khám bệnh!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); txt_thuoc.Focus(); } } }
public static void ThemPhieuKhamBenh(PHIEUKHAMBENH_DTO PhieuKhamBenh) { SqlConnection cnn = sqlConectionData.KetNoi(); SqlCommand cmd = new SqlCommand("ThemPhieuKhamBenh", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MaBenhNhan", SqlDbType.Int); cmd.Parameters.Add("@MaBenh", SqlDbType.Int); cmd.Parameters.Add("@TrieuChung", SqlDbType.NVarChar, 50); cmd.Parameters["@MaBenhNhan"].Value = PhieuKhamBenh.MaBenhNhan; cmd.Parameters["@MaBenh"].Value = PhieuKhamBenh.MaLoaiBenh; cmd.Parameters["@TrieuChung"].Value = PhieuKhamBenh.TrieuChung; cnn.Open(); cmd.ExecuteNonQuery(); cnn.Close(); }
public static void ThemPhieuKhamBenh(PHIEUKHAMBENH_DTO PhieuKhamBenh) { PHIEUKHAMBENH_DAO.ThemPhieuKhamBenh(PhieuKhamBenh); }