public ActionResult GiveBook(int id = 0)
        {
            if (Session["CurUsr"] == null)
            {
                Response.Redirect("~/Library/SignIn");
            }
            if (id == 0)
            {
                Response.Redirect("~/Library/ReadersCollection");
            }
            Reader rd = DM.Rd.GetReader(id);

            if (rd == null)
            {
                Response.Redirect("~/Library/ReadersCollection");
            }
            BookGiving bg = new BookGiving();

            bg.Reader      = rd;
            bg.Librarian   = (Librarian)Session["CurUsr"];
            bg.Give_Date   = DateTime.Today;
            ViewData.Model = bg;
            DateTime dt = DateTime.Today;

            dt = new DateTime(dt.Year, dt.Month, dt.Day + 1);
            string t = dt.ToString("s");

            ViewData["ERD"]        = t.Substring(0, t.IndexOf('T'));
            Session["CurrentDate"] = t.Substring(0, t.IndexOf('T'));
            Session["Book_OK"]     = null;//->false
            return(View());
        }
        public ActionResult BookReturn(int id, Penalty pn, int SumP, int SumK)
        {
            pn.Sum = SumP + (decimal)SumK / 100;
            if (Session["CurUsr"] == null)
            {
                Response.Redirect("~/Library/SignIn");
            }
            BookReturning BR = new BookReturning();

            if (pn.Info == null)
            {
                pn.Info = "";
            }
            BR.Penalty          = pn;
            BR.Real_Return_Date = DateTime.Today;
            BR.Librarian        = (Librarian)Session["CurUsr"];
            BookGiving bg = DM.BG.GetBookGiving(id);

            if (bg == null)
            {
                Response.Redirect("~/Library/ReadersCollection");
            }
            DM.BR.Add(bg, BR);
            return(RedirectToAction("ReaderInfo/" + bg.Reader.Id));
        }
        public ActionResult Delete(BookGiving model)
        {
            BookGiving entityObject = Objects.First(e => e.Id == model.Id);

            Objects.Remove(entityObject);
            StaticDataContext.Save();
            return(RedirectToAction("Index"));
        }
 private void UpdateEntityObject(BookGiving entityObject,
                                 BookTableModel model)
 {
     entityObject.ClassName   = model.ClassName;
     entityObject.BookName    = model.BookName;
     entityObject.Author      = model.Author;
     entityObject.DateGiving  = model.DateGiving;
     entityObject.Note        = model.Note;
     entityObject.Description = model.Description;
 }
        public ActionResult GiveBook(int id, BookGiving bg, int BookID = 0)
        {
            if (Session["CurUsr"] == null)
            {
                Response.Redirect("~/Library/SignIn");
            }
            Publication p  = null;
            bool        OK = false;

            try
            {
                p = DM.Book.GetPublication(BookID);
            }
            catch { }
            if (p != null)
            {
                if (p.Available)
                {
                    OK                 = true;
                    bg.Publication     = p;
                    ViewData["BookID"] = BookID;
                }
            }
            Reader rd = DM.Rd.GetReader(id);

            if (rd == null)
            {
                Response.Redirect("~/Library/ReadersCollection");
            }
            bg.Reader      = rd;
            bg.Librarian   = (Librarian)Session["CurUsr"];
            bg.Give_Date   = DateTime.Today;
            ViewData.Model = bg;
            try
            {
                if (Session["Book_OK"] != null && (bool)Session["Book_OK"])
                {
                    DM.BG.Add(bg);
                    return(RedirectToAction("/ReaderInfo/" + id));
                }
            }
            catch { }
            Session["Book_OK"] = OK;
            string t = bg.Expected_Return_Date.ToString("s");

            ViewData["ERD"] = t.Substring(0, t.IndexOf('T'));
            return(View());
        }
Beispiel #6
0
        private static void ReadBookGiving(XmlTextReader reader)
        {
            BookGiving obj = new BookGiving();
            string     s   = reader.GetAttribute("Id");

            if (!string.IsNullOrEmpty(s))
            {
                obj.Id = int.Parse(s);
            }
            obj.ClassName   = reader.GetAttribute("ClassName");
            obj.BookName    = reader.GetAttribute("BookName");
            obj.Author      = reader.GetAttribute("Author");
            obj.DateGiving  = reader.GetAttribute("DateGiving");
            obj.Note        = reader.GetAttribute("Note");
            obj.Description = reader.GetAttribute("Description");
            BookGivings.Add(obj);
        }
        public ActionResult PayPenalty(int id = 0)
        {
            if (Session["CurUsr"] == null)
            {
                Response.Redirect("~/Library/SignIn");
            }
            if (id == 0)
            {
                Response.Redirect("~/Library/ReadersCollection");
            }
            BookGiving b = DM.BG.GetBookGiving(id);

            if (b != null && b.BookReturning != null && b.BookReturning.Penalty != null)
            {
                int PenaltyID = b.BookReturning.Penalty.Id;
                DM.Penalty.PenaltyToZero(PenaltyID);
            }
            return(RedirectToAction("ReaderInfo/" + b.Reader.Id));
        }