public static List <ThuocDTO> SelectAllThuoc() { List <ThuocDTO> listThuoc = null; string sql = "Select * from Thuoc"; DataTable dt = DataProvider.ExecQuery(sql); if (dt != null && dt.Rows.Count > 0) { listThuoc = new List <ThuocDTO>(); foreach (DataRow row in dt.Rows) { ThuocDTO Thuoc = new ThuocDTO(); Thuoc.MaThuoc = row.ItemArray[0].ToString(); Thuoc.TenThuoc = row.ItemArray[1].ToString(); Thuoc.DonVi = row.ItemArray[2].ToString(); Thuoc.CachDung = row.ItemArray[3].ToString(); Thuoc.SoLuong = int.Parse(row.ItemArray[4].ToString()); Thuoc.GiaThuoc = int.Parse(row.ItemArray[5].ToString()); Thuoc.MoTa = row.ItemArray[6].ToString(); listThuoc.Add(Thuoc); } } return(listThuoc); }
private void btnThayDoi_Click(object sender, EventArgs e) { ThuocDTO Thuoc = new ThuocDTO(); Thuoc.MaThuoc = cbbMaThuoc1.Text; Thuoc.GiaThuoc = int.Parse(txtGiaThuoc1.Text); DbAck ack = ThuocBUS.Update(Thuoc); if (ack == DbAck.Ok) { MessageBox.Show("Thay đổi thành công", "Thông báo"); LoadListThuoc(); GetMaThuoc(); txtGiaThuoc1.Text = null; } else { if (ack == DbAck.Unknown) { MessageBox.Show("Lỗi không xác định", "Thông báo"); } else { } } }
public static DbAck Delete(ThuocDTO Thuoc) { DbAck result = DbAck.Unknown; result = ThuocDAO.Delete(Thuoc); return(result); }
public void themdonvi_thuoc() { ThuocDTO thuoc = new ThuocDTO(); thuocbus = new ThuocBUS(); bool kq = thuocbus.themcd("Vỉ"); Assert.AreEqual(true, kq); }
public void suacachdung_thuoc() { ThuocDTO thuoc = new ThuocDTO(); thuocbus = new ThuocBUS(); bool kq = thuocbus.thaydoiCD("Ăn", "Uống"); Assert.AreEqual(true, kq); }
public static DbAck Insert(ThuocDTO Thuoc) { DbAck result = DbAck.Unknown; result = ThuocDAO.Insert(Thuoc); return(result); }
public void xoacachdung_thuoc() { ThuocDTO thuoc = new ThuocDTO(); thuocbus = new ThuocBUS(); bool kq = thuocbus.xoaCD("Ăn"); Assert.AreEqual(true, kq); }
public void suadonvi_thuoc() { ThuocDTO thuoc = new ThuocDTO(); thuocbus = new ThuocBUS(); bool kq = thuocbus.thaydoiDV("Bình", ""); Assert.AreEqual(true, kq); }
public void xoadonvi_thuoc() { ThuocDTO thuoc = new ThuocDTO(); thuocbus = new ThuocBUS(); bool kq = thuocbus.xoaCD("Vỉ"); Assert.AreEqual(true, kq); }
public void XoaThuoc() { ThuocDTO thuoc = new ThuocDTO(); thuocbus = new ThuocBUS(); thuoc.MaThuoc = "32"; bool kq = thuocbus.xoa(thuoc); Assert.AreEqual(true, kq); }
public static DbAck Delete(ThuocDTO Thuoc) { string sql = "delete from Thuoc where ma_thuoc = @Ma"; Dictionary <string, object> parameter = new Dictionary <string, object>(); parameter.Add("@Ma", Thuoc.MaThuoc); DbAck result = DataProvider.ExecNonQuery(sql, parameter); return(DbAck.Ok); }
public void SuaThuoc() { ThuocDTO thuoc = new ThuocDTO(); thuocbus = new ThuocBUS(); thuoc.MaThuoc = "32"; thuoc.TenThuoc = "Teroxin"; thuoc.DonGia = 40000; thuoc.CachDung = "Uống"; thuoc.DVT = "Viên"; Assert.AreEqual(true, thuocbus.sua(thuoc, "32")); }
public static DbAck Update(ThuocDTO Thuoc) { string sql = "update Thuoc set gia_thuoc = @Gia where ma_thuoc= @Ma"; Dictionary <string, object> parameter = new Dictionary <string, object>(); parameter.Add("@Ma", Thuoc.MaThuoc); parameter.Add("@Gia", Thuoc.GiaThuoc); DbAck result = DataProvider.ExecNonQuery(sql, parameter); return(result); }
public static bool XoaThuoc(ThuocDTO th) { try { string sql = @"DELETE from Thuoc WHERE MaThuoc='" + th.MaThuoc + "' "; ConnectionData.ExeNonQuery(sql); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
public void ThemThuoc() { ThuocDTO thuoc = new ThuocDTO(); thuocbus = new ThuocBUS(); thuoc.MaThuoc = thuocbus.autogenerate_mathuoc().ToString(); thuoc.TenThuoc = "Teroxin"; thuoc.DonGia = 50000; thuoc.CachDung = "Uống"; thuoc.DVT = "Viên"; bool kq = thuocbus.them(thuoc); Assert.AreEqual(true, kq); }
public async Task <BaseResponse> Update(ThuocDTO thuocDTO) { try { var result = _thuocService.Update(thuocDTO); if (result) { return(await Task.FromResult(new BaseResponse(result))); } return(await Task.FromResult(new BaseResponse(Message.UpdateNotSuccess, false)).ConfigureAwait(false)); } catch (Exception e) { return(await Task.FromResult(new BaseResponse(Message.UpdateNotSuccess, false)).ConfigureAwait(false)); } }
public static bool ThemThuoc(ThuocDTO th) { try { string sql = @"INSERT INTO Thuoc (MaThuoc,TenThuoc,MaNhom,MaNSX,DVBan,DonGia,QuyCach) Values('" + th.MaThuoc + "', N'" + th.TenThuoc + "', '" + th.MaNhom + "', " + "'" + th.MaNSX + "', '" + th.DVBan + "', '" + th.DonGia + "', N'" + th.QuyCach + "')"; ConnectionData.ExeNonQuery(sql); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
public static bool SuaThuoc(ThuocDTO th) { try { string sql = @"UPDATE Thuoc SET TenThuoc= N'" + th.TenThuoc + "', MaNhom= '" + th.MaNhom + "', " + "MaNSX= '" + th.MaNSX + "', DVBan= '" + th.DVBan + "', DonGia= '" + th.DonGia + "', " + "QuyCach= N'" + th.QuyCach + "' WHERE MaThuoc= '" + th.MaThuoc + "'"; ConnectionData.ExeNonQuery(sql); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
public async Task <BaseResponse> Create(ThuocDTO thuocDto) { try { var result = _thuocService.Create(thuocDto); if (result) { return(await Task.FromResult(new BaseResponse(result))); } return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess))); } catch (Exception e) { return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess))); } }
private void grid_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataGrid gd = (DataGrid)sender; DataRowView row_selected = gd.SelectedItem as DataRowView; th = new ThuocDTO(); if (row_selected != null) { th.TenThuoc = row_selected["tenThuoc"].ToString(); th.MaThuoc = row_selected["maThuoc"].ToString(); th.DVT = row_selected["DVT"].ToString(); th.DonGia = float.Parse(row_selected["Dongia"].ToString()); th.CachDung = row_selected["CachDung"].ToString(); temp = th.MaThuoc.ToString(); } }
public Int64 Insert(ThuocDTO _nv) { string[] str = new string[2]; object[] val = new object[2]; str[0] = "@tenThuoc"; str[1] = "@gia"; val[0] = _nv.tenThuoc; val[1] = _nv.gia; DataProvider dp = new DataProvider(); return(dp.WriteDataAddParam("SP_InsertThuoc", str, val, 50)); }
public Int64 Update(ThuocDTO _nv) { string[] str = new string[3]; object[] val = new object[3]; str[0] = "@tenThuoc"; str[1] = "@gia"; str[2] = "@id"; val[0] = _nv.tenThuoc; val[1] = _nv.gia; val[2] = _nv.id; DataProvider dp = new DataProvider(); return(dp.WriteDataAddParam("SP_UpdateThuoc", str, val, 50)); }
private void MenuItem_Click_1(object sender, RoutedEventArgs e) { th = new ThuocDTO(); th.MaThuoc = temp; thBus = new ThuocBUS(); bool kq = thBus.xoa(th); if (kq == false) { MessageBox.Show("Xóa Thuốc thất bại. Vui lòng kiểm tra lại dũ liệu", "Result", MessageBoxButton.OKCancel, MessageBoxImage.Warning); } else { MessageBox.Show("Xóa Thuốc thành công", "Result"); } load_data(); }
private void Them_Click(object sender, RoutedEventArgs e) { bool kt; try { float.Parse(dongia.Text); kt = true; } catch (Exception) { MessageBox.Show("Vui lòng nhập số trên trường đơn giá và không được để trống", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); kt = false; } if (kt == false) { dongia.Text = ""; dongia.Focus(); } else if (mathuoc.Text == "" || tenthuoc.Text == "" || cachdung.Text == "" || donvi.Text == "") { MessageBox.Show("Vui lòng nhập đầy đủ thông tin loại thuốc"); } else { ThuocDTO th = new ThuocDTO(); th.MaThuoc = mathuoc.Text; th.TenThuoc = tenthuoc.Text; th.DonGia = float.Parse(dongia.Text); th.CachDung = cachdung.Text; th.DVT = donvi.Text; thBus = new ThuocBUS(); bool kq = thBus.them(th); if (kq == false) { MessageBox.Show("Thêm Thuốc thất bại. Vui lòng kiểm tra lại dũ liệu", "Result", MessageBoxButton.OKCancel, MessageBoxImage.Warning); } else { MessageBox.Show("Thêm Thuốc thành công", "Result"); } } }
public static DbAck Insert(ThuocDTO Thuoc) { string sql = "insert into Thuoc(ma_thuoc,ten_thuoc,don_vi,cach_dung,so_luong,gia_thuoc,mo_ta) values(@Ma,@Ten,@DonVi,@CachDung,@Sl,@Gia,@Mota)"; Dictionary <string, object> parameter = new Dictionary <string, object>(); parameter.Add("@Ma", Thuoc.MaThuoc); parameter.Add("@Ten", Thuoc.TenThuoc); parameter.Add("@DonVi", Thuoc.DonVi); parameter.Add("@CachDung", Thuoc.CachDung); parameter.Add("@SL", Thuoc.SoLuong); parameter.Add("@Gia", Thuoc.GiaThuoc); parameter.Add("@Mota", Thuoc.MoTa); DbAck result = DataProvider.ExecNonQuery(sql, parameter); return(result); }
public bool Create(ThuocDTO thuocDto) { try { var item = CheckExistsTenThuoc(thuocDto.TenThuoc); if (item) { return(false); } var thuoc = new Thuoc { MaThuoc = Guid.NewGuid(), TenThuoc = thuocDto.TenThuoc, CongDung = thuocDto.CongDung, CachDung = thuocDto.CachDung, HinhAnh = thuocDto.HinhAnh, LuuY = thuocDto.LuuY, LieuDung = thuocDto.LieuDung }; _thuocRepository.Insert(thuoc); _unitOfWork.Commit(); if (thuocDto.MaBenhs != null) { foreach (var mabenh in thuocDto.MaBenhs) { var thuocdieutri = new ThuocDieuTri { MaThuoc = thuoc.MaThuoc, MaBenh = new Guid(mabenh) }; _thuocdieutriRepository.Insert(thuocdieutri); } _unitOfWork.Commit(); } return(true); } catch (Exception e) { return(false); } }
private void tb_xoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn muốn xóa thông tin thuốc?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { ThuocDTO thDTO = new ThuocDTO(); thDTO.MaThuoc1 = tb_mathuoc.Text; bool kq = bus.xoa(thDTO); if (kq == false) { MessageBox.Show("Xóa thông tin thuốc thất bại."); } else { MessageBox.Show("Xóa thông tin thuốc thành công"); dataGridView1.DataSource = bus.loadDuLieuThuoc();//load lại dữ liệu cho datagridview } KhoaButton(); } }
public bool Update(ThuocDTO thuocDto) { try { var thuoc = _thuocRepository.GetById(thuocDto.MaThuoc); if (thuoc == null) { return(false); } // Update chi tiet thuoc.MaThuoc = thuocDto.MaThuoc; thuoc.TenThuoc = thuocDto.TenThuoc.ToLower(); thuoc.CongDung = thuocDto.CongDung; thuoc.CachDung = thuocDto.CachDung; thuoc.HinhAnh = thuocDto.HinhAnh; thuoc.LuuY = thuocDto.LuuY; thuoc.LieuDung = thuocDto.LieuDung; //update thuốc điều trị var thuocdieutriOld = _thuocdieutriRepository.GetMany(p => p.MaThuoc == thuoc.MaThuoc).ToList(); _thuocdieutriRepository.RemoveMultiple(thuocdieutriOld); var benhs = _benhRepository.GetMany(r => thuocDto.MaBenhs.Contains(r.MaBenh.ToString())); foreach (var benh in benhs) { var thuocdieutri = new ThuocDieuTri { MaBenh = benh.MaBenh, MaThuoc = thuoc.MaThuoc }; _thuocdieutriRepository.Insert(thuocdieutri); } // update user _thuocRepository.Update(thuoc); _unitOfWork.Commit(); return(true); } catch (Exception ex) { return(false); } }
//thêm private void btnThem_Click(object sender, EventArgs e) { ThuocDTO Thuoc = new ThuocDTO(); Thuoc.MaThuoc = txtMaThuoc.Text; Thuoc.TenThuoc = txtTenThuoc.Text; Thuoc.DonVi = cbbDonVi.Text; Thuoc.CachDung = cbbCachDung.Text; Thuoc.SoLuong = int.Parse(txtSoLuong.Text); Thuoc.GiaThuoc = int.Parse(txtGiaThuoc.Text); Thuoc.MoTa = txtMoTa.Text; DbAck ack = ThuocBUS.Insert(Thuoc); if (ack == DbAck.Ok) { MessageBox.Show("Thêm thành công", "Thông báo"); LoadListThuoc(); GetMaThuoc(); txtMaThuoc.Text = null; txtTenThuoc.Text = null; cbbDonVi.Text = null; cbbCachDung.Text = null; txtSoLuong.Text = null; txtGiaThuoc.Text = null; } else { if (ack == DbAck.Unknown) { MessageBox.Show("Lỗi không xác định", "thông báo"); } else { } } }
public string GetListThuoc(QLPHONGKHAMEntities db, out List <ThuocDTO> ListThuocEntity) { ListThuocEntity = new List <ThuocDTO>(); List <THUOC> listObjectDAO = null; if (donThuocService.Select(db, out listObjectDAO) == Constant.RES_FAI) { return(Constant.RES_FAI); } if (listObjectDAO == null) { return(Constant.RES_FAI); } foreach (var thuoc in listObjectDAO) { // tạo đối tượng entity ThuocDTO thuocEntity = new ThuocDTO(); // copy property BUS.Com.Utils.CopyPropertiesFrom(thuoc, thuocEntity); // add vào list ouput ListThuocEntity.Add(thuocEntity); } return(Constant.RES_SUC); }