Beispiel #1
0
 public Boolean UpdateThuoc(Thuoc thuoc) {
     SystemLog systemLog = new SystemLog(QuanLy.IDUser, DateTime.Now.ToString(), "Sửa thuốc");
     busUser.SetSystemLog(systemLog);
     if (thuocQ.UpdateThuoc(thuoc) > 0)
     {
         return true;
     }
     else return false;
 }
Beispiel #2
0
 public ArrayList SelectAllThuoc(string _TenThuoc)
 {
     _TenThuoc = _TenThuoc.Replace("'", "''");
     SqlDataReader rd = dbHelper.ExecuteQuery("GetThuocBYTenThuoc N'%" + _TenThuoc + "%'");
     ArrayList arrLThuoc = new ArrayList();
     while (rd.Read())
     {
         Thuoc thuoc = new Thuoc(rd.GetInt32(0), rd.GetString(1), rd.GetString(2), rd.GetString(3), rd.GetString(4), rd.GetString(5), rd.GetInt32(6), rd.GetDouble(7), rd.GetDecimal(8), rd.GetString(9), rd.GetString(10), rd.GetInt32(11), rd.GetString(12), rd.GetString(13), rd.GetString(14), rd.GetString(15), rd.GetString(16), rd.GetString(17), rd.GetString(18), rd.GetString(19), rd.GetString(20), rd.GetString(21));
         arrLThuoc.Add(thuoc);
     }
     rd.Close();
     return arrLThuoc;
 }
Beispiel #3
0
 public Thuoc SelectThuocDetails(int _IDThuoc)
 {
     SqlDataReader rd = dbHelper.ExecuteQuery("GetThuocDetails "+_IDThuoc+"");
     if (rd.Read())
     {
         Thuoc thuoc = new Thuoc(rd.GetInt32(0), rd.GetString(1), rd.GetString(2), rd.GetString(3), rd.GetString(4), rd.GetString(5), rd.GetInt32(6), rd.GetDouble(7), rd.GetDecimal(8), rd.GetString(9), rd.GetString(10), rd.GetInt32(11), rd.GetString(12), rd.GetString(13), rd.GetString(14), rd.GetString(15), rd.GetString(16), rd.GetString(17), rd.GetString(18), rd.GetString(19), rd.GetString(20), rd.GetString(21));
         rd.Close();
         return thuoc;
     }
     else
     {
         rd.Close();
         return null;
     }
 }
Beispiel #4
0
        public Thuoc SelectThuocDetails2(string _MaThuoc)
        {
            SqlDataReader rd = dbHelper.ExecuteQuery("GetThuocDetails_Hungnc N'" + _MaThuoc.Replace("'", "''") + "'");
            if (rd.Read())
            {
                Thuoc thuoc = new Thuoc(rd.GetInt32(0), rd.GetString(1), rd.GetString(2), rd.GetInt32(22), rd.GetString(3), rd.GetString(4), rd.GetInt32(23), rd.GetString(5), rd.GetInt32(6), rd.GetDouble(7), rd.GetDecimal(8),
rd.GetInt32(24), rd.GetString(9), rd.GetInt32(25), rd.GetString(10), rd.GetInt32(11), rd.GetString(12), rd.GetString(13), rd.GetString(14),
rd.GetString(15), rd.GetString(16), rd.GetString(17), rd.GetString(18), rd.GetString(19), rd.GetString(20), rd.GetString(21));
                rd.Close();
                return thuoc;
            }
            else
            {
                rd.Close();
                return null;
            }
        }
Beispiel #5
0
        public ChiTietThuoc(Thuoc thuoc,int type)
        {
            this.thuocCurent = thuoc;
            this.type = type;
            busThuoc = new BusThuoc();
            busNT = new BusNhomThuoc();
            busNSX = new BusNSX();
            busDVT = new BusDVT();
            InitializeComponent();
            DanhSachNhomThuoc();
            DanhSachNSX();
            DanhSachDVT();
            DanhSachDongGoi();

            if (type == 2)
            {
                ViewForm();
                btn_ThemThuoc.Visible = false;
            }
            else
                btn_CapNhap.Visible = false;
            txt_TenThuoc.Focus();
            
        }
Beispiel #6
0
        public int UpdateThuoc(Thuoc thuoc) {
            List<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter param = new SqlParameter();
            param = new SqlParameter("@IDThuoc", SqlDbType.Int);
            param.Value = thuoc.IDThuoc;
            paramList.Add(param);
            param = new SqlParameter("@MaThuoc", SqlDbType.NVarChar);
            param.Value = thuoc.MaThuoc.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@TenThuoc", SqlDbType.NVarChar);
            param.Value = thuoc.TenThuoc.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@MaNhom", SqlDbType.Int);
            param.Value = thuoc.MaNhom;
            paramList.Add(param);
            param = new SqlParameter("@NguonGoc", SqlDbType.NVarChar);
            param.Value = thuoc.NguonGoc.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@MaNSX", SqlDbType.Int);
            param.Value = thuoc.MaNSX;
            paramList.Add(param);
            param = new SqlParameter("@SoLuong", SqlDbType.Int);
            param.Value = thuoc.SoLuong;
            paramList.Add(param);
            param = new SqlParameter("@Thue", SqlDbType.Float);
            param.Value = thuoc.Thue;
            paramList.Add(param);
            param = new SqlParameter("@GiaBan", SqlDbType.Money);
            param.Value = thuoc.GiaBan;
            paramList.Add(param);
            param = new SqlParameter("@MaDVT", SqlDbType.Int);
            param.Value = thuoc.MaDVT;
            paramList.Add(param);
            param = new SqlParameter("@DangDongGoi", SqlDbType.Int);
            param.Value = thuoc.DangDongGoi;
            paramList.Add(param);
            param = new SqlParameter("@SoLuongDongGoi", SqlDbType.Int);
            param.Value = thuoc.SoLuongDongGoi;
            paramList.Add(param);
            param = new SqlParameter("@SoDangKy", SqlDbType.NVarChar);
            param.Value = thuoc.SoDangKy.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@DangBaoChe", SqlDbType.NVarChar);
            param.Value = thuoc.DangBaoChe.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@ThanhPhan", SqlDbType.NVarChar);
            param.Value = thuoc.ThanhPhan.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@HamLuong", SqlDbType.NVarChar);
            param.Value = thuoc.HamLuong.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@CongDung", SqlDbType.NVarChar);
            param.Value = thuoc.CongDung.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@PhanTacDung", SqlDbType.NVarChar);
            param.Value = thuoc.PhanTacDung.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@CachDung", SqlDbType.NVarChar);
            param.Value = thuoc.CachDung.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@ChuY", SqlDbType.NVarChar);
            param.Value = thuoc.ChuY.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@HanSuDung", SqlDbType.NVarChar);
            param.Value = thuoc.HanSuDung.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@BaoQuan", SqlDbType.NVarChar);
            param.Value = thuoc.BaoQuan.Replace("'", "''");
            paramList.Add(param);

            int i = dbHelper.ExecuteNonQuery("UpdateThuoc", paramList);
            return i;
        }
Beispiel #7
0
        public ArrayList TimKiemThuoc(string MaThuoc,int MaNhom,int MaNSX)
        {

            SqlDataReader rd = dbHelper.ExecuteQuery("TimKiemThuoc N'%" + MaThuoc.Replace("'", "''") + "%'," + MaNhom + "," + MaNSX);
            ArrayList arrLThuoc = new ArrayList();
            while (rd.Read())
            {
                Thuoc thuoc = new Thuoc(rd.GetInt32(0), rd.GetString(1), rd.GetString(2), rd.GetInt32(22), rd.GetString(3), rd.GetString(4), rd.GetInt32(23), rd.GetString(5), rd.GetInt32(6), rd.GetDouble(7), rd.GetDecimal(8),
rd.GetInt32(24), rd.GetString(9), rd.GetInt32(25), rd.GetString(10), rd.GetInt32(11), rd.GetString(12), rd.GetString(13), rd.GetString(14),
rd.GetString(15), rd.GetString(16), rd.GetString(17), rd.GetString(18), rd.GetString(19), rd.GetString(20), rd.GetString(21));
                arrLThuoc.Add(thuoc);
            }
            rd.Close();
            return arrLThuoc;
        }
Beispiel #8
0
        public int InsertThuoc(Thuoc thuoc)
        {            
            String MaThuoc = "";

            SqlDataReader rd = dbHelper.ExecuteQuery("GetThuocLast");
            if (rd.Read())
            {
                MaThuoc = rd.GetString(0);
            }
            rd.Close();
            int index = Convert.ToInt32(MaThuoc.Substring(3, 4));
            index++;
            String text = "";
            if (index > 999)
                text = "MT_";
            else if (index > 99)
                text = "MT_0";
            else if (index>9)
                text = "MT_00";
            else 
                text = "MT_000";
            thuoc.MaThuoc = text + index.ToString()+"_"+thuoc.TenThuoc;
            List<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter param = new SqlParameter();
            param = new SqlParameter("@MaThuoc", SqlDbType.NVarChar);
            param.Value = thuoc.MaThuoc.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@TenThuoc", SqlDbType.NVarChar);
            param.Value = thuoc.TenThuoc.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@MaNhom", SqlDbType.Int);
            param.Value = thuoc.MaNhom;
            paramList.Add(param);
            param = new SqlParameter("@NguonGoc", SqlDbType.NVarChar);
            param.Value = thuoc.NguonGoc.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@MaNSX", SqlDbType.Int);
            param.Value = thuoc.MaNSX;
            paramList.Add(param);
            param = new SqlParameter("@SoLuong", SqlDbType.Int);
            param.Value = thuoc.SoLuong;
            paramList.Add(param);
            param = new SqlParameter("@Thue", SqlDbType.Float);
            param.Value = thuoc.Thue;
            paramList.Add(param);
            param = new SqlParameter("@GiaBan", SqlDbType.Money);
            param.Value = thuoc.GiaBan;
            paramList.Add(param);
            param = new SqlParameter("@MaDVT", SqlDbType.Int);
            param.Value = thuoc.MaDVT;
            paramList.Add(param);
            param = new SqlParameter("@DangDongGoi", SqlDbType.Int);
            param.Value = thuoc.DangDongGoi;
            paramList.Add(param);
            param = new SqlParameter("@SoLuongDongGoi", SqlDbType.Int);
            param.Value = thuoc.SoLuongDongGoi;
            paramList.Add(param);
            param = new SqlParameter("@SoDangKy", SqlDbType.NVarChar);
            param.Value = thuoc.SoDangKy.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@DangBaoChe", SqlDbType.NVarChar);
            param.Value = thuoc.DangBaoChe.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@ThanhPhan", SqlDbType.NVarChar);
            param.Value = thuoc.ThanhPhan.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@HamLuong", SqlDbType.NVarChar);
            param.Value = thuoc.HamLuong.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@CongDung", SqlDbType.NVarChar);
            param.Value = thuoc.CongDung.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@PhanTacDung", SqlDbType.NVarChar);
            param.Value = thuoc.PhanTacDung.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@CachDung", SqlDbType.NVarChar);
            param.Value = thuoc.CachDung.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@ChuY", SqlDbType.NVarChar);
            param.Value = thuoc.ChuY.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@HanSuDung", SqlDbType.NVarChar);
            param.Value = thuoc.HanSuDung.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@BaoQuan", SqlDbType.NVarChar);
            param.Value = thuoc.BaoQuan.Replace("'", "''");
            paramList.Add(param);

            int i = dbHelper.ExecuteNonQuery("InsertThuoc", paramList);
            return i;
            
        }
Beispiel #9
0
 private void btn_ThemThuoc_Click(object sender, EventArgs e)
 {
     Thuoc thuoc = new Thuoc();
     ChiTietThuoc ctThuoc = new ChiTietThuoc(thuoc, 1);
     ctThuoc.ShowDialog();
     DanhSachThuoc();
 }
Beispiel #10
0
        public void NhanBanDonThuoc()
        {
                if (lVSanhSachHDX.SelectedItems.Count > 0)
                {
                    HoaDonXuat hdxOLD = (HoaDonXuat)arrLAllHDX.ToArray()[lVSanhSachHDX.FocusedItem.Index];
                    if (MessageBox.Show("Bạn có muốn tạo thêm một hóa đơn như này không?!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {

                        tabControl1.TabPages.Clear();
                        tabControl1.TabPages.Add(tPTaoDon);
                        tPTaoDon.Text = "Tạo Đơn Thuốc Mới";

                        lblbtnCopy.Visible = false;
                        lblbtnXemChiTiet.Visible = false;
                        lblbtnXoa.Visible = true;
                        lblbtnSua.Visible = true;

                        benhNhanHDX = busBenhNhan.GetBenhNhanDetails(hdxOLD.IDBN);
                        txtMaBN.Text = benhNhanHDX.MaBN;
                        lblMaBN_DT.Text = benhNhanHDX.MaBN;
                        lblTenBN_DT.Text = benhNhanHDX.HoTen;
                        lblTuoiBN_DT.Text = benhNhanHDX.Tuoi.ToString();
                        lblDiaChiBN_DT.Text = benhNhanHDX.DiaChi;
                        lblSoDienThoaiBN_DT.Text = benhNhanHDX.DienThoai;

                        arrLlVChiTietHDX.Clear();
                        ArrayList arrlTemp = busHDX.GetAllChiTietHDX(hdxOLD.MaHDX);

                        foreach (ChiTietHoaDonXuat chiTietHDX in arrlTemp)
                        {
                            Thuoc thuoc = new Thuoc(chiTietHDX.IDThuoc,chiTietHDX.MaThuoc, chiTietHDX.TenThuoc, chiTietHDX.SoLuong, chiTietHDX.GiaBan, chiTietHDX.DonVi, chiTietHDX.Thue);
                            arrLlVChiTietHDX.Add(thuoc);
                        }

                        this.ThemThuocVaoDS();
                        this.TinhTienHDX();

                    }
                }
                else
                {
                    MessageBox.Show(this, "Chọn một hóa đơn", "Thông báo");
                }
            
        }
Beispiel #11
0
        public void LayMaThuocTuKQRK(Thuoc thuoc)
        {

            int SoLuong = Convert.ToInt32(txtNTBSoLuongMua.Text);
            if (SoLuong <= thuoc.SoLuong)
            {
                bool KiemTraThuoc = true;
                foreach (Thuoc thuocTemp in arrLlVChiTietHDX)
                {
                    if (thuocTemp.IDThuoc == thuoc.IDThuoc)
                    {
                        KiemTraThuoc = false;
                        MessageBox.Show(this, "Thuốc này đã có trong danh sách.\nHãy đổi số lượng mua nếu muốn mua thêm.", "Thông báo");
                        txtMaThuoc.Focus();
                    }
                }
                if (KiemTraThuoc)
                {
                    thuoc.SoLuong = SoLuong;
                    arrLlVChiTietHDX.Add(thuoc);
                    this.ThemThuocVaoDS();
                    this.TinhTienHDX();
                }
            }
            else
            {
                if (thuoc.SoLuong == 0)
                {
                    MessageBox.Show(this, "Thuốc này đã hết!", "Thông báo");
                    txtMaThuoc.Focus();
                }
                else
                {
                    MessageBox.Show(this, "Trong kho còn: [ " + thuoc.SoLuong + " " + thuoc.TenDVT + "] \nSố lượng mua vượt quá số thuốc trong kho...", "Thông báo");
                    txtNTBSoLuongMua.Focus();
                }
            }
            
        }