private void btn_Luu_Click(object sender, EventArgs e) { bool flag = CheckValue(); if (flag) { foreach (DataRow dataRow in ((DataTable)gridDSDichVuKe.DataSource).Rows) { DichVu_LanKham_Info dichVu_LanKham_Info = new DichVu_LanKham_Info(0, Convert.ToInt32(dataRow["DichVuID"].ToString()), lk.Ma, Convert.ToInt32(dataRow["BacSiGuiID"].ToString()), Convert.ToInt32(dataRow["SoLuong"].ToString()), Convert.ToDecimal(dataRow["DonGia"].ToString()), 0, Convert.ToDateTime(txt_Ngay_Gio_vaovien.Value), DateTime.Now, 0); dichVu_LanKham_Info.Insert(); } TienNop_LanKham_Info tn = new TienNop_LanKham_Info(0, lk.LanKhamID, Convert.ToDecimal(txtTongChiPhi.Value), ""); tn.Insert(); MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK); txtSoKham.Focus(); // In biên lai DataTable ds = dsDichVuKe; foreach (DataRow r in ds.Rows) { DataView v = ds.DefaultView; v.RowFilter = "DichVuID=" + r["DichVuID"].ToString(); decimal t = Convert.ToDecimal(r["SoLuong"].ToString()) * Convert.ToDecimal(r["DonGia"].ToString()); string[] ParamName = { "@NgayThu", "@HoVaTen", "@Tuoi", "@DiaChi", "@TenDoiTuong", "@SoTien", "@BangChu", "@SoKham", "@Phong" }; object[] ParamValue = { DateTime.Now, txtHoTenBenhNhan.Text, txtNamSinh.Value.ToString() , txtDiaChi.Text, txtTenDoiTuong.Text,t, Util.FormHandler.txtVND(Convert.ToDecimal(t)), txtSoKham.Text, r["TenPhong"].ToString() }; frmReportMain report = new frmReportMain(11, v.ToTable(), ParamName, ParamValue); report.Show(); } dsDichVuKe.Rows.Clear(); this.Close(); } }
private void SuaThongTinBN_Click(object sender, EventArgs e) { if (grid_DV.ActiveRow != null) { DichVu_LanKham_Info dv_lk = new DichVu_LanKham_Info(); dv_lk = (DichVu_LanKham_Info)Util.FormHandler.GetAs(((DataTable)grid_DV.DataSource).Rows[grid_DV.ActiveRow.Index], typeof(DichVu_LanKham_Info)); DichVu_Info dv = new DichVu_Info(); dv.TenDichVu = grid_DV.ActiveRow.Cells["TenDichVu"].Value.ToString(); frmHuyDichVu frm = new frmHuyDichVu(dv, dv_lk); frm.ShowDialog(); grid_DV.DataSource = LoadDV(dv_lk.MaLanKham.ToString()); } }
private void load() { tb = Util.DB_SQL.EXECUTE_SQL(@"SELECT ROW_NUMBER() OVER(ORDER BY LanKhamID DESC) AS STT, dbo.BenhNhan.*,LanKham.Ma as LanKhamID, dbo.LanKham.SoBH, dbo.LanKham.ChuanDoan, dbo.LanKham.NgayKham, dbo.LanKham.GioKham, dbo.LanKham.SoKham, LanKham.BacSiGuiID,BacSi.HoTen as HoTenBacSi, dbo.DoiTuong.TenDoiTuong FROM dbo.BenhNhan INNER JOIN dbo.LanKham ON dbo.BenhNhan.Ma = dbo.LanKham.MaBenhNhan INNER JOIN dbo.DoiTuong ON dbo.LanKham.DoiTuongID = dbo.DoiTuong.DoiTuongID left JOIN dbo.BacSi ON dbo.LanKham.BacSiGuiID = dbo.BacSi.BacSiID "); GridBenhNhan.DataSource = tb; dv_lk_list = DichVu_LanKham_Info.SelectAllList(); label_TongBN.Text = string.Format("{0:00} Người", tb.Rows.Count); }
public frmHuyDichVu(DichVu_Info dv, DichVu_LanKham_Info dv_lk) { this.dv = dv; this.dv_lk = dv_lk; InitializeComponent(); }
private void btn_Luu_Click(object sender, EventArgs e) { bool flag = CheckValue(); if (flag) { BenhNhan_Info benhNhan_Info = new BenhNhan_Info(0, txtHoTenBenhNhan.Text, txtDiaChi.Text, txtSoDienThoai.Text, Convert.ToInt32(txtNamSinh.Value), Convert.ToDateTime(new DateTime(DateTime.Now.Year - Convert.ToInt32(txtNamSinh.Value), DateTime.Now.Month, DateTime.Now.Day, 1, 0, 0)), Convert.ToBoolean(cbx_GioiTinh.Text)); benhNhan_Info.Insert(); LanKham_Info lanKham_Info = new LanKham_Info(0, benhNhan_Info.Ma, Convert.ToInt32(cbx_BacSiGui.Value), Convert.ToInt32(cbx_MaDoiTuong.Text), txtMaTheBHYT.Text, txtChuanDoan.Text, Convert.ToDateTime(cdt_Ngayvaovien.Value), "", Convert.ToInt32(txtSoKham.Text)); lanKham_Info.Insert(); IEnumerator ienumerator = ((DataTable)gridDSDichVuKe.DataSource).Rows.GetEnumerator(); foreach (DataRow dataRow in ((DataTable)gridDSDichVuKe.DataSource).Rows) { DichVu_LanKham_Info dichVu_LanKham_Info = new DichVu_LanKham_Info(0, Convert.ToInt32(dataRow["DichVuID"].ToString()), lanKham_Info.Ma, Convert.ToInt32(dataRow["BacSiGuiID"].ToString()), Convert.ToInt32(dataRow["SoLuong"].ToString()), Convert.ToDecimal(dataRow["DonGia"].ToString()), 0, Convert.ToDateTime(cdt_Ngayvaovien.Value), DateTime.Now, 0); dichVu_LanKham_Info.Insert(); } TienNop_LanKham_Info tn = new TienNop_LanKham_Info(0, lanKham_Info.LanKhamID, Convert.ToDecimal(txtTongChiPhi.Value), ""); tn.Insert(); DataTable dataTable = DB_SQL.EXECUTE_SQL("select max(SoKham) as SoKham from LanKham"); flag = dataTable.Rows[0]["SoKham"].ToString() != ""; if (!flag) { txtSoKham.Text = "1"; } else { int i = Convert.ToInt32(dataTable.Rows[0]["SoKham"].ToString()) + 1; txtSoKham.Text = i.ToString(); } MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK); txtSoKham.Focus(); // In biên lai DataTable ds = dsDichVuKe, temp; temp = dsDichVuKe.Copy(); temp.Clear(); foreach (DataRow r in ds.Rows) { if (check_as(temp, "PhongID", r["PhongID"].ToString())) { DataRow rt = temp.NewRow(); rt["PhongID"] = r["PhongID"].ToString(); temp.Rows.Add(rt); DataView v = ds.DefaultView; v.RowFilter = "TenPhong='" + r["TenPhong"].ToString() + "'"; DataTable ds1 = v.ToTable(); decimal t = 0; foreach (DataRow k in ds1.Rows) { t += Convert.ToDecimal(k["SoLuong"].ToString()) * Convert.ToDecimal(k["DonGia"].ToString()); } string[] ParamName = { "@NgayThu", "@HoVaTen", "@Tuoi", "@DiaChi", "@TenDoiTuong", "@SoTien", "@BangChu", "@SoKham", "@Phong" }; object[] ParamValue = { Convert.ToDateTime(cdt_Ngayvaovien.Value), txtHoTenBenhNhan.Text, txtNamSinh.Value.ToString() , txtDiaChi.Text, txtTenDoiTuong.Text,t, Util.FormHandler.txtVND(Convert.ToDecimal(t)), lanKham_Info.SoKham.ToString(), r["TenPhong"].ToString() }; frmReportMain report = new frmReportMain(11, v.ToTable(), ParamName, ParamValue); report.Show(); } } txtTongChiPhi.Value = 0; clear(); load(); } }