コード例 #1
0
        public SACHKHUYENMAI deleteSachKhuyenMai(string MaSachKhuyenMai)
        {
            SACHKHUYENMAI skm = (from c in entity.SACHKHUYENMAIs where c.MASACH == MaSachKhuyenMai select c).FirstOrDefault();

            entity.SACHKHUYENMAIs.Remove(skm);
            entity.SaveChanges();
            return(skm);
        }
コード例 #2
0
        private SACHKHUYENMAI ViewToModel()
        {
            SACHKHUYENMAI skm = new SACHKHUYENMAI();

            skm.MASACH     = view.MASACH;
            skm.MUCGIAMGIA = view.MUCGIAMGIA;

            return(skm);
        }
コード例 #3
0
 public void showSelected()
 {
     if (view.selectedSackKhuyenMai != "")
     {
         SACHKHUYENMAI kho = repository.getSachKhuyenMai(view.selectedSackKhuyenMai);
         ModelToView(kho);
         //view.SachKhuyenMai = kho;
     }
 }
コード例 #4
0
 public SACHKHUYENMAI saveSachKhuyenMai(SACHKHUYENMAI sachkhuyenmai)
 {
     try
     {
         entity.SACHKHUYENMAIs.Add(sachkhuyenmai);
         entity.SaveChanges();
         return(sachkhuyenmai);
     }
     catch (DbUpdateException) // tranh loi update
     {
         return(null);
     }
 }
コード例 #5
0
        public void saveSachKhuyenMai()
        {
            //SACHKHUYENMAI kho = repository.getSachKhuyenMai(view.selectedSachKhuyenMai);
            SACHKHUYENMAI kho = ViewToModel();

            if (valid(kho))
            {
                SACHKHUYENMAI kq = repository.saveSachKhuyenMai(kho);

                //view.Log("Đã lưu thành công");
                getListSachKhuyenMai();
            }
        }
コード例 #6
0
        public SACHKHUYENMAI editSachKhuyenMai(SACHKHUYENMAI sachkhuyenmai, string oldMasach)
        {
            SACHKHUYENMAI skm = (from c in entity.SACHKHUYENMAIs where c.MASACH == oldMasach select c).FirstOrDefault();

            //kho_re.MASACH = kho.MASACH;
            //saveSachKhuyenMai(sachkhuyenmai);
            //deleteSachKhuyenMai(skm.MASACH);
            //kho_re.SOLUONGCON = kho.SOLUONGCON;
            //kho_re.TONGSOLUONG = kho.TONGSOLUONG;
            skm.MUCGIAMGIA = sachkhuyenmai.MUCGIAMGIA;
            entity.SaveChanges();

            return(skm); //kho cu
        }
コード例 #7
0
        public void deleteSachKhuyenMai()
        {
            //SACHKHUYENMAI kho = repository.getSachKhuyenMai(view.selectedSachKhuyenMai);
            string makho = view.selectedSackKhuyenMai;

            if (makho != "")
            {
                SACHKHUYENMAI kho = repository.getSachKhuyenMai(makho);

                SACHKHUYENMAI kq = repository.deleteSachKhuyenMai(makho);

                //view.Log("Đã lưu thành công");
                getListSachKhuyenMai();
            }
        }
コード例 #8
0
 public bool valid(SACHKHUYENMAI skm)
 {
     //xet null
     state.Clear();
     if (repository.getSachKhuyenMai(skm.MASACH) != null)
     {
         state.addError("masach", "Mã Sách đã tồn tại được chọn");
     }
     //if (kho.TONGSOLUONG < 0)
     //    state.addError("tongsoluong", "Tổng số lượng không được nhỏ hơn 0");
     //if (kho.SOLUONGCON > kho.TONGSOLUONG)
     //    state.addError("lonhon", "Số lượng còn không được lớn hơn tổng số lượng");
     //if (kho.MASACH == "")
     //    state.addError("sach", "Không còn sách để thêm thông tin");
     return(state.isValid());
 }
コード例 #9
0
        public void editSachKhuyenMai()
        {
            SACHKHUYENMAI kho_moi = ViewToModel();

            string makho_cu = view.selectedSackKhuyenMai;

            if (makho_cu != "")
            {
                kho_moi.MASACH = makho_cu;

                SACHKHUYENMAI kq = repository.editSachKhuyenMai(kho_moi, makho_cu);


                getListSachKhuyenMai();
            }
        }
コード例 #10
0
 private void ModelToView(SACHKHUYENMAI skm)
 {
     view.MASACH     = skm.MASACH;
     view.MUCGIAMGIA = skm.MUCGIAMGIA;
 }