//ham them benh nhan moi vao CSDL public bool ThemBenhNhan(BenhNhan bn) { //them thong tin vao table BENHNHAN string sql = string.Format("Insert into BENHNHAN(STT, MaBenhNhan, MaDoiTuong, MaPhongKham, MaBacSi, Ho, Ten, GioiTinh, CMND, NgheNghiep, NgaySinh," + "DiaChi, SDT, YeuCauKham, GioKham, NgayKham) values('{0}', '{1}', '{2}', '{3}', '{4}', N'{5}', N'{6}', N'{7}', '{8}', N'{9}', N'{10}', N'{11}', '{12}', N'{13}', '{14}', N'{15}')", "0", bn.MaBenhNhan,bn.MaDoiTuong, bn.MaPhongKham, bn.MaBacSi, bn.Ho, bn.Ten, bn.GioiTinh, bn.CMND, bn.NgheNghiep, bn.NgaySinh.ToString("MM/dd/yyyy"), bn.DiaChi, bn.SDT, bn.YeuCauKham, bn.GioKham.ToString("hh:mm:ss"), bn.NgayKham.ToString("MM/dd/yyyy")); if (connData.ExcuteQuery(sql)) return true; return false; }
//Sua doi thong tin benh nhan public bool SuaDoiBenhNhan(BenhNhan bn) { string sql = string.Format("Update BENHNHAN set Ho = N'{0}', Ten = N'{1}', NgaySinh = N'{2}', GioiTinh = N'{3}', DiaChi = N'{4}'," +" CMND = '{5}', MaDoiTuong = '{6}', NgheNghiep = N'{7}', SDT = '{8}', YeuCauKham = '{9}', NgayKham = N'{10}', MaPhongKham = '{11}'" + " where MaBenhNhan = '{12}'",bn.Ho, bn.Ten, bn.NgaySinh.ToString("MM/dd/yyyy"), bn.GioiTinh, bn.DiaChi, bn.CMND, bn.MaDoiTuong, bn.NgheNghiep, bn.SDT, bn.YeuCauKham, bn.NgayKham.ToString("MM/dd/yyyy"), bn.MaPhongKham, bn.MaBenhNhan); if (conn.ExcuteQuery(sql)) { MessageBox.Show("Sửa đổi thông tin Bệnh nhân thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } else return false; }
private BenhNhan LayThongTinBenhNhan() { BenhNhan bn = new BenhNhan(); bn.MaBenhNhan = txtThemBN_MaBenhNhan.Text; bn.MaBenhAn = txtThemBN_MaBenhAnBN.Text; bn.MaDoiTuong = cboThemBN_MaDoiTuongBN.SelectedValue.ToString(); bn.MaPhieuKham = txtThemBN_MaPhieuBN.Text; bn.MaPhongKham = cboThemBN_PhongKham.SelectedValue.ToString(); bn.MaBacSi = txtThemBN_MaBacSi.Text; bn.Ho = txtThemBN_HoBN.Text; bn.Ten = txtThemBN_TenBN.Text; bn.GioiTinh = cboThemBN_GioiTinhBN.SelectedValue.ToString(); bn.CMND = Convert.ToInt32(txtThemBN_CMNDBN.Text); bn.NgheNghiep = txtThemBN_NgheNghiepBN.Text; bn.NgaySinh = Convert.ToDateTime(dtPickerThemBN_NgaySinhBN.Value.ToString()); bn.DiaChi = txtThemBN_DiaChiBN.Text; bn.SDT = Convert.ToInt64(txtThemBN_SDTBN.Text); bn.YeuCauKham = rtxtThemBN_YeuCauKhamBN.Text; bn.NgayKham = Convert.ToDateTime(dtPickerThemBN_NgayKhamBN.Value.ToString()); bn.GioKham = Convert.ToDateTime(dtPicker_GioKhamBN.Value.ToString()); return bn; }
//ham them benh nhan moi vao CSDL public bool ThemBenhNhan(BenhNhan bn) { //them thong tin vao table BENHNHAN string sql = string.Format("Insert into BENHNHAN(STT, MaBenhNhan, MaDoiTuong, Ho, Ten, GioiTinh, CMND, NgheNghiep, NgaySinh," + "DiaChi, SDT, YeuCauKham, MaBenhAn, NgayKham, MaPhongKham) values('{0}', '{1}', '{2}', N'{3}', N'{4}', N'{5}', '{6}', N'{7}', N'{8}', N'{9}', '{10}', N'{11}', '{12}', N'{13}', '{14}' )", "0", bn.MaBenhNhan, bn.MaDoiTuong, bn.Ho, bn.Ten, bn.GioiTinh, bn.CMND, bn.NgheNghiep, bn.NgaySinh.ToString("MM/dd/yyyy"), bn.DiaChi, bn.SDT, bn.YeuCauKham, bn.MaBenhAn, bn.NgayKham.ToString("MM/dd/yyyy"), bn.MaPhongKham); if (conn.ExcuteQuery(sql)) { MessageBox.Show("Đã thêm bệnh nhân thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } else return false; }