// GET: LCNoes
        public ActionResult Index()
        {
            LCNo lcNO = new LCNo();

            lcNO.LCNO = db.LCNoes.ToList();
            return(View(lcNO));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            LCNo lCNo = db.LCNoes.Find(id);

            db.LCNoes.Remove(lCNo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "LC_Id,LC_No,LC_Date")] LCNo lCNo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lCNo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(lCNo));
 }
        public ActionResult Create([Bind(Include = "LC_Id,LC_No,LC_Date")] LCNo lCNo)
        {
            if (ModelState.IsValid)
            {
                db.LCNoes.Add(lCNo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(lCNo));
        }
        // GET: LCNoes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LCNo lCNo = db.LCNoes.Find(id);

            if (lCNo == null)
            {
                return(HttpNotFound());
            }
            return(View(lCNo));
        }
Example #6
0
        public ActionResult Index(string LCNo, string FromDate, string ToDate, string currentFilterLC, String currentFilterFrDate, String currentFilterToDate, int?page, int filterBonderId = 0, int BONDERID = 0)
        {
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"].ToString();
                TempData.Remove("Message");
            }

            var requestType = this.HttpContext.Request.RequestType;

            System.Diagnostics.Debug.WriteLine("requestType = " + requestType);
            USERPERMISSION loggedinUser  = new SessionAttributeRetreival().getStoredUserPermission();
            var            backtobacklcs = db.BACKTOBACKLCs.OrderByDescending(b => b.ID).Include(b => b.BANKBRANCH).Include(b => b.BANK).Include(b => b.BONDER);
            int            pageSize      = recordNumbers;
            int            pageNumber    = (page ?? 1);

            if (LCNo != null || FromDate != null || ToDate != null || BONDERID != 0)
            {
                page = 1;
            }
            else
            {
                if (LCNo == null)
                {
                    LCNo = currentFilterLC;
                }
                if (FromDate == null)
                {
                    FromDate = currentFilterFrDate;
                }
                if (ToDate == null)
                {
                    ToDate = currentFilterToDate;
                }
                if (BONDERID == 0)
                {
                    BONDERID = filterBonderId;
                }
            }
            ViewBag.CurrentFilterLC     = LCNo;
            ViewBag.CurrentFilterFrDate = FromDate;
            ViewBag.CurrentFilterToDate = ToDate;
            ViewBag.filterBonderId      = BONDERID;
            ViewBag.BONDERID            = new SelectList(db.BONDERs, "BONDERSLNO", "BONDERNAME");
            if ("GET" == requestType)
            {
                if (LCNo != null || FromDate != null || ToDate != null || BONDERID != 0)
                {
                    ViewBag.resultofbonderID = BONDERID;
                    backtobacklcs            = GetBackToBackRolesBySearchCriterial(LCNo, FromDate, ToDate, loggedinUser, BONDERID);
                }
                if (loggedinUser != null && loggedinUser.BONDERID != null)
                {
                    ViewBag.resultofbonderID = loggedinUser.BONDERID;
                    backtobacklcs            = backtobacklcs.Where(i => i.BONDERID == loggedinUser.BONDERID).OrderByDescending(b => b.ID).Include(b => b.BANKBRANCH).Include(b => b.BANK).Include(b => b.BONDER);
                }
                else if (BONDERID == 0 && filterBonderId == 0 && !User.IsInRole("Bonder"))
                {
                    ViewBag.resultofbonderID = BONDERID;
                    List <BACKTOBACKLC> backtobacklc = new List <BACKTOBACKLC>();
                    return(View(backtobacklc.ToPagedList(pageNumber, pageSize)));
                }

                return(View(backtobacklcs.ToList().ToPagedList(pageNumber, pageSize)));
            }
            else if ("POST" == requestType)
            {
                if (BONDERID == 0 && filterBonderId == 0 && !User.IsInRole("Bonder"))
                {
                    ViewBag.resultofbonderID = BONDERID;
                    List <BACKTOBACKLC> backtobacklc = new List <BACKTOBACKLC>();
                    return(View(backtobacklc.ToPagedList(pageNumber, pageSize)));
                }
                if (!string.IsNullOrEmpty(LCNo))
                {
                    LCNo = LCNo.Trim();
                }
                System.Diagnostics.Debug.WriteLine("LCNo = " + LCNo + ", FromDate = " + FromDate + ", ToDate = " + ToDate);

                if (LCNo.Equals(String.Empty) && FromDate.Equals(String.Empty) && ToDate.Equals(String.Empty))
                {
                    System.Diagnostics.Debug.WriteLine("if");
                }
                else if ((LCNo != null && !LCNo.Equals(String.Empty)) && (FromDate != null && !FromDate.Equals(String.Empty)) && (ToDate != null && !ToDate.Equals(String.Empty)))
                {
                    System.Diagnostics.Debug.WriteLine("else if 1");
                    DateTime fromLCDate = Convert.ToDateTime(FromDate);
                    DateTime toLCDate   = Convert.ToDateTime(ToDate);
                    backtobacklcs = backtobacklcs.Where(b => b.LCNUMBER.Contains(LCNo) && (b.LCDATE >= fromLCDate && b.LCDATE <= toLCDate)).Include(b => b.BANKBRANCH).OrderByDescending(b => b.ID);
                }
                else if ((FromDate != null && !FromDate.Equals(String.Empty)) && (ToDate != null && !ToDate.Equals(String.Empty)))
                {
                    System.Diagnostics.Debug.WriteLine("else if 2");
                    DateTime fromLCDate = Convert.ToDateTime(FromDate);
                    DateTime toLCDate   = Convert.ToDateTime(ToDate);
                    backtobacklcs = backtobacklcs.Where(b => (b.LCDATE >= fromLCDate && b.LCDATE <= toLCDate)).Include(b => b.BANKBRANCH).OrderByDescending(b => b.ID);
                }
                else if (LCNo != null && !LCNo.Equals(String.Empty))
                {
                    System.Diagnostics.Debug.WriteLine("else if 3");
                    backtobacklcs = backtobacklcs.Where(b => b.LCNUMBER.Contains(LCNo)).Include(b => b.BANKBRANCH).OrderByDescending(b => b.ID);
                }
                else if (FromDate != null && !FromDate.Equals(String.Empty))
                {
                    System.Diagnostics.Debug.WriteLine("else if 4");
                    DateTime fromLCDate = Convert.ToDateTime(FromDate);
                    backtobacklcs = backtobacklcs.Where(b => b.LCDATE >= fromLCDate).OrderByDescending(b => b.ID);
                }
                else if (ToDate != null && !ToDate.Equals(String.Empty))
                {
                    System.Diagnostics.Debug.WriteLine("else if 5");
                    DateTime toLCDate = Convert.ToDateTime(ToDate);
                    backtobacklcs = backtobacklcs.Where(b => b.LCDATE <= toLCDate).OrderByDescending(b => b.ID);
                }
                if (loggedinUser.BONDERID > 0)
                {
                    ViewBag.resultofbonderID = loggedinUser.BONDERID;
                    backtobacklcs            = backtobacklcs.Where(e => e.BONDERID == loggedinUser.BONDERID).OrderByDescending(b => b.ID);
                }
                else if (BONDERID > 0)
                {
                    ViewBag.resultofbonderID = BONDERID;
                    backtobacklcs            = backtobacklcs.Where(e => e.BONDERID == BONDERID).OrderByDescending(b => b.ID);
                }
                if (loggedinUser != null && loggedinUser.BONDERID != null)
                {
                    ViewBag.resultofbonderID = loggedinUser.BONDERID;
                    backtobacklcs            = backtobacklcs.Where(i => i.BONDERID == loggedinUser.BONDERID).OrderByDescending(b => b.ID).Include(b => b.BANKBRANCH).Include(b => b.BANK).Include(b => b.BONDER);
                }
            }
            else
            {
                // Error handel
            }
            pageSize   = recordNumbers;
            pageNumber = (page ?? 1);

            return(View(backtobacklcs.ToPagedList(pageNumber, pageSize)));
        }