Beispiel #1
0
 public async Task <string> AddDonThuocAsync(DTO_DonThuoc donThuoc)
 {
     using (var context = new SQLServerDBContext())
     {
         string res = null;
         try
         {
             var maDon  = new SqlParameter("@1", System.Data.SqlDbType.NVarChar);
             var loiDan = new SqlParameter("@2", System.Data.SqlDbType.NVarChar);
             maDon.Value  = donThuoc.MaDonThuoc;
             loiDan.Value = donThuoc.LoiDan;
             res          = await context.Database.SqlQuery <string>("exec proc_DonThuoc_insert @1, @2",
                                                                     new SqlParameter[]
             {
                 maDon,
                 loiDan
             }).FirstOrDefaultAsync();
         }
         catch (Exception e)
         {
             Debug.WriteLine("[ERROR] " + e.Message);
         }
         return(res);
     }
 }
        public bool Add(DTO_DonThuoc pDonThuoc)
        {
            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from DONTHUOC", _cn);
                DataRow        r  = dt.NewRow();
                r["MaDT"]        = pDonThuoc.MaDT;
                r["MaPK"]        = pDonThuoc.MaPK;
                r["MaLoaiThuoc"] = pDonThuoc.MaLoaiThuoc;
                r["SoLuong"]     = pDonThuoc.SoLuong;
                dt.Rows.Add(r);

                SqlCommandBuilder cm = new SqlCommandBuilder(da);
                da.Update(dt);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #3
0
 public bool LoadNP_DSCTDonThuoc(DTO_DonThuoc donThuoc)
 {
     try
     {
         using (var context = new SQLServerDBContext())
         {
             context.DonThuoc.Attach(donThuoc);
             var entry = context.Entry(donThuoc);
             if (!entry.Collection(p => p.DS_CTDonThuoc).IsLoaded)
             {
                 entry.Collection(p => p.DS_CTDonThuoc).Load();
             }
             return(true);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine($"[ERRROR DAL DonThuoc] {e.Message}");
         return(false);
     }
 }
 public bool Update(DTO_DonThuoc pDonThuoc)
 {
     try
     {
         SqlDataAdapter da = new SqlDataAdapter("select * from DONTHUOC", _cn);
         DataRow        r  = dt.Rows.Find(pDonThuoc.MaDT);
         if (r != null)
         {
             r["MaDT"]        = pDonThuoc.MaDT;
             r["MaPKT"]       = pDonThuoc.MaPK;
             r["MaLoaiThuoc"] = pDonThuoc.MaLoaiThuoc;
             r["SoLuong"]     = pDonThuoc.SoLuong;
         }
         SqlCommandBuilder cm = new SqlCommandBuilder(da);
         da.Update(dt);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool Update(DTO_DonThuoc pDonThuoc)
 {
     return(dal_donThuoc.Update(pDonThuoc));
 }
 public bool Add(DTO_DonThuoc pDonThuoc)
 {
     return(dal_donThuoc.Add(pDonThuoc));
 }
Beispiel #7
0
 public void LoadNP_DSCTDonThuoc(DTO_DonThuoc donThuoc)
 {
     DALManager.DonThuocDAL.LoadNP_DSCTDonThuoc(donThuoc);
 }
Beispiel #8
0
 public void LoadNPPKDaKhoa(DTO_DonThuoc donThuoc)
 {
     DALManager.DonThuocDAL.LoadNPPKDaKhoa(donThuoc);
 }
Beispiel #9
0
 public async Task <string> AddDonThuocAsync(DTO_DonThuoc donThuoc)
 {
     return(await DALManager.DonThuocDAL.AddDonThuocAsync(donThuoc));
 }
Beispiel #10
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();
        }