public static bool XoaCTTT(GhiKQVaoPKDTO a)
        {
            string sTruyVan = string.Format("update CTTT set TrangThai = '0' where MaPK='{0}' and TenThuoc=N'{1}' ", a.Mapk, a.Tenthuoc);

            Con = DataProvider.KetNoi();
            try
            {
                // thuc thi truy van
                bool KetQua = DataProvider.ThucThiNonQuery(sTruyVan, Con);
                // dong truy van
                DataProvider.DongKetNoi(Con);
                if (KetQua == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                DataProvider.DongKetNoi(Con);
                return(false);
            }
        }
Esempio n. 2
0
 private void SuaCTTTDaTonTai(GhiKQVaoPKDTO a)
 {
     if (GhiKQVaoPKBUS.SuaCTTTDaTonTai(a) == true)
     {
         return;
     }
 }
        public static bool SuaCTTTDaTonTai(GhiKQVaoPKDTO SuaDTO)
        {
            string sTruyVan = string.Format("update CTTT set TenThuoc= N'{0}', SoLuong='{1}', DonGia ={2},  CachDung=N'{3}', TrangThai = '1' where MaPK='{4}' and TenThuoc=N'{5}' ", SuaDTO.Tenthuoc, SuaDTO.Soluong, SuaDTO.Dongia, SuaDTO.Cachdung, SuaDTO.Mapk, SuaDTO.Tenthuoc);

            Con = DataProvider.KetNoi();
            try
            {
                // thuc thi truy van
                bool KetQua = DataProvider.ThucThiNonQuery(sTruyVan, Con);
                // dong truy van
                DataProvider.DongKetNoi(Con);
                if (KetQua == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                DataProvider.DongKetNoi(Con);
                return(false);
            }
        }
        public GhiKQVaoPKDTO LayGiaThuoc(GhiKQVaoPKDTO a)
        {
            string sTruyVan = " select Gia from THUOC where TenThuoc = N'" + a.Tenthuoc + "'";

            // Mo Kết Nối
            Con = DataProvider.KetNoi();
            // Tiến Hành Truy Vấn

            DataTable dt = DataProvider.LoadTable(sTruyVan, Con);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            if (dt.Rows.Count == 1)
            {
                GhiKQVaoPKDTO gkqdto = new GhiKQVaoPKDTO();
                gkqdto.Gia = float.Parse(dt.Rows[0]["Gia"].ToString());
                DataProvider.DongKetNoi(Con);
                return(gkqdto);
            }
            else
            {
                DataProvider.DongKetNoi(Con);
                return(null);
            }
        }
        // Them CTTT
        public static bool ThemCTTT(GhiKQVaoPKDTO gkqDTO)
        {
            //string sTruyVan = string.Format("insert into CTTT values (N'{0}',N'{1}','{2}','{3}', '1')", gkqDTO.Mapk, gkqDTO.Tenthuoc, gkqDTO.Soluong, gkqDTO.Cachdung, gkqDTO.Trangthai);
            string sTruyVan = string.Format("INSERT INTO CTTT (MaPK, TenThuoc, SoLuong, DonGia, CachDung, TrangThai)	 VALUES('{0}',N'{1}','{2}','{3}', N'{4}', '1')", gkqDTO.Mapk, gkqDTO.Tenthuoc, gkqDTO.Soluong, gkqDTO.Dongia, gkqDTO.Cachdung, gkqDTO.Trangthai);

            Con = DataProvider.KetNoi();
            try
            {
                // thuc thi truy van
                bool KetQua = DataProvider.ThucThiNonQuery(sTruyVan, Con);
                // dong ket noi
                DataProvider.DongKetNoi(Con);
                if (KetQua == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                DataProvider.DongKetNoi(Con);
                return(false);
            }
        }
        // Load CTTT

        public static List <GhiKQVaoPKDTO> LoadCTTT(GhiKQVaoPKDTO a)
        {
            // Khai báo truy vấn SQL

            string sTruyVan = " select CTTT.TenThuoc, CTTT.SoLuong, THUOC.DonViTinh, CTTT.CachDung from CTTT, THUOC where CTTT.TenThuoc = THUOC.TenThuoc and CTTT.TrangThai = '1' and CTTT.MaPK = '" + a.Mapk + "'";

            // Mo Kết Nối
            Con = DataProvider.KetNoi();
            // Tiến Hành Truy Vấn

            DataTable dt = DataProvider.LoadTable(sTruyVan, Con);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            //tạo list GhiKetQuaVaoPhieuKham_DTO
            List <GhiKQVaoPKDTO> listgkqdto = new List <GhiKQVaoPKDTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                GhiKQVaoPKDTO dto = new GhiKQVaoPKDTO();
                dto.Tenthuoc  = dt.Rows[i]["TenThuoc"].ToString();
                dto.Soluong   = int.Parse(dt.Rows[i]["SoLuong"].ToString());
                dto.Donvitinh = dt.Rows[i]["DonViTinh"].ToString();
                dto.Cachdung  = dt.Rows[i]["CachDung"].ToString();
                listgkqdto.Add(dto);
            }
            DataProvider.DongKetNoi(Con);
            return(listgkqdto);
        }
        public List <GhiKQVaoPKDTO> loadTenThuoc()
        {
            string query = "select TenThuoc from THUOC";

            SqlConnection connection = new SqlConnection(connectionString);

            List <GhiKQVaoPKDTO> lstDto = new List <GhiKQVaoPKDTO>();

            connection.Open();

            DataTable dt = DataProvider.LoadTable(query, connection);

            if (dt.Rows.Count == 0)
            {
                connection.Close();
                return(null);
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                GhiKQVaoPKDTO dto = new GhiKQVaoPKDTO();
                dto.Tenthuoc = dt.Rows[i]["TenThuoc"].ToString();
                lstDto.Add(dto);
            }
            connection.Close();
            return(lstDto);
        }
Esempio n. 8
0
        public void TaiDuLieuVaoDataGirdView()
        {
            if (KiemTraMaPK() == false)
            {
                return;
            }
            GhiKQVaoPKDTO a = new GhiKQVaoPKDTO();

            a.Mapk = int.Parse(txtMaPK.Text);
            if (GhiKQVaoPKBUS.LoadCTTT(a) == null)
            {
                MessageBox.Show("Không có dữ liệu chi tiết toa thuốc!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.dgvCTTT.Columns.Clear();
                return;
            }

            this.dgvCTTT.Columns.Clear();
            this.dgvCTTT.DataSource = null;

            this.dgvCTTT.AutoGenerateColumns = false;
            this.dgvCTTT.AllowUserToAddRows  = false;
            this.dgvCTTT.DataSource          = GhiKQVaoPKBUS.LoadCTTT(a);

            DataGridViewTextBoxColumn tenthuocCol = new DataGridViewTextBoxColumn();

            tenthuocCol.Name             = "TenThuoc";
            tenthuocCol.HeaderText       = "Tên thuốc";
            tenthuocCol.DataPropertyName = "TenThuoc";
            tenthuocCol.Width            = 130;
            this.dgvCTTT.Columns.Add(tenthuocCol);

            DataGridViewTextBoxColumn soluongCol = new DataGridViewTextBoxColumn();

            soluongCol.Name             = "SoLuong";
            soluongCol.HeaderText       = "Số lượng";
            soluongCol.DataPropertyName = "SoLuong";
            soluongCol.Width            = 80;
            this.dgvCTTT.Columns.Add(soluongCol);

            DataGridViewTextBoxColumn donvitinhCol = new DataGridViewTextBoxColumn();

            donvitinhCol.Name             = "DonViTinh";
            donvitinhCol.HeaderText       = "Đơn vị tính";
            donvitinhCol.DataPropertyName = "DonViTinh";
            this.dgvCTTT.Columns.Add(donvitinhCol);

            DataGridViewTextBoxColumn cachdungCol = new DataGridViewTextBoxColumn();

            cachdungCol.Name             = "CachDung";
            cachdungCol.HeaderText       = "Cách dùng";
            cachdungCol.DataPropertyName = "CachDung";
            cachdungCol.Width            = 500;
            this.dgvCTTT.Columns.Add(cachdungCol);


            CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[this.dgvCTTT.DataSource];

            myCurrencyManager.Refresh();
        }
Esempio n. 9
0
        private bool KiemTraMaPK()
        {
            GhiKQVaoPKDTO a = new GhiKQVaoPKDTO();

            if (IsNumber(txtMaPK.Text) == false || txtMaPK.Text == "")
            {
                MessageBox.Show("Bạn cần nhập mã phiếu khám là số!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            a.Mapk = int.Parse(txtMaPK.Text);
            if (gkqBus.KtMaPK(a) == false)
            {
                MessageBox.Show("Mã phiếu khám không tồn tại hoặc đã bị xóa!", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
Esempio n. 10
0
        //public GhiKQVaoPKDAO()
        //{
        //    //connectionString = ConfigurationManager.AppSettings["ConnectionString"];
        //    //connectionString = @"Data Source=DESKTOP-39B6H1E\SQLEXPRESS;Initial Catalog=QLKB1;Integrated Security=True";
        //    //ConfigurationManager.AppSettings["ConnectionString"];
        //    connectionString = @"Data Source=DESKTOP-HLJNT2J\SQLEXPRESS;Initial Catalog=QLKB;Integrated Security=True";
        //}

        //public string ConnectionString
        //{
        //    get
        //    {
        //        return connectionString;
        //    }

        //    set
        //    {
        //        connectionString = value;
        //    }
        //}
        // Kiểm tra mã phiếu khám có tồn tại hay không.

        public bool KtMaPK(GhiKQVaoPKDTO a)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            connection.Open();


            string query = "select MaPK from PHIEUKHAM where MaPK = '" + a.Mapk + "' and TrangThai = '1'";

            DataTable dt = DataProvider.LoadTable(query, connection);

            if (dt.Rows.Count == 1)
            {
                connection.Close();
                return(true);
            }
            connection.Close();
            return(false);
        }
Esempio n. 11
0
        private void LuuKetQua()
        {
            GhiKQVaoPKDTO a = new GhiKQVaoPKDTO();

            if (txtKetQua.Text == "" || txtMaPK.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập đủ thông tin", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (KiemTraMaPK() == false)
            {
                return;
            }
            a.Mapk   = int.Parse(txtMaPK.Text);
            a.Ketqua = txtKetQua.Text;

            if (gkqBus.updateKetQua(a) == true)
            {
                MessageBox.Show("Ghi kết quả thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 12
0
        // THÊM CTTT

        private void btnThem_Click(object sender, EventArgs e)
        {
            GhiKQVaoPKDTO gkqDTO = new GhiKQVaoPKDTO();

            if (txtCachDung.Text == "" || nudSoLuong.Text == "0")
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (KiemTraMaPK() == false)
            {
                return;
            }
            gkqDTO.Mapk     = int.Parse(txtMaPK.Text);
            gkqDTO.Tenthuoc = cbbTenThuoc.Text;
            //gkqDTO.Trangthai = 1;
            gkqDTO.Soluong  = int.Parse(nudSoLuong.Text);
            gkqDTO.Cachdung = txtCachDung.Text;

            if (gkqBus.LayGiaThuoc(gkqDTO) == null)
            {
                MessageBox.Show("Vui lòng nhập đúng Tên thuốc!", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            float x = gkqBus.LayGiaThuoc(gkqDTO).Gia;
            float y = x * gkqDTO.Soluong;

            gkqDTO.Dongia = y;
            if (GhiKQVaoPKBUS.ThemCTTT(gkqDTO) == false)
            {
                SuaCTTTDaTonTai(gkqDTO);
            }

            MessageBox.Show("Thêm thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);


            TaiDuLieuVaoDataGirdView();
        }
Esempio n. 13
0
        // Cập nhật kết quả vào phiếu khám.
        public bool updateKetQua(GhiKQVaoPKDTO a)
        {
            string query = "update PHIEUKHAM set KetQua = N'" + a.Ketqua + "' where MaPK ='" + a.Mapk + "'";

            SqlConnection connection = new SqlConnection(connectionString);

            connection.Open();


            try
            {
                if (DataProvider.ThucThiNonQuery(query, connection) == true)
                {
                    connection.Close();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                connection.Close();
                return(false);
            }
            return(false);
        }
Esempio n. 14
0
        private void SuaCTTT()
        {
            GhiKQVaoPKDTO SuaDTO = new GhiKQVaoPKDTO();

            if (txtCachDung.Text == "" || nudSoLuong.Text == "0")
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            SuaDTO.Tenthuoc = cbbTenThuoc.Text;
            SuaDTO.Soluong  = int.Parse(nudSoLuong.Text);
            if (gkqBus.LayGiaThuoc(SuaDTO) == null)
            {
                MessageBox.Show("Vui lòng nhập đúng Tên thuốc!", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            float x = gkqBus.LayGiaThuoc(SuaDTO).Gia;
            float y = x * SuaDTO.Soluong;

            SuaDTO.Dongia   = y;
            SuaDTO.Cachdung = txtCachDung.Text;
            if (LayDTO.Tenthuoc == null)
            {
                MessageBox.Show("Bạn phải chọn chi tiết toa thuốc trước!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (GhiKQVaoPKBUS.SuaCTTT(LayDTO, SuaDTO) == false)
            {
                XoaCTTT();
                SuaDTO.Mapk = int.Parse(txtMaPK.Text);
                SuaCTTTDaTonTai(SuaDTO);
            }

            MessageBox.Show("Sửa chi tiết toa thuốc thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            TaiDuLieuVaoDataGirdView();
        }
Esempio n. 15
0
 // Thêm Thuốc
 public static bool ThemCTTT(GhiKQVaoPKDTO gkqDTO)
 {
     return(GhiKQVaoPKDAO.ThemCTTT(gkqDTO));
 }
Esempio n. 16
0
 public bool updateKetQua(GhiKQVaoPKDTO a)
 {
     return(gkqDao.updateKetQua(a));
 }
Esempio n. 17
0
 public bool KtMaPK(GhiKQVaoPKDTO a)
 {
     return(gkqDao.KtMaPK(a));
 }
Esempio n. 18
0
 public static bool XoaCTTT(GhiKQVaoPKDTO a)
 {
     return(GhiKQVaoPKDAO.XoaCTTT(a));
 }
Esempio n. 19
0
 public GhiKQVaoPKDTO LayGiaThuoc(GhiKQVaoPKDTO a)
 {
     return(gkqDao.LayGiaThuoc(a));
 }
Esempio n. 20
0
 public static bool SuaCTTTDaTonTai(GhiKQVaoPKDTO SuaDTO)
 {
     return(GhiKQVaoPKDAO.SuaCTTTDaTonTai(SuaDTO));
 }
Esempio n. 21
0
 public static bool SuaCTTT(GhiKQVaoPKDTO LayDTO, GhiKQVaoPKDTO SuaDTO)
 {
     return(GhiKQVaoPKDAO.SuaCTTT(LayDTO, SuaDTO));
 }
Esempio n. 22
0
        ///////////////////

        public static List <GhiKQVaoPKDTO> LoadCTTT(GhiKQVaoPKDTO a)
        {
            return(GhiKQVaoPKDAO.LoadCTTT(a));
        }