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 ThemChiTiet(CT_PHIEUKHAMBENH_DTO CT_PhieuKhamBenh) { SqlConnection cnn = sqlConectionData.KetNoi(); SqlCommand cmd = new SqlCommand("ThemCTPhieuKhamBenh", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MaPhieuKham", SqlDbType.Int); cmd.Parameters.Add("@MaThuoc", SqlDbType.Int); cmd.Parameters.Add("@MaDonVi", SqlDbType.Int); cmd.Parameters.Add("@MaCachDung", SqlDbType.Int); cmd.Parameters.Add("@SoLuong", SqlDbType.Int); cmd.Parameters["@MaPhieuKham"].Value = CT_PhieuKhamBenh.MaPhieuKham; cmd.Parameters["@MaThuoc"].Value = CT_PhieuKhamBenh.MaLoaiThuoc; cmd.Parameters["@MaDonVi"].Value = CT_PhieuKhamBenh.MaLoaiDonVi; cmd.Parameters["@SoLuong"].Value = CT_PhieuKhamBenh.SoLuong; cmd.Parameters["@MaCachDung"].Value = CT_PhieuKhamBenh.MaCachDung; cnn.Open(); cmd.ExecuteNonQuery(); cnn.Close(); }
public static void ThemChiTiet(CT_PHIEUKHAMBENH_DTO CTPK) { CT_PHIEUKHAMBENH_DAO.ThemChiTiet(CTPK); }