public ActionResult DeleteAccount(castleaccount33 cstl)
        {
            try {
                castleaccount33 tt = db.castleaccount33.Where(x => x.AccountId == cstl.AccountId).FirstOrDefault();
                if (tt != null && tt.Balance != 0)
                {
                    TempData["notdel"] = "Delete Operation unSuccessful as acount has balance";
                    return(RedirectToAction("ViewAccount"));
                }
                else
                {
                    int rows = db.deleteaccount33(cstl.AccountId);


                    if (rows > 0)
                    {
                        TempData["delacc"] = "Account Deleted  Successfully";
                        return(RedirectToAction("ViewAccount"));
                    }
                    else
                    {
                        ViewBag.Message = "Delete Operation Failed";
                        return(View("Error"));
                    }
                }
            }
            catch (Exception e)
            {
                return(View("Error"));
            }
        }
        public ActionResult Transfer(castleaccount33 acob)
        {
            //castleaccount33 tt = db.castleaccount33.Where(x => x.srcac == ct.srcac).FirstOrDefault();
            //castleaccount33 tt1 = db.castleaccount33.Where(x => x.tgtac == ct.tgtac).FirstOrDefault();


            //if (tt != null && tt.AccountStatus == "Inactive" && tt1 != null && tt1.AccountStatus == "Inactive")
            //{
            //    TempData["lfl"] = "Transfer failed as account inactive";
            //    return RedirectToAction("ViewTransfer");


            //}
            //else
            //{
            try {
                int id1 = acob.accid1;
                int id2 = acob.accid2;
                Session["id1"] = id1;
                Session["id2"] = id2;
                castleaccount33 ac1  = db.castleaccount33.Where(x => x.AccountId == id1).FirstOrDefault();
                castleaccount33 ac2  = db.castleaccount33.Where(x => x.AccountId == id2).FirstOrDefault();
                int             bal1 = int.Parse(ac1.Balance.ToString());
                int             bal2 = int.Parse(ac2.Balance.ToString());
                Session["bal1"] = bal1;
                Session["bal2"] = bal2;
                ObjectParameter para = new ObjectParameter("transid", typeof(int));
                para.Value = 0;
                ObjectParameter flag = new ObjectParameter("flag", typeof(int));
                flag.Value = 0;
                db.transfermoney(acob.accid1, acob.accid2, acob.amount, acob.ShowMessage = "Transfer successful", para, flag);
                int transid = int.Parse((para.Value).ToString());
                if (Convert.ToInt16(flag.Value) == 1)
                {
                    TempData["sc"] = "<script>alert('Transaction successful, Transaction Id is" + transid + "');</script>";
                    return(RedirectToAction("ViewTransfer"));
                }
                else if (Convert.ToInt16(flag.Value) == 2)
                {
                    TempData["fl"] = "<script>alert('Transaction failed because of insufficient balance');</script>";
                    //Response.Write("<script>alert('Transaction failed because of insufficient balance');</script>");
                    return(RedirectToAction("ViewTransfer"));
                }
                else if (Convert.ToInt16(flag.Value) == 0)
                {
                    TempData["sm"] = "<script>alert('Transaction failed as source and target account are same';);</script>";
                    return(RedirectToAction("ViewTransfer"));
                }
                else if (Convert.ToInt16(flag.Value) == 3)
                {
                    TempData["lfl"] = "Transfer failed as account inactive";
                    return(RedirectToAction("ViewTransfer"));
                }
                return(View());
            }
            catch (Exception e)
            {
                return(View("Error"));
            }
        }
 public ActionResult depositdetails(string n)
 {
     try
     {
         castleaccount33 tt = db.castleaccount33.Where(x => x.AccountId == ct.AccountId).FirstOrDefault();
         if (tt != null && tt.AccountStatus == "Inactive")
         {
             TempData["in"] = "Deposit not Successful as account is inactive";
             return(RedirectToAction("ViewTransaction"));
         }
         else
         {
             int ab = int.Parse(n);
             ct.depositamount = ab;
             ObjectParameter para = new ObjectParameter("TransactionId", typeof(int));
             para.Value = 0;
             db.deposit(ct.AccountId, "Deposit Successful", ct.depositamount, para);
             TempData["dep"] = "Deposit Successful";
             return(RedirectToAction("ViewTransaction"));
         }
     }
     catch (Exception e)
     {
         return(View("Error"));
     }
 }
        public ActionResult AddAccount()
        {
            try {
                castleaccount33       csob    = new castleaccount33();
                List <SelectListItem> acctype = new List <SelectListItem>()
                {
                    new SelectListItem()
                    {
                        Text = "Current", Value = "Current"
                    },
                    new SelectListItem()
                    {
                        Text = "Savings", Value = "Savings"
                    },
                };
                List <SelectListItem> cidlist = new List <SelectListItem>();

                cidlist = db.Custdet_1288.Select(x => new SelectListItem {
                    Text = x.custid.ToString(), Value = x.custid.ToString()
                }).ToList();



                csob.cidlist = cidlist;
                //csob.amount = 0;
                //csob.depositamount = 0;
                //csob.withdrawlamount = 0;
                csob.acctype = acctype;
                return(View(csob));
            }
            catch (Exception e)
            {
                return(View("Error"));
            }
        }
        public ActionResult Delete(Custdet_1288 cst)
        {
            try {
                castleaccount33 ccc = db.castleaccount33.Where(x => x.CustomerId == cst.custid).FirstOrDefault();
                if (ccc != null)
                {
                    TempData["not"] = "Delete Operation unSuccessful as customer has an account";
                    return(RedirectToAction("Viewdet"));
                }
                else
                {
                    int rows = db.delete_castle(cst.custid);


                    if (rows > 0)
                    {
                        TempData["second"] = "Delete Operation Successful";
                        return(RedirectToAction("Viewdet"));
                    }
                    else
                    {
                        ViewBag.Message = "Delete Operation Failed";
                        return(View("Error"));
                    }
                }
            }catch (Exception e)
            {
                ViewBag.Message = "Delete Operation Failed";
                return(View("Error"));
            }
        }
        public ActionResult withdrawldetails()
        {
            int dp = int.Parse(Session["dp"].ToString());

            ct            = db.castleaccount33.Where(x => x.AccountId == dp).FirstOrDefault();
            ViewBag.actid = ct.AccountId;
            ViewBag.csid  = ct.CustomerId;
            ViewBag.actp  = ct.AccountType;
            ViewBag.amt   = ct.Balance;
            return(View(ct));
        }
        public ActionResult searchaccountdetails()
        {
            int             ac   = int.Parse(Session["ac"].ToString());
            castleaccount33 cstt = db.castleaccount33.Where(x => x.AccountId == ac).FirstOrDefault();

            ViewBag.actid = cstt.AccountId;
            ViewBag.csid  = cstt.CustomerId;
            ViewBag.asts  = cstt.AccountStatus;
            ViewBag.amt   = cstt.Balance;
            return(View());
        }
        public ActionResult ViewTransfer()
        {
            int             id1  = int.Parse(Session["id1"].ToString());
            int             id2  = int.Parse(Session["id2"].ToString());
            int             bal1 = int.Parse(Session["bal1"].ToString());
            int             bal2 = int.Parse(Session["bal2"].ToString());
            castleaccount33 ob1  = db.castleaccount33.Where(x => x.AccountId == id1).FirstOrDefault();
            castleaccount33 ob2  = db.castleaccount33.Where(x => x.AccountId == id2).FirstOrDefault();

            ViewBag.src   = ob1.AccountId;
            ViewBag.oldbs = bal1;
            ViewBag.newbs = ob1.Balance;
            ViewBag.tgt   = ob2.AccountId;
            ViewBag.oldbt = bal2;
            ViewBag.newbt = ob2.Balance;
            return(View());
        }
        public ActionResult Transfer()
        {
            castleaccount33       acob  = new castleaccount33();
            List <SelectListItem> srcac = new List <SelectListItem>();

            srcac = db.castleaccount33.Select(x => new SelectListItem {
                Text = x.AccountId.ToString(), Value = x.AccountId.ToString()
            }).ToList();

            List <SelectListItem> tgtac = new List <SelectListItem>();

            tgtac = db.castleaccount33.Select(x => new SelectListItem {
                Text = x.AccountId.ToString(), Value = x.AccountId.ToString()
            }).ToList();

            acob.srcac = srcac;
            acob.tgtac = tgtac;
            return(View(acob));
        }
Exemplo n.º 10
0
        public ActionResult withdrawldetails(string n)
        {
            try {
                castleaccount33 tt = db.castleaccount33.Where(x => x.AccountId == ct.AccountId).FirstOrDefault();
                if (tt != null && tt.AccountStatus == "Inactive")
                {
                    TempData["fll"] = "Withdrawl fail as account is inactive";
                    return(RedirectToAction("ViewTransaction"));
                }
                else
                {
                    int ab = int.Parse(n);
                    ct.withdrawlamount = ab;
                    ObjectParameter para = new ObjectParameter("flag", typeof(int));
                    para.Value = 0;
                    ObjectParameter opara = new ObjectParameter("TransactionId", typeof(int));
                    opara.Value = 0;
                    db.withdrawl(ct.AccountId, "Withdrawl Successful", ct.withdrawlamount, para, opara);
                    if (Convert.ToInt16(para.Value) == 1)

                    {
                        TempData["with"] = "Withdrawl Successful";
                        return(RedirectToAction("ViewTransaction"));
                    }
                    else if (Convert.ToInt16(para.Value) == 0)
                    {
                        TempData["fail"] = "Withdrawl fail";
                        return(RedirectToAction("ViewTransaction"));
                    }
                }
                return(View());
            }
            catch (Exception e)
            {
                return(View("Error"));
            }
        }
Exemplo n.º 11
0
        public ActionResult DeleteAccount(int id)
        {
            castleaccount33 cstl = db.castleaccount33.Where(x => x.AccountId == id).FirstOrDefault();

            return(View(cstl));
        }
Exemplo n.º 12
0
        public ActionResult AddAccount(castleaccount33 csob /*,string CustomerId,string AccountType,string Balance*/)

        {
            try {
                //csob.amount = 0;
                //csob.depositamount = 0;
                //csob.withdrawlamount = 0;

                // castleaccount33 csob = new castleaccount33();
                //if (ModelState.IsValid)
                //{
                ObjectParameter flag = new ObjectParameter("flagg", typeof(int));
                flag.Value = 0;

                db.addaccount33(csob.CustomerId, csob.AccountType, csob.ShowMessage = "Account Creation successful", csob.AccountStatus = "Active", csob.Balance, flag);

                if (Convert.ToInt16(flag.Value) == 1)
                {
                    //  db.addaccount33(csob.CustomerId, csob.AccountType, csob.ShowMessage = "Account Creation successful", csob.AccountStatus = "Active", csob.Balance, flag);
                    TempData["acc"] = "Account added successfully";
                    return(RedirectToAction("ViewAccount"));
                }
                else if (Convert.ToInt16(flag.Value) == 0)
                {
                    TempData["asc"] = "Account cannot be added as CustomerId is inactive";
                    return(RedirectToAction("ViewAccount"));
                }
                else if (Convert.ToInt16(flag.Value) == 2)
                {
                    TempData["sim"] = "Account cannot be added as given CustomerId already has an account of similar type ";
                    return(RedirectToAction("ViewAccount"));
                }
                return(View());
                //}
                //else
                //{
                //    castleaccount33 csob1 = new castleaccount33();
                //    List<SelectListItem> acctype = new List<SelectListItem>()
                //{



                //    new SelectListItem() {Text="Current",Value="Current"},
                //    new SelectListItem() {Text="Savings",Value="Savings"},

                //};
                //    List<SelectListItem> cidlist = new List<SelectListItem>();

                //    cidlist = db.Custdet_1288.Select(x => new SelectListItem { Text = x.custid.ToString(), Value = x.custid.ToString() }).ToList();



                //    csob1.cidlist = cidlist;

                //    csob1.acctype = acctype;
                //    return View(csob1);
                //}
            }
            catch (Exception e)
            {
                return(View("Error"));
            }
        }