public UserManagementForm(Feature feature, MainForm mainForm)
 {
     InitializeComponent();
     _feature = feature;
     _mainForm = mainForm;
     InitializeData();
 }
 //public ExpandRentalForm()
 //{
 //    InitializeComponent();
 //}
 public ExpandRentalForm(Feature feature, RentalDTO rentalDto)
 {
     InitializeComponent();
     _feature = feature;
     _rental = rentalDto;
     InitializeData();
 }
        public ActionResult ChangePassword(FormCollection collection)
        {
            if (Session["USER"] != null)
            {
                UserBUS bus = new UserBUS();
                UserDTO user = (UserDTO)Session["USER"];
                string oldPass = collection["txtOldPassword"];
                string newPass = collection["txtNewPassword"];

                if (!user.Password.Equals(oldPass))
                {
                    ViewData["RESULT"] = "0";
                    return View();
                }
                else
                {
                    Feature f = new Feature();
                    ViewData["RESULT"] = f.ChangePassword(user, newPass) ? "1" : "0";

                    return View();
                }
            }

            return RedirectToAction("Index", "Home");
        }
 //public ReturnBookForm()
 //{
 //    InitializeComponent();
 //}
 public ReturnBookForm(Feature feature, RentalDTO selectedRental)
 {
     InitializeComponent();
     _feature = feature;
     _rental = selectedRental;
     InitializeData();
 }
        public string GetRegisterByUserIdPaging(int p)
        {
            UserDTO user = (UserDTO) Session["USER"];
            int NoP = 0;
            string rs = "";
            Feature f = new Feature();
            List<BookRegisterDTO> rtd = f.GetRegisterByUserIdPaging(user, p, out NoP);

            foreach (BookRegisterDTO register in rtd)
            {
                rs += "<tr>";
                rs += "<td width=\"150px\">" + register.BookTitle + "</td>";
                rs += "<td style=\"color:red\">" + register.RegisterDate.ToShortDateString() + "</td>";
                rs += "<td style=\"color:darkgreen\">" + EnumHelper.GetDescription(register.Status) + "</td>";
                rs += "<td style=\"color:darkgreen\">" +
                      (register.Status == BookRegisterStatus.NEW
                           ? "<span class=\"button_01\"><a href=\"/Shared/CancelRegister/?ui=" + register.UserId + "&rd=" + register.RegisterDate.Ticks + "&ri=" + register.ISBN + "\" style=\"width:70px\">Huỷ</a></span>"
                           : "") + "</td>";
                rs += "</tr>";
            }

            rs += "<tr><td colspan=\"4\" align=\"center\">" + Paging(p, NoP, "setvalRegister") + "</td></tr>";

            return rs;
        }
        public string GetRentalByUserIdPaging(int p)
        {
            UserDTO user = (UserDTO)Session["USER"];
            string rs = "";
            int NoP = 0;
            Feature f = new Feature();
            List<RentalDTO> rtd = f.GetRentalByUserIdPaging(user, p, out NoP);

            foreach (RentalDTO rental in rtd)
            {
                //if (rental.Status == RentalStatus.NEW)
                {
                    rs += "<tr>";
                    rs += "<td width=\"150px\">" + rental.BookTitle + "</td>";
                    rs += "<td style=\"color:darkgreen\">" + rental.Barcode + "</td>";
                    rs += "<td style=\"color:red\">" + rental.DueDate.ToShortDateString() + "</td>";
                    rs += "<td style=\"color:" + (rental.Status == RentalStatus.NEW ? "red" : "darkblue") + "\">" +
                          EnumHelper.GetDescription(rental.Status) + "</td>";
                    rs += "</tr>";
                }
            }

            rs += "<tr><td colspan=\"4\" align=\"center\">" + Paging(p, NoP, "setvalRental") + "</td></tr>";

            return rs;
        }
 public Refresher(Feature feature, RegisterRentalForm registerRentalForm)
 {
     _registerRentalForm = registerRentalForm;
     _feature = feature;
     _listNewRegister = new List<BookRegisterDTO>();
     LastUpdateTime = DateTime.Now;
     RefreshInterval = 10 * 1000;
 }
 public UserEditForm(Feature feature, UserDTO userDto)
 {
     InitializeComponent();
     _feature = feature;
     _selectedUser = userDto;
     InitializeControlStatus();
     InitializeData();
 }
        public ActionResult CancelRegister(string ui, string rd, string ri)
        {
            long ticks;
            long.TryParse(rd, out ticks);
            DateTime registerDate = new DateTime(ticks);

            Feature f = new Feature();
            f.DeleteRegister(ui, ri, registerDate);

            return RedirectToAction("Information", "Account");
        }
        public MainForm()
        {
            _feature = new Feature();

            InitializeComponent();

            pageCatalogueManagement.Visible = false;
            pageUser.Visible = false;
            pageRegisterRental.Visible = false;

            ribbon.SelectedPage = pageMain;

            //Help.ShowHelp(this, "HELP.chm", HelpNavigator.Topic, "14_3.2.IterationobjectivesL9.htm");
        }
        public RegisterRentalForm(Feature feature, MainForm mainForm)
        {
            InitializeComponent();
            cboRentalStatus.Text = "Tất cả";
            cboRequestStatus.Text = "Tất cả";
            _feature = feature;
            _mainForm = mainForm;
            InitializeData();

            // new thread
            _refresher = new Refresher(_feature, this);
            _refresher.LastUpdateTime = DateTime.Now;
            _threadRefresh = new Thread(_refresher.GetNewRegister);
            _threadRefresh.Start();
        }
        public ActionResult ResetPassword(FormCollection collection)
        {
            UserBUS bus = new UserBUS();
            UserDTO user = bus.GetUserById(collection["txtUserId"]);

            if (user == null)
            {
                ViewData["RESULT"] = "0";
            }
            else
            {
                ViewData["RESULT"] = "1";
                Feature f = new Feature();
                f.ResetPassword(user);
            }
            return View();
        }
 public string RentalService(string isbn)
 {
     string rs = "";
     if (Session["USER"] == null)
     {
         rs = "Nếu muốn mượn sách, bạn phải đăng nhập. <br /> <div style=\"text-align:center; padding-left:20px; padding-top:5px; padding-bottom:5px\"><span class=\"button_01\"><a href=\"/Account/LogOn?returnUrl=" + Request.Url + "\"> Đăng nhập </a></span></div>";
     }
     else
     {
         UserDTO user = (UserDTO)Session["USER"];
         Feature f= new Feature();
         BookRegisterBUS bus = new BookRegisterBUS();
         if (user.ExpiredDate < DateTime.Now)
             rs = "<div style=\"text-align:center; padding-left:20px; padding-top:5px; padding-bottom:5px\"><span class=\"button_02\"><a href=\"javascript:void(0);\">Thẻ hết hạn</a></span></div>";
         else if (bus.GetBookRegisterByUserId(user.UserId).Find(r => (r.ISBN == isbn) && (r.Status == BookRegisterStatus.NEW)) == null)
             rs = "<div style=\"text-align:center; padding-left:20px; padding-top:5px; padding-bottom:5px\"><span class=\"button_01\"><a href=\"/Shared/RegisterRental/" + isbn + "\" onclick=\"return confirm('Bạn có chắc muốn đăng ký mượn quyển sách này?');\">Đăng ký mượn</a></span></div>";
         else
             rs = "<div style=\"text-align:center; padding-left:20px; padding-top:5px; padding-bottom:5px\"><span class=\"button_03\"><a href=\"javascript:void(0);\">Đã đăng ký</a></span></div>";
     }
     return rs;
 }
        public ActionResult RegisterRental(string id)
        {
            CatalogueBUS bus = new CatalogueBUS();
            CatalogueDTO cat = bus.GetCatalogueById(id);
            Feature f = new Feature();
            UserDTO user = (UserDTO) Session["USER"];

            if(f.AddRegister(new BookRegisterDTO()
                              {
                                  BookTitle = cat.Title,
                                  ISBN = id,
                                  Note = "",
                                  Status = BookRegisterStatus.NEW,
                                  UserId = user.UserId,
                                  Username = user.Username,
                                  CreatedDate = DateTime.Now,
                                  UpdatedDate = DateTime.Now,
                                  RegisterDate = DateTime.Now
                              }))
            {
                Log.Info("Create a new Register");
            }
            else
            {
                ViewData["Message"] = "Có lỗi xảy ra lúc đăng ký mượn sách, hãy liên hệ với thư viện!";
                return View("Error");
            }

            return RedirectToAction("BookDetail", "Search", new {id = id});
        }
 //public NewRentalForm()
 //{
 //    InitializeComponent();
 //}
 public NewRentalForm(Feature feature, List<RentalDTO> listRental)
 {
     InitializeComponent();
     _feature = feature;
     _listRental = listRental;
 }
 public RegisterImportForm(Feature feature)
 {
     InitializeComponent();
     _feature = feature;
 }