private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         CheckError();
         if (isThem == true)
         {
             eThuoc newThuoc = new eThuoc();
             newThuoc.MaLoaiThuoc = cboLoaiThuoc.SelectedValue.ToString();
             newThuoc.MaThuoc     = txtMaThuoc.Text;
             newThuoc.TenThuoc    = txtTenThuoc.Text;
             newThuoc.MoTa        = txtMoTaBenh.Text;
             if (rdoTrangThai1.Checked == true)
             {
                 newThuoc.TrangThai = 1;
             }
             else
             {
                 newThuoc.TrangThai = 0;
             }
             thuocBLL.ThemThongTinThuoc(newThuoc);
             MessageBox.Show("Them thanh cong");
             clearTXT();
             isThem                   = false;
             btnThem.Text             = "Them";
             btnSua.Enabled           = true;
             btnLuu.Enabled           = false;
             dgvDanhSachThuoc.Enabled = true;
             UCQuanLiThuoc_Load(sender, e);
         }
         else
         {
             int    trangThai;
             string maThuoc     = txtMaThuoc.Text;
             string maLoaiThuoc = cboLoaiThuoc.SelectedValue.ToString();
             string tenThuoc    = txtTenThuoc.Text;
             string moTa        = txtMoTaBenh.Text;
             if (rdoTrangThai1.Checked == true)
             {
                 trangThai = 1;
             }
             else
             {
                 trangThai = 0;
             }
             thuocBLL.CapNhatThongTinThuoc(maThuoc, maLoaiThuoc, tenThuoc, moTa, trangThai);
             MessageBox.Show("Cap nhat thanh cong");
             isSua                    = false;
             btnSua.Text              = "Sua";
             btnThem.Enabled          = true;
             btnLuu.Enabled           = false;
             dgvDanhSachThuoc.Enabled = true;
             UCQuanLiThuoc_Load(sender, e);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
        private void lstDsDonThuoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            int i = lstDsDonThuoc.SelectedIndex;

            if (i == -1)
            {
                return;
            }
            eDonThuoc dt = new eDonThuoc();

            dt              = (eDonThuoc)lstDsDonThuoc.Items[i];
            lblMaDon.Text   = dt.idDonThuoc.ToString();
            lblKH.Text      = khachHangWCFClient.GetKhachHangs_byID(phieuKhamWCFClient.getPhieuKham_byID(dt.idPhieuKham).idKH).tenKH;
            lblNhaSi.Text   = nhaSiWCFClient.getNhabyID(dt.idNhaSi).tenNhaSi;
            lblNgayLap.Text = dt.ngayLap.ToShortDateString();

            DataTable tableThuoc = new DataTable();

            tableThuoc.Columns.Add("Tên thuốc");
            tableThuoc.Columns.Add("Số lượng");
            tableThuoc.Columns.Add("Đơn vị");
            tableThuoc.Columns.Add("Đơn giá");

            DataTable tableDichVu = new DataTable();

            tableDichVu.Columns.Add("Tên dịch vụ");
            tableDichVu.Columns.Add("Số lượng");
            tableDichVu.Columns.Add("Đơn giá");

            foreach (var item in chiTietDonThuocWCF.getChiTietDonThuocbyID(dt.idDonThuoc))
            {
                eThuoc           thuoc = thuocWCFClient.getThuocbyID(item.idThuoc);
                eDichVuPhongKham dv    = dichVuWCFClient.getDVbyID(item.idDV);
                if (thuoc != null)
                {
                    tableThuoc.Rows.Add(thuoc.tenThuoc, item.soLuong, thuoc.donVi, thuoc.donGia);
                }
                tableDichVu.Rows.Add(dv.tenDV, item.soLuong, dv.donGia);
            }
            dgvDonThuoc.DataSource = tableThuoc;
            dgvDichVu.DataSource   = tableDichVu;
            long tienThuoc  = 0;
            long tienDichVu = 0;

            for (int x = 0; x < tableThuoc.Rows.Count; x++)
            {
                tienThuoc += (int)tableThuoc.Rows[x]["Số lượng"] * (int)tableThuoc.Rows[x]["Đơn giá"];
            }
            for (int y = 0; y < tableDichVu.Rows.Count; y++)
            {
                tienDichVu += Convert.ToInt32(tableDichVu.Rows[y]["Số lượng"]) * Convert.ToInt32(tableDichVu.Rows[y]["Đơn giá"]);
            }
            lblTien.Text = (tienDichVu + tienThuoc).ToString();
        }
Esempio n. 3
0
        public int AddThuoc(eThuoc item)
        {
            Thuoc temp = new Thuoc();

            temp.tenThuoc = item.tenThuoc;
            temp.donGia   = item.donGia;
            temp.moTa     = item.moTa;
            temp.donVi    = item.donVi;
            db.thuocs.Add(temp);
            return(db.SaveChanges());
        }
        public void ThemThongTinThuoc(eThuoc thuocMoi)
        {
            Thuocs temp = new Thuocs();

            temp.MaLoaiThuoc = thuocMoi.MaLoaiThuoc;
            temp.MaThuoc     = thuocMoi.MaThuoc;
            temp.TenThuoc    = thuocMoi.TenThuoc;
            temp.TrangThai   = thuocMoi.TrangThai;
            temp.MoTa        = thuocMoi.MoTa;

            qt.Thuocs.InsertOnSubmit(temp);
            qt.SubmitChanges();
        }
        public List <eThuoc> LayThongTinThuoc()
        {
            var           dsThuoc = qt.Thuocs.ToList();
            List <eThuoc> dst     = new List <eThuoc>();

            foreach (Thuocs ts in dsThuoc)
            {
                eThuoc t = new eThuoc();
                t.MaThuoc     = ts.MaThuoc;
                t.MaLoaiThuoc = ts.MaLoaiThuoc;
                t.TenThuoc    = ts.TenThuoc;
                t.TrangThai   = ts.TrangThai;
                t.MoTa        = ts.MoTa;
                dst.Add(t);
            }
            return(dst);
        }
Esempio n. 6
0
        public eThuoc getThuocbyID(int id)
        {
            Thuoc item = db.thuocs.Where(x => x.idThuoc == id).FirstOrDefault();

            if (item == null)
            {
                return(null);
            }
            eThuoc temp = new eThuoc();

            temp.idThuoc  = item.idThuoc;
            temp.tenThuoc = item.tenThuoc;
            temp.donGia   = item.donGia;
            temp.moTa     = item.moTa;
            temp.donVi    = item.donVi;
            return(temp);
        }
Esempio n. 7
0
        public List <eThuoc> GetThuocs()
        {
            var           list   = db.thuocs.ToList();
            List <eThuoc> listkh = new List <eThuoc>();

            foreach (var item in list)
            {
                eThuoc temp = new eThuoc();
                temp.idThuoc  = item.idThuoc;
                temp.tenThuoc = item.tenThuoc;
                temp.donGia   = item.donGia;
                temp.moTa     = item.moTa;
                temp.donVi    = item.donVi;

                listkh.Add(temp);
            }
            return(listkh);
        }