Пример #1
0
        public ActionResult Form(long? id)
        {
            try
            {
                if (id == null)
                {
                    user = (OCCUSER)Session["User"];
                    ViewBag.BRANCHCODE = new SelectList(db.BRANCHINFO, "ID", "BRANCHNAME");
                    CARDCHEREUISITION ccreq = new CARDCHEREUISITION();
                    //if (user.BRANCH != null)
                    //{
                    //    ccreq.BRANCHCODE = (long)user.BRANCH;
                    //}
                    long status = db.OCCENUMERATION.Where(x => x.Name == "applied").Select(x => x.ID).FirstOrDefault();
                    ViewBag.STATUSID = new SelectList(db.OCCENUMERATION.Where(x => x.Type == "chequereq"), "ID", "Name", status);
                    ViewBag.STATUS = status;
                    ccreq.CREATEDON = DateTime.Now;
                    return View(ccreq);
                }
                CARDCHEREUISITION cardchereuisition = db.CARDCHEREUISITION.Find(id);
                if (cardchereuisition == null)
                {
                    return HttpNotFound();
                }
                ViewBag.BRANCHCODE = new SelectList(db.BRANCHINFO, "ID", "BRANCHNAME", cardchereuisition.BRANCHCODE);

                ViewBag.STATUSID = new SelectList(db.OCCENUMERATION.Where(x => x.Type == "chequereq"), "ID", "Name", cardchereuisition.STATUS);

                return View(cardchereuisition);
            }
            catch (Exception)
            {
                return RedirectToAction("Error", "Home", new { Area = "" });
            }
        }
Пример #2
0
        public ActionResult Form(CARDCHEREUISITION cardchereuisition)
        {
            try
            {
                user = (OCCUSER)Session["User"];

                int adminFlag = 0;
                if (cardchereuisition.ID == 0)
                {
                    cardchereuisition.LEAFNO = 10;
                    cardchereuisition.ISACTIVE = false;
                    cardchereuisition.ISDELETE = false;
                    cardchereuisition.CREATEDBY = user.ID;
                    if (ModelState.IsValid)
                    {
                        db.CARDCHEREUISITION.Add(cardchereuisition);
                        db.SaveChanges();
                        if (user.TYPE == 1)
                        {
                            adminFlag = 1;
                        }
                        string msg = "Successfully Saved";
                        return Json(new { msg, adminFlag }, JsonRequestBehavior.AllowGet);
                    }
                    ViewBag.BRANCH = new SelectList(db.BRANCHINFO, "ID", "BRANCHNAME", user.BRANCH);
                    CARDCHEREUISITION ccreq = new CARDCHEREUISITION();
                    if (user.BRANCH != null)
                    {
                        ccreq.BRANCHCODE = (long)user.BRANCH;
                    }

                    long status = db.OCCENUMERATION.Where(x => x.Name == "applied").Select(x => x.ID).FirstOrDefault();
                    ViewBag.STATUSID = new SelectList(db.OCCENUMERATION.Where(x => x.Type == "chequereq"), "ID", "Name", status);
                    cardchereuisition.STATUS = status;
                    return View(cardchereuisition);
                }
                else
                {
                    var modifiedcardCheque = db.CARDCHEREUISITION.Find(cardchereuisition.ID);

                        modifiedcardCheque.REMARKS = cardchereuisition.REMARKS;
                        modifiedcardCheque.REFERENCENO = cardchereuisition.REFERENCENO;
                        modifiedcardCheque.MODIFIEDBY = user.ID;
                        modifiedcardCheque.MODIFIEDON = DateTime.Now;
                        db.Entry(modifiedcardCheque).State = EntityState.Modified;
                        db.SaveChanges();
                        string msg = "Successfully Updated";
                        return Json(new { msg, adminFlag }, JsonRequestBehavior.AllowGet);

                }

            }
            catch (Exception exception)
            {
                return RedirectToAction("Error", "Home", new { Area = "" });
            }
        }
Пример #3
0
        public ActionResult Details(CARDCHEREUISITION cardchereuisition,string btnName)
        {
            try
            {
                OCCUSER user = (OCCUSER)Session["User"];
                if (String.Equals(btnName, "delete"))
                {
                    CARDCHEREUISITION ccr = db.CARDCHEREUISITION.Find(cardchereuisition.ID);
                    ccr.ISDELETE = true;
                    //db.Entry(ccr).State = EntityState.Modified;
                    db.SaveChanges();
                    var msg = "Successfully Removed";
                    return Json(msg, JsonRequestBehavior.AllowGet);
                }
                if (String.Equals(btnName, "update"))
                {

                    var updatedModel = db.CARDCHEREUISITION.Find(cardchereuisition.ID);
                    updatedModel.CARDNO = cardchereuisition.CARDNO;
                    updatedModel.CREATEDON = cardchereuisition.CREATEDON;
                    updatedModel.BRANCHCODE = cardchereuisition.BRANCHCODE;
                    updatedModel.STATUS = cardchereuisition.STATUS;
                    updatedModel.REFERENCENO = cardchereuisition.REFERENCENO;
                    updatedModel.REMARKS = cardchereuisition.REMARKS;
                    //if (cardchereuisition.ISACTIVE)
                    //{
                    //    updatedModel.ISACTIVE = cardchereuisition.ISACTIVE;
                    //}
                    //if (ModelState.IsValid)
                    //{

                        //db.Entry(cardchereuisition).State = EntityState.Modified;
                        db.SaveChanges();
                    //}

                    var msg = "Successfully Updated";
                    return Json(msg, JsonRequestBehavior.AllowGet);
                }
                return Json("Error",JsonRequestBehavior.AllowGet);
            }
            catch (Exception exception)
            {

                return Json(exception.Message, JsonRequestBehavior.AllowGet);
            }
        }