Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        public ActionResult Transfer(long?id, long?cid, int?acctype, decimal?bal)
        {
            try
            {
                ViewBag.username = Session["userName"];
                if (Session["userName"] != null && Session["userroleId"].ToString() == "2")
                {
                    sp_selectCustomerAccountIdforTransfer_group2_Result cusacc = new sp_selectCustomerAccountIdforTransfer_group2_Result();
                    int NoOfacc = Convert.ToInt32(bank.sp_checknoofAccounts_group2(cid).FirstOrDefault());
                    if (NoOfacc == 2)
                    {
                        if (id != null)
                        {
                            cusacc = bank.sp_selectCustomerAccountIdforTransfer_group2(cid, id).FirstOrDefault();
                            int?transctns = bank.sp_Totaltransactions(cusacc.CustomerID, DateTime.Today.Date).FirstOrDefault();
                            int a         = transctns.GetValueOrDefault();
//ALTER proc [dbo].[sp_Totaltransactions]
//@CustomerId bigint,
//@date date
//as
//begin
//select count(*) as TransactionsCount from addaccount_group2
//inner join transactiontable_group2 on addaccount_group2.AccountId=transactiontable_group2.AccountId
//where (addaccount_group2.CustomerID=@CustomerId and transactiontable_group2.dateoftransaction=@date)
//end
                            if (a > 3)
                            {
                                TempData["msg"] = "transactions limit has been reached";

                                return(RedirectToAction("cashierView"));
                            }
                            Session["SAccidsource"] = cusacc.AccountType;
                            Session["SAccId"]       = id;
                            Session["SAccBal"]      = bal;
                            Session["SAccType"]     = acctype;

                            if (cusacc.AccountType == 1)
                            {
                                Session["DAccType"] = "Savings";
                            }
                            else
                            {
                                Session["DAccType"] = "Current";
                            }
                        }
                        return(View(cusacc));
                    }
                    else
                    {
                        TempData["notransfer"] = "This customer has only one account";
                        return(RedirectToAction("cashierView"));
                    }
                }


                else
                {
                    return(Redirect("../login/login"));
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }