public async Task <ActionResult> Create(Finerecords finerecords)
        {
            if (finerecords != null)
            {
                finerecords.TotalAmount = finerecords.FineAmount;


                int classid = (from alias in db.students where alias.Id == finerecords.StudentId select alias.ClassId).FirstOrDefault();
                finerecords.SemesterClass = (from alias in db.classes where alias.Id == classid select alias.ClassName).FirstOrDefault();

                finerecords.Name = (from alias in db.students where alias.Id == finerecords.StudentId select alias.StudentName).FirstOrDefault();


                Finerecords        fineslip    = new Finerecords();
                transactionrecords transaction = new transactionrecords();

                fineslip.Id = finerecords.Id;

                fineslip.TotalAmount  = finerecords.TotalAmount;
                fineslip.Payingstatus = finerecords.Payingstatus;


                fineslip.FineAmount     = finerecords.FineAmount;
                fineslip.SubmissionDate = finerecords.SubmissionDate;
                fineslip.Remarks        = finerecords.Remarks;

                //here normal record ends and students retrieving record start

                fineslip.SemesterClass = finerecords.SemesterClass;

                fineslip.Name = finerecords.Name;

                fineslip.StudentId = finerecords.StudentId;
                //here insterting transaction record
                transaction.PersonId          = fineslip.StudentId;
                transaction.TransactionAmount = fineslip.TotalAmount;
                transaction.TransactionDate   = fineslip.SubmissionDate;
                transaction.TransactionYear   = DateTime.Now.Year;
                transaction.TransactionType   = "Fine";



                db.Finerecords.Add(fineslip);
                await db.SaveChangesAsync();

                db.Entry(fineslip).GetDatabaseValues();
                int getid = fineslip.Id;
                TempData["Fineid"] = getid;
                //here  saving the created record of each specific tranaction
                db.transactionecords.Add(transaction);
                await db.SaveChangesAsync();

                return(RedirectToAction("PrintfineSlip"));
            }


            ViewBag.StudentId = new SelectList(db.students, "Id", "StudentName", finerecords.StudentId);
            return(View(finerecords));
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Finerecords finerecords = await db.Finerecords.FindAsync(id);

            db.Finerecords.Remove(finerecords);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,SemesterClass,SubmissionDate,FineAmount,TotalAmount,Payingstatus,Remarks,StudentId")] Finerecords finerecords)
        {
            if (ModelState.IsValid)
            {
                db.Entry(finerecords).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.StudentId = new SelectList(db.students, "Id", "StudentName", finerecords.StudentId);
            return(View(finerecords));
        }
        // GET: Finerecords/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Finerecords finerecords = await db.Finerecords.FindAsync(id);

            if (finerecords == null)
            {
                return(HttpNotFound());
            }
            return(View(finerecords));
        }
        // GET: Finerecords/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Finerecords finerecords = await db.Finerecords.FindAsync(id);

            if (finerecords == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StudentId = new SelectList(db.students, "Id", "StudentName", finerecords.StudentId);
            return(View(finerecords));
        }
        // GET: Finerecords/Create
        public ActionResult Create()
        {
            ViewBag.StudentId = db.students.Select(c => new SelectListItem {
                Value = c.Id.ToString(), Text = c.Id.ToString()
            })
                                .ToList();

            var view = new Finerecords
            {
                SubmissionDate = DateTime.Now.Date,
                Remarks        = "Write Fine Reason/Category",
                Payingstatus   = "Full Fine Paid"
            };

            return(View(view));
        }
        //here below is the fine slip
        public ActionResult PrintfineSlip()
        {
            int id = Convert.ToInt32(TempData["Fineid"]);

            if (id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Finerecords fineslip = db.Finerecords.Find(Convert.ToInt32(id));

            if (fineslip == null)
            {
                return(HttpNotFound());
            }
            return(View(fineslip));
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,BookTitle,BookId,AssignedBy,AssignedDate,ReturnDate,StudedRegId,StudentName,StudentDepartment,StudentClass,Comments,fineComment,ReceivedStatus,Receiveddate,fineslipid,finestatus")] LibarayIssuedBooks libarayIssuedBooks)
        {
            if (ModelState.IsValid)
            {
                //         public string fineComment { get; set; }
                //public string ReceivedStatus { get; set; }
                //public DateTime Receiveddate { get; set; }
                //public string fineslipid { get; set; }
                //public string finestatus { get; set; }
                libarayIssuedBooks.Receiveddate = DateTime.Now;
                if (libarayIssuedBooks.ReturnDate > libarayIssuedBooks.ReturnDate)
                {
                    if (libarayIssuedBooks.fineslipid == "")
                    {
                        ViewBag.finemsg = "Provide the Fine Challan ID to Proceed.";
                        return(View(libarayIssuedBooks));
                    }
                    int         convert     = Convert.ToInt32(libarayIssuedBooks.fineslipid);
                    Finerecords checkrecord = await db.Finerecords.FindAsync(convert);

                    if (checkrecord == null)
                    {
                        ViewBag.finemsg = "Provided  Fine Challan ID Not Matched.";
                    }
                    libarayIssuedBooks.finestatus = "Fined";
                }
                else
                {
                    libarayIssuedBooks.finestatus = "Not Fined";
                }
                libarayIssuedBooks.ReceivedStatus = "Received";

                db.Entry(libarayIssuedBooks).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(libarayIssuedBooks));
        }