Esempio n. 1
0
        public bool Create(SachModel model)
        {
            string msgError = "";

            try
            {
                var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "Sach_create",
                                                                              "@ID_Sach", model.ID_Sach,
                                                                              "@ID_LoaiS", model.ID_LoaiS,
                                                                              "@Ten_Sach", model.Ten_Sach,
                                                                              "@Noi_XB", model.Noi_XB,
                                                                              "@Nam_XB", model.Nam_XB,
                                                                              "@ISBN", model.ISBN
                                                                              );
                if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError))
                {
                    throw new Exception(Convert.ToString(result) + msgError);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public bool Update(SachModel model)
        {
            string msgError = "";

            try
            {
                var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_sach_update",
                                                                              "@masach", model.masach,
                                                                              "@tensach", model.tensach,
                                                                              "@giaban", model.giaban,
                                                                              "@mota", model.mota,
                                                                              "@anhbia", model.anhbia,
                                                                              "@soluongton", model.soluongton,
                                                                              "@manxb", model.manxb,
                                                                              "@machude", model.machude);
                if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError))
                {
                    throw new Exception(Convert.ToString(result) + msgError);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
 public IActionResult Create(SachModel model)
 {
     ViewData["TheLoaiId"] = new SelectList(_theLoaiService.GetAll(), "Id", "TenTheLoai");
     if (ModelState.IsValid)
     {
         _sachService.ThemSach(model);
         return(Redirect("Index"));
     }
     return(View(model));
 }
Esempio n. 4
0
 public SachModel UpdateSach([FromBody] SachModel model)
 {
     if (model.anhbia != null)
     {
         var arrData = model.anhbia.Split(';');
         if (arrData.Length == 3)
         {
             var savePath = $@"{arrData[0]}";
             model.anhbia = $"{savePath}";
             SaveFileFromBase64String(savePath, arrData[2]);
         }
     }
     _SachBusiness.Update(model);
     return(model);
 }
        public void ThemSach(SachModel model)
        {
            Sach entity = new Sach()
            {
                Tensach      = model.Tensach,
                TacGia       = model.TacGia,
                TheLoaiId    = model.TheLoaiId,
                NamXuatBan   = model.NamXuatBan,
                NhaXuatBan   = model.NhaXuatBan,
                NgayNhapSach = model.NgayNhapSach,
                TinhTrang    = model.TinhTrang
            };

            _sachRepository.Insert(entity);
        }
Esempio n. 6
0
 public IHttpActionResult Put(SachModel model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("error"));
     }
     if (sDAL.Update(new Sach()
     {
         MaSach = model.MaSach,
         TenSach = model.TenSach,
         NamXB = model.NamXB,
         NhaXB = model.NhaXB,
         Email = model.Email,
         MaLoai = model.MaLoai
     }))
     {
         return(Ok());
     }
     return(BadRequest("error"));
 }
Esempio n. 7
0
        public IHttpActionResult GetSachById(int id)
        {
            SachModel tmp = null;

            tmp = db.Saches.Where(k => k.Id == id)
                  .Select(k => new SachModel()
            {
                Id          = k.Id,
                Ma          = k.Ma,
                Ten         = k.Ten,
                NoiXuatBan  = k.NoiXuatBan,
                NamHoc      = k.NamHoc,
                KiHoc       = k.KiHoc,
                SoThanhVien = k.SoThanhVien,
                IdLoaiSach  = k.IdLoaiSach,
                LoaiSach    = k.IdLoaiSach == null ? null : new LoaiSachModel()
                {
                    Id  = k.LoaiSach.Id,
                    Ten = k.LoaiSach.Ten
                }
            }).FirstOrDefault <SachModel>();

            return(Ok(tmp));
        }
Esempio n. 8
0
 public SachModel UpdateUser([FromBody] SachModel model)
 {
     _SachBLL.Update(model);
     return(model);
 }
Esempio n. 9
0
 public SachModel CreateItem([FromBody] SachModel model)
 {
     model.ID_Sach = Guid.NewGuid().ToString();
     _SachBLL.Create(model);
     return(model);
 }
Esempio n. 10
0
 public bool Update(SachModel model)
 {
     return(_res.Update(model));
 }
Esempio n. 11
0
 public bool Create(SachModel model)
 {
     return(_res.Create(model));
 }
Esempio n. 12
0
 public List <SachModel> GetListTableModelBySearch(string search)
 {
     return(SachModel.ToListByListSach(_sachControls.GetBySearch(search)));
 }
Esempio n. 13
0
        private void gridSach_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
        {
            try {
                SachModel      select = gridSach.SelectedItem as SachModel;
                SachController sc     = new SachController();
                Sach           sach   = sc.GetById(select.MaSach);
                _txttensach.Text    = sach.TenSach;
                _txtsotrang.Text    = sach.SoTrang.ToString();
                _txtsoluog.Text     = sach.TongSoSach.ToString();
                _txtnamxb.Text      = sach.NamXuatBan.ToString("dd/MM/yyyy");
                _txtmasach.Text     = sach.MaSach;
                _txtsachdamuon.Text = sach.LuongDaMuon.ToString();
                if (sach.TheLoai != null)
                {
                    try
                    {
                        View_Models.TheLoai        selected = _cbbtheloai.SelectedItem as View_Models.TheLoai;
                        List <View_Models.TheLoai> cboxList = _cbbtheloai.ItemsSource as List <View_Models.TheLoai>;
                        selected = cboxList.SingleOrDefault(m => m.MaTheLoai == sach.MaTheLoai);
                        _cbbtheloai.SelectedItem = selected;
                    }
                    catch (Exception)
                    {
                        _cbbtheloai.SelectedItem = null;
                    }
                }
                else
                {
                    _cbbtheloai.SelectedItem = null;
                }
                _imagebooks.Source = App.ConvertByteArrayToBitmapImage(sach.ImageSach) != null?App.ConvertByteArrayToBitmapImage(sach.ImageSach) : null;

                if (sach.NhaXB != null)
                {
                    try
                    {
                        View_Models.NhaXB        selected = _cbbnxb.SelectedItem as View_Models.NhaXB;
                        List <View_Models.NhaXB> cboxList = _cbbnxb.ItemsSource as List <View_Models.NhaXB>;
                        selected             = cboxList.SingleOrDefault(m => m.MaNXB == sach.MaNXB);
                        _cbbnxb.SelectedItem = selected;
                    }
                    catch (Exception)
                    {
                        _cbbnxb.SelectedItem = null;
                    }
                }
                else
                {
                    _cbbnxb.SelectedItem = null;
                }
                if (sach.TacGia != null)
                {
                    try
                    {
                        View_Models.TacGia        selected = _cbbtacgia.SelectedItem as View_Models.TacGia;
                        List <View_Models.TacGia> cboxList = _cbbtacgia.ItemsSource as List <View_Models.TacGia>;
                        selected = cboxList.SingleOrDefault(m => m.MaTacGia == sach.MaTacGia);
                        _cbbtacgia.SelectedItem = selected;
                    }
                    catch (Exception)
                    {
                        _cbbtacgia.SelectedItem = null;
                    }
                }
                else
                {
                    _cbbtacgia.SelectedItem = null;
                }
            }
            catch
            { }
        }
 public void SuaSach(SachModel model)
 {
     throw new NotImplementedException();
 }