//lay DS benh nhan theo ngay //create proc sp_DanhSachBenhNhanTheoNgay @ngay datetime public List <BenhNhanInfo> sp_DanhSachBenhNhanTheoNgay(DateTime Ngay) { List <BenhNhanInfo> arr = new List <BenhNhanInfo>(); BenhNhanInfo info; SqlDataReader read; dataService.Conect(); dataService.Cmd = new SqlCommand("sp_DanhSachBenhNhanTheoNgay", dataService.Cnn); dataService.Cmd.CommandType = CommandType.StoredProcedure; dataService.Cmd.Parameters.Add("@ngay", SqlDbType.DateTime); dataService.Cmd.Parameters["@ngay"].Value = Ngay; read = dataService.Cmd.ExecuteReader(); //string chuoingay; //DateTime ngay; while (read.Read()) { info = new BenhNhanInfo(); info.Ma = int.Parse(read.GetValue(0).ToString()); info.Ten = read.GetValue(1).ToString(); info.NgaySinh = DateTime.Parse(read.GetValue(2).ToString()); //chuoingay = ngay.Day + "/" + ngay.Month + "/" + ngay.Year; //info.NgaySinh = chuoingay; info.DiaChi = read.GetValue(3).ToString(); arr.Add(info); } dataService.DisConect(); return(arr); }
//---lay thong tin Benh nhan //create proc sp_ThongTinBenhNhan //---lay thong tin BN co Ma //create proc sp_ThongTinBenhNhanCoMa @maBN int public BenhNhanInfo sp_ThongTinBenhNhanCoMa(int MaBN) { BenhNhanInfo info = new BenhNhanInfo(); dataService.Conect(); dataService.Cmd = new SqlCommand("sp_ThongTinBenhNhanCoMa", dataService.Cnn); dataService.Cmd.CommandType = CommandType.StoredProcedure; dataService.Cmd.Parameters.Add("@maBN", SqlDbType.Int); dataService.Cmd.Parameters["@maBN"].Value = MaBN; //info = (BenhNhanInfo)dataService.Cmd.ExecuteScalar(); SqlDataReader r; r = dataService.Cmd.ExecuteReader(); while (r.Read()) { info.Ma = int.Parse(r.GetValue(0).ToString()); info.Ten = r.GetValue(1).ToString(); info.NgaySinh = DateTime.Parse(r.GetValue(2).ToString()); info.DiaChi = r.GetValue(3).ToString(); info.Phai = r.GetValue(4).ToString(); break; } dataService.DisConect(); return(info); }
//create proc sp_ThongTinBenhNhanVuaThem @Ten nvarchar(50) public BenhNhanInfo sp_ThongTinBenhNhanVuaThem() { dataService.Conect(); dataService.Cmd = new SqlCommand("sp_ThongTinBenhNhanVuaThem", dataService.Cnn); dataService.Cmd.CommandType = CommandType.StoredProcedure; SqlDataReader r; r = dataService.Cmd.ExecuteReader(); BenhNhanInfo info = new BenhNhanInfo(); while (r.Read()) { info.Ma = int.Parse(r.GetValue(0).ToString()); info.Ten = r.GetValue(1).ToString(); info.NgaySinh = DateTime.Parse(r.GetValue(2).ToString()); info.DiaChi = r.GetValue(3).ToString(); info.Phai = r.GetValue(4).ToString(); break; } dataService.DisConect(); return(info); }
//----them thong tin bang Benh Nhan //create proc sp_ThemThongTinBenhNhan @ten nvarchar(20), @ngaysinh datetime, // @diachi nvarchar(20), @phai nvarchar(20) public void sp_ThemThongTinBenhNhan(BenhNhanInfo info) { dataService.Conect(); dataService.Cmd = new SqlCommand("sp_ThemThongTinBenhNhan", dataService.Cnn); dataService.Cmd.CommandType = CommandType.StoredProcedure; dataService.Cmd.Parameters.Add("@ten", SqlDbType.NVarChar); dataService.Cmd.Parameters["@ten"].Value = info.Ten; dataService.Cmd.Parameters.Add("@ngaysinh", SqlDbType.DateTime); dataService.Cmd.Parameters["@ngaysinh"].Value = info.NgaySinh; dataService.Cmd.Parameters.Add("@diachi", SqlDbType.NVarChar); dataService.Cmd.Parameters["@diachi"].Value = info.DiaChi; dataService.Cmd.Parameters.Add("@phai", SqlDbType.NVarChar); dataService.Cmd.Parameters["@phai"].Value = info.Phai; dataService.Cmd.ExecuteNonQuery(); dataService.DisConect(); }
public void ThemThongTinBenhNhan(BenhNhanInfo info) { accBenhnhan.sp_ThemThongTinBenhNhan(info); }
protected void btDangKy_Click(object sender, EventArgs e) { // kiem tra so luong nguoi da dang ky trong ngay PhieuDangKyControl pdkctr = new PhieuDangKyControl(); int SluongDK = pdkctr.DemSLBenhNhanDKTrongNgay(UCNgayThangNam2.NgayThang); ThamSoControl tsctr = new ThamSoControl(); ThamSoInfo tsinfo = new ThamSoInfo(); tsinfo = tsctr.spLayThongTinBangThamSoCoMa(1); int SLDKToiDa = tsinfo.GiaTri; if (SluongDK > SLDKToiDa) { // khong cho dang ky Label1.Text = "So Luong DK Vuot Muc cho Phep,Chon Ngay Khac Di"; return; } Label1.Text = ""; int MaNguoiLon; int MaTK = (int)Session["MaTK"]; NguoiLonControl nglonctr = new NguoiLonControl(); MaNguoiLon = nglonctr.MaBenhNhanKhiBietMaTK(MaTK); //dang ky cho tre em // lay ma nguoi lon dang online= ma nguoi lon // int MaBenhNhan = 3; BenhNhanControl ctrBN = new BenhNhanControl(); BenhNhanInfo infoBN = new BenhNhanInfo(); infoBN.Ten = txtHotenTre.Text; infoBN.NgaySinh = UCNgayThangNam1.NgayThang; infoBN.DiaChi = txtDiachi.Text; if (ckNam.Checked == true) { infoBN.Phai = "Nam"; } else { infoBN.Phai = "Nu"; } ctrBN.ThemThongTinBenhNhan(infoBN); //nhap cac thong tin //luu xuong bang benh nhan //lay ma tre em vua moi luu= ma benh nhan //lay ma nguoi lon= ma nguoi lon dang Online TreEmControl ctrTE = new TreEmControl(); TreEmInfo infoTE = new TreEmInfo(); //int MaNguoiLon = 3; infoBN = ctrBN.ThongTinBenhNhanVuaThem(); infoTE.MaBenhNhan = infoBN.Ma; infoTE.MaNguoiLon = MaNguoiLon; ctrTE.ThemTreEm(infoTE); // lb.Text = "Them Thanh Cong Benh Nhan Tre Em"; // luu xuong bang tre em //luu xuong bang Dang ky PhieuDangKyControl ctrpdk = new PhieuDangKyControl(); PhieuDangKyInfo infopdk = new PhieuDangKyInfo(); infopdk.MaBenhNhan = MaNguoiLon; infopdk.Ngay = UCNgayThangNam2.NgayThang; infopdk.TrieuChung = txtTCtreem.Text; ctrpdk.sp_ThemPhieuDangKy(infopdk); int soluong = ctrpdk.DemSLBenhNhanDKTrongNgay(infopdk.Ngay); lbsoluong.Text = soluong.ToString(); Label2.Text = "Them Thanh Cong Dang ky "; }