예제 #1
0
        public bool ThemPhieuKham(DTO_PhieuKham pPhieuKham)
        {
            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from PHIEUKHAM", _cn);
                DataRow        r  = dt.NewRow();
                r["MaPK"]       = pPhieuKham.MaPK;
                r["MaCTDSKB"]   = pPhieuKham.MaCTDSKB;
                r["TrieuChung"] = pPhieuKham.TrieuChung;
                r["MaLoaiBenh"] = pPhieuKham.MaLoaiBenh;
                dt.Rows.Add(r);

                SqlCommandBuilder cm = new SqlCommandBuilder(da);
                da.Update(dt);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
 public bool Update(DTO_PhieuKham pPhieuKham)
 {
     try
     {
         SqlDataAdapter da = new SqlDataAdapter("select * from PHIEUKHAM", _cn);
         DataRow        r  = dt.Rows.Find(pPhieuKham.MaPK);
         if (r != null)
         {
             r["MaPK"]       = pPhieuKham.MaPK;
             r["MaCTDSKB"]   = pPhieuKham.MaCTDSKB;
             r["TrieuChung"] = pPhieuKham.TrieuChung;
             r["MaLoaiBenh"] = pPhieuKham.MaLoaiBenh;
         }
         SqlCommandBuilder cm = new SqlCommandBuilder(da);
         da.Update(dt);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool ThemPhieuKham(DTO_PhieuKham pPhieuKham)
 {
     return(dal_phieuKham.ThemPhieuKham(pPhieuKham));
 }
 public bool Update(DTO_PhieuKham pPhieuKham)
 {
     return(dal_phieuKham.Update(pPhieuKham));
 }
예제 #5
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (!KiemTraDSVaBenhNhan())
            {
                return;
            }
            if (tbxTrieuChung.Text.Length > 50)
            {
                MessageBox.Show("Triệu chứng bệnh quá dài! (Tối đa 50 ký tự)");
                return;
            }
            if (cbxLoaiBenh.SelectedValue == null)
            {
                MessageBox.Show("Loại bệnh không tồn tại trong danh sách!");
                return;
            }
            //Luu phieu kham
            try
            {
                //MessageBox.Show( bus_ctdskb.GetMaCTDSKB(maDSKB, tbxMaBenhNhan.Text)); BN0000001
                DTO_PhieuKham phieuKham = new DTO_PhieuKham(tbxMaPhieuKham.Text, bus_ctdskb.GetMaCTDSKB(maDSKB, tbxMaBenhNhan.Text), tbxTrieuChung.Text, cbxLoaiBenh.SelectedValue.ToString());
                bus_phieuKham.ThemPhieuKham(phieuKham);

                //Luu don thuoc
                try
                {
                    for (int i = 0; i < dgrvDSThuoc.Rows.Count - 1; i++)
                    {
                        DataTable table = dgrvDSThuoc.DataSource as DataTable;
                        DataRow   r     = table.NewRow();
                        r = ((DataRowView)dgrvDSThuoc.Rows[i].DataBoundItem).Row;

                        //MessageBox.Show(bus_donThuoc.GetMaDonThuocNext(i));
                        //MessageBox.Show(tbxMaPhieuKham.Text);
                        //MessageBox.Show(bus_loaiThuoc.GetMaLoaiThuocFromTen(r.ItemArray[1].ToString()));
                        //string tmp = r.ItemArray[2].ToString();
                        //MessageBox.Show(Int32.Parse(tmp).ToString());

                        DTO_DonThuoc donThuoc = new DTO_DonThuoc(bus_donThuoc.GetMaDonThuocNext(i),
                                                                 tbxMaPhieuKham.Text,
                                                                 bus_loaiThuoc.GetMaLoaiThuocFromTen(r.ItemArray[1].ToString()),
                                                                 Int32.Parse(r.ItemArray[2].ToString()));


                        if (bus_donThuoc.Add(donThuoc))
                        {
                            //MessageBox.Show("Lưu phiếu khám thành công!");
                        }
                        else
                        {
                            MessageBox.Show("Lưu đơn thuốc thất bại!");
                            bus_phieuKham.Delete(tbxMaPhieuKham.Text);
                            return;
                        }
                    }

                    //add vao hoa don
                    LuuHoaDon();

                    MessageBox.Show("Lưu phiếu khám thành công!");
                }
                catch
                {
                    MessageBox.Show("Lưu đơn thuốc thất bại!");
                    bus_phieuKham.Delete(tbxMaPhieuKham.Text);
                    return;
                }
            }
            catch
            {
                MessageBox.Show("Lưu phiếu khám thất bại!");
                return;
            }
            ResetGiaoDien();
        }