예제 #1
0
 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();
         }
     }
 }
        private void btn_Tim_Click(object sender, EventArgs e)
        {
            if (txt_HD_MaHoaDon.Text == String.Empty)
            {
                MessageBox.Show("Vui lòng nhập mã số hóa đơn cần thanh toán.", "", MessageBoxButtons.OK);
                txt_HD_MaHoaDon.Focus();
                return;
            }

            int        MaHoaDon  = int.Parse(txt_HD_MaHoaDon.Text.Trim());
            HOADON_DTO hoadonDto = new HOADON_BUS().Select(MaHoaDon);

            if (hoadonDto != null)
            {
                btn_LapPhieu.Enabled = true;
                btn_HuyBo.Enabled    = true;

                txt_HD_NgayLap.Text  = hoadonDto.NgayLap.ToShortDateString();
                txt_HD_TongTien.Text = hoadonDto.TongTien.ToString();
                txt_HD_SoLanTra.Text = hoadonDto.SoLanTra.ToString();

                List <BIENNHAN_DTO> biennhanDtoList = new BIENNHAN_BUS().SelectAllByMaHoaDon(MaHoaDon);
                if (biennhanDtoList.Count != 0)
                {
                    lb_CacBienNhanTruoc.Visible       = true;
                    txt_HD_SoLanDaTra.Text            = biennhanDtoList.Count.ToString();
                    grid_CacDotDaThanhToan.Visible    = true;
                    grid_CacDotDaThanhToan.DataSource = biennhanDtoList;
                    if (biennhanDtoList.Count == hoadonDto.SoLanTra)
                    {
                        txt_BN_SoTienTra.ReadOnly = true;
                        btn_LapPhieu.Enabled      = false;
                        btn_HuyBo.Enabled         = false;
                        MessageBox.Show("Hóa đơn " + MaHoaDon.ToString() + " đã được thanh toán đầy đủ", "", MessageBoxButtons.OK);
                    }
                }

                txt_BN_NgayTra.Text = DateTime.Today.ToShortDateString();

                //Customer's Info
                KHACHHANG_DTO khachhangDto = new KHACHHANG_BUS().SelectByMaHoaDon(MaHoaDon);
                txt_KH_MaKhachHang.Text  = khachhangDto.Ma.ToString();
                txt_KH_TenKhachHang.Text = khachhangDto.HoTen;
                txt_KH_DiaChi.Text       = khachhangDto.DiaChi;
                txt_KH_DienThoai.Text    = khachhangDto.DienThoai;
                txt_KH_CMND.Text         = khachhangDto.Cmnd;


                //Staff's Info
                NHANVIEN_DTO nhanvienDto = new NHANVIEN_BUS().SelectByMaHoaDon(MaHoaDon);
                txt_NV_MaNV_LapHoaDon.Text = nhanvienDto.Ma.ToString();
                txt_NV_TenNhanVien.Text    = nhanvienDto.HoTen;

                LOAINHANVIEN_DTO loainvDto = new LOAINHANVIEN_BUS().Select(nhanvienDto.MaLoaiNhanVien);
                txt_NV_LoaiNhanVien.Text = loainvDto.TenLoaiNhanVien;

                //Thong tin bien nhan
                txt_BN_SoTienTra.Text = hoadonDto.TienTraMoiDot.ToString();
            }
        }
예제 #3
0
 private void dgv_benhnhan_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         lbl_thanhchu.Text = "Thành chữ: ";
         int now        = dgv_benhnhan.CurrentCell.RowIndex;
         int k          = int.Parse(dgv_benhnhan.Rows[now].Cells[0].Value.ToString());
         int MaBenhNhan = int.Parse(PHIEUKHAMBENH_BUS.LoadDaKham().Rows[k - 1][0].ToString());
         XuLyMaBN(MaBenhNhan);
         dt_ngaysinh.Value = Convert.ToDateTime(PHIEUKHAMBENH_BUS.HienThongTin(MaBenhNhan).Rows[0][0].ToString());
         txt_diachi.Text   = PHIEUKHAMBENH_BUS.HienThongTin(MaBenhNhan).Rows[0][1].ToString();
         lbl_hoten.Text    = "Họ tên: " + dgv_benhnhan.Rows[now].Cells[1].Value.ToString();
         lbl_tienkham.Text = "Tiền khám: " + string.Format("{0:0,0}", QUYDINH_BUS.TienKham());
         lbl_ngaykham.Text = "Ngày khám: " + Convert.ToDateTime(HOADON_BUS.XuatHoaDon(MaBenhNhan).Rows[0][1].ToString()).Date.ToShortDateString();
         LoadDataThuoc(int.Parse(HOADON_BUS.XuatHoaDon(MaBenhNhan).Rows[0][0].ToString()));
         lbl_tienthuoc.Text = "Tiền thuốc: " + string.Format("{0:0,0}", (int)float.Parse(HOADON_BUS.XuatHoaDon(MaBenhNhan).Rows[0][2].ToString()));
         lbl_tong.Text      = "Tổng tiền: " + string.Format("{0:0,0}", ((int)float.Parse(HOADON_BUS.XuatHoaDon(MaBenhNhan).Rows[0][2].ToString()) + QUYDINH_BUS.TienKham()));
         DocTien(((int)float.Parse(HOADON_BUS.XuatHoaDon(MaBenhNhan).Rows[0][2].ToString()) + QUYDINH_BUS.TienKham()).ToString());
         lbl_thanhchu.Text = lbl_thanhchu.Text + "Đồng";
     }
     catch (Exception ex)
     { }
 }