Exemplo n.º 1
0
        public ActionResult Create(CARDCHTRAN cardchtran)
        {
            List<string> currencyList;

            try
            {
                int adminFlag = 0;
                OCCUSER user = (OCCUSER) Session["User"];
                cardchtran.CREATEDBY = user.ID;
                cardchtran.CREATEDON = DateTime.Now.Date;
                cardchtran.STATUS = 13;
                cardchtran.ISACTIVE = true;
                cardchtran.ISDELETE = false;

                var leaf=db.CARDCHLEAF.FirstOrDefault(x => x.ID == cardchtran.CHEQUELEAFID);

                leaf.LEAFSTATUS = db.OCCENUMERATION.Where(x=>x.Name=="used").Select(x=>x.ID).FirstOrDefault();
                db.Entry(leaf).State = EntityState.Modified;

                if (ModelState.IsValid)
                {
                    db.CARDCHTRAN.Add(cardchtran);
                    db.SaveChanges();
                    if (user.TYPE == 1)
                    {
                        adminFlag = 1;
                    }
                    var msg = "Data saved successfully. ";

                    return Json(new { msg, adminFlag }, JsonRequestBehavior.AllowGet);

                }

                currencyList = new List<string>() { "BDT" };
                ViewBag.BRANCHCODE = new SelectList(db.BRANCHINFO.ToList(), "ID", "BRANCHNAME");
                ViewBag.CURRENCY = new SelectList(currencyList);
                return View("Index");

            }

            catch (DbEntityValidationException dbEntityValidationException)
            {

                return RedirectToAction("Error", "Home", new { Area = "" });
            }
            catch (InvalidOperationException invalidOperationException)
            {
                return RedirectToAction("Error", "Home", new { Area = "" });
            }

            catch (Exception exception)
            {
                return RedirectToAction("Error", "Home", new { Area = "" });
            }
        }
Exemplo n.º 2
0
        public ActionResult Details(CARDCHTRAN tran,string btnName)
        {
            try
            {
                OCCUSER user = (OCCUSER)Session["User"];
                if (String.Equals(btnName, "update"))
                {
                    var updatedTrn = db.CARDCHTRAN.Find(tran.ID);
                    updatedTrn.CHEQUELEAFID = tran.CHEQUELEAFID;
                    updatedTrn.CARDNO = tran.CARDNO;
                    updatedTrn.BENEFICIARINFO = tran.BENEFICIARINFO;
                    updatedTrn.AMOUNT = tran.AMOUNT;
                    updatedTrn.BRANCHCODE = tran.BRANCHCODE;
                    updatedTrn.REQUESTDATE = tran.REQUESTDATE;

                    updatedTrn.MODIFIEDBY = user.ID;
                    updatedTrn.MODIFIEDON = DateTime.Now;
                   // updatedTrn.ISACTIVE = true;
                    db.Entry(updatedTrn).State = EntityState.Modified;
                    db.SaveChanges();
                    var msg = "Successfully Updated";
                    return Json(msg, JsonRequestBehavior.AllowGet);
                }
                if (String.Equals(btnName, "delete"))
                {
                    //aUser.MODIFIEDBY = user.ID;
                    //aUser.MODIFIEDON = DateTime.Now;
                    //aUser.ISACTIVE = false;
                    //db.Entry(aUser).State = EntityState.Modified;
                    //db.SaveChanges();
                    var updatedTrn = db.CARDCHTRAN.Find(tran.ID);
                    updatedTrn.ISDELETE = true;
                    db.Entry(updatedTrn).State = EntityState.Modified;
                    db.SaveChanges();
                    var msg = "Successfully Removed";
                    return Json(msg, JsonRequestBehavior.AllowGet);
                }
                var msg1 = "Error in operation";
                return Json(msg1, JsonRequestBehavior.DenyGet);
              //  return View(tran);
            }
            catch (Exception exception)
            {
                return Json(exception.Message, JsonRequestBehavior.AllowGet);
                //return RedirectToAction("Error", "Home", new { Area = "" });
            }
        }