Beispiel #1
0
        public ActionResult Withdraw(addaccount_group2 withd, long id, decimal?balamt)
        {
            try
            {
                cashierViewAccountbyId_group2_Result objAccount = new cashierViewAccountbyId_group2_Result();
                if (withd.DepositAmount < 0 || withd.DepositAmount > balamt || withd.DepositAmount == 0 || withd.DepositAmount == null)
                {
                    objAccount.AccountId     = withd.AccountId;
                    objAccount.DepositAmount = withd.DepositAmount;
                    ViewBag.messageinsuf     = "invalid amount";

                    return(View());
                }

                else
                {
//                    @AccountId bigint,
//@AccountType varchar(50),
//@TransactionType varchar(50),
//@amount money,
//@beforebalance money,
//@latestbalance money out
                    ObjectParameter objParam = new ObjectParameter("latestbalance", typeof(decimal));
                    int             result;
                    if (withd.AccountType == 1)
                    {
                        result = bank.sp_WithdrawAmount_group2(id, "Savings", "withdraw", withd.DepositAmount, balamt, objParam);
                    }
                    else
                    {
                        result = bank.sp_WithdrawAmount_group2(id, "Current", "withdraw", withd.DepositAmount, balamt, objParam);
                    }
                    if (result > 0)
                    {
                        this.bank.SaveChanges();
                        TempData["Messwith"] = "Successfully Withdrawn! The new available balance is Rs." + objParam.Value;
                    }
                    return(RedirectToAction("cashierView"));
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #2
0
        public ActionResult Transfer(long id, long cid, addaccount_group2 acctable)
        {
            try
            {
                sp_selectCustomerAccountIdforTransfer_group2_Result cusacc = new sp_selectCustomerAccountIdforTransfer_group2_Result();

                if (acctable.DepositAmount > Convert.ToDecimal(Session["SAccBal"]) || acctable.DepositAmount <= 0)
                {
                    TempData["transferfailed"] = "Cannot transfer the entered amount or check your balance!";
                    return(RedirectToAction("Transfer"));
                }
                else
                {
                    cusacc = bank.sp_selectCustomerAccountIdforTransfer_group2(cid, id).FirstOrDefault();


                    ObjectParameter balsrc = new ObjectParameter("up_balS", typeof(decimal));
                    ObjectParameter baldes = new ObjectParameter("up_balD", typeof(decimal));
                    int             result;
                    string          type = Convert.ToString(Session["SAccType"]);
                    if (type == "Savings")
                    {
                        result = bank.sp_transfer_group2(Convert.ToInt64(Session["SAccId"]), cusacc.AccountId, Convert.ToInt32(Session["SAccType"]), Convert.ToInt32(Session["SAccidsource"]), Convert.ToDecimal(Session["SAccBal"]), cusacc.DepositAmount, acctable.DepositAmount, balsrc, baldes);
                    }
                    else
                    {
                        result = bank.sp_transfer_group2(Convert.ToInt64(Session["SAccId"]), cusacc.AccountId, Convert.ToInt32(Session["SAccType"]), Convert.ToInt32(Session["SAccidsource"]), Convert.ToDecimal(Session["SAccBal"]), cusacc.DepositAmount, acctable.DepositAmount, balsrc, baldes);
                    }
                    if (result > 0)
                    {
                        this.bank.SaveChanges();
                        TempData["Messtransferred"] = "Successfully Transferred! The new available balance is Rs. " + balsrc.Value;
                    }
                    return(RedirectToAction("cashierView"));
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #3
0
        public ActionResult deposit(addaccount_group2 objTran, long id, decimal balamt)
        {
            try
            {
                ViewBag.username = Session["userName"];
                cashierViewAccountbyId_group2_Result objAccount = new cashierViewAccountbyId_group2_Result();
                if (objTran.DepositAmount <= 0 || objTran.DepositAmount > 100000 || objTran.DepositAmount == null)
                {
                    objAccount.AccountId     = objTran.AccountId;
                    objAccount.DepositAmount = objTran.DepositAmount;
                    ViewBag.message          = "enter valid amount";
                    return(View(objAccount));
                }
                else
                {
                    ObjectParameter objParam = new ObjectParameter("latestbalance", typeof(decimal));
                    int             result;
                    if (objTran.AccountType == 1)
                    {
                        result = bank.sp_Deposit_group2(id, "Savings ", "deposit", objTran.DepositAmount, balamt, objParam);
                    }
                    else
                    {
                        result = bank.sp_Deposit_group2(id, "Current ", "deposit", objTran.DepositAmount, balamt, objParam);
                    }
                    if (result > 0)
                    {
                        this.bank.SaveChanges();
                        TempData["Messdep"] = "Successfully Deposited! The new available balance is Rs." + objParam.Value;
                    }
                    return(RedirectToAction("cashierView"));
                }
            }

            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #4
0
        public ActionResult addaccountfromlist(addaccount_group2 addacc, long id)
        {
            try
            {
                ViewBag.username      = Session["userName"];
                Session["CustomerId"] = id;
                int Noofacc = Convert.ToInt32(bank.sp_checknoofAccounts_group2(id).FirstOrDefault());

                if (Noofacc != 0)
                {
                    Session["CustomerId"] = id;
                    ObjectParameter retAcc    = new ObjectParameter("Accountidout", typeof(long));
                    int             acctypeid = Convert.ToInt16(Session["accounttype"]);
                    if (acctypeid == 1)
                    {
                        if (addacc.DepositAmount <= 0 || addacc.DepositAmount < 1000 || addacc.DepositAmount > 100000)
                        {
                            TempData["amtdepositmin"] = "minimum amount should be more than 1000 or no negative amount";
                            return(RedirectToAction("addaccountfromlist"));
                        }
                        else
                        {
                            int res = bank.sp_addaccount_group2(addacc.AccountId, id, acctypeid, addacc.DepositAmount, retAcc);
                            this.bank.SaveChanges();
                            long resacc = Convert.ToInt64(retAcc.Value);
                            return(RedirectToAction("listofaccounts"));
                        }
                    }
                }
                else
                {
                    if (addacc.DepositAmount <= 0 || addacc.DepositAmount < 5000 || addacc.DepositAmount > 100000)
                    {
                        TempData["amtdepositmincurrent"] = "minimum amount should be 5000";
                        return(RedirectToAction("addaccountfromlist"));
                    }
                    else
                    {
                        ObjectParameter retAcc = new ObjectParameter("Accountidout", typeof(long));
                        id = Convert.ToInt64(Session["CustomerId"]);

                        int res = bank.sp_addaccount_group2(addacc.AccountId, id, addacc.AccountType, addacc.DepositAmount, retAcc);
                        this.bank.SaveChanges();
                        long resacc = Convert.ToInt64(retAcc.Value);


                        return(RedirectToAction("listofaccounts"));
                    }
                }

                // }
                //else
                //{

                //    ViewBag.Message = "Two accounts already exist for this CustomerId " + id;
                //    return View("listofaccounts");

                //}

                return(View());
            }

            catch (Exception)
            {
                throw;
            }
        }