public ActionResult newfund(valuesto_sp_funds_ofMember tab)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (tab.loan_amt != null)
                {
                    long avl_bl = Convert.ToInt64(db.sp_checkbal().FirstOrDefault());
                    if (tab.loan_amt <= avl_bl)
                    {
                        ObjectParameter retbal        = new ObjectParameter("bal_amt", 0);
                        ObjectParameter rettrans_type = new ObjectParameter("trans_type", 0);
                        ObjectParameter retsl_no      = new ObjectParameter("sl_no", 0);
                        ObjectParameter ret_avl_bal   = new ObjectParameter("avl_bal", 0);
                        ObjectParameter ret_loan_id   = new ObjectParameter("loan_idout", 0);


                        //int res = db.sp_fund_collection_new(Convert.ToInt32(Session["new_id"]), tab.name,Convert.ToInt64(Session["new_mob"]), tab.loan_amnt, 0,0, tab.dt, trans_type, retsl_no, ret_avl_bal);
                        int result = db.sp_funds_ofMember(tab.loan_id, tab.id, tab.name, tab.loan_amt, 0, retbal, 0, tab.paid_dt, rettrans_type, retsl_no, ret_avl_bal, ret_loan_id);
                        this.db.SaveChanges();
                        TempData["Trans_message"] = "Loan amount of 'Rs:" + tab.loan_amt + "' has been given to '" + tab.name + "'.";
                        //return RedirectToAction("fundlist", new { id = (Convert.ToInt32(Session["id"])) });
                        return(RedirectToAction("fundlist", new { id = tab.id }));
                    }
                    else
                    {
                        TempData["insufficient_bal"] = "There is no Sufficient balance for this loan amount.";
                        return(RedirectToAction("fundlist", new { id = (Convert.ToInt32(Session["id"])) }));
                    }
                }
                else
                {
                    ViewBag.loanamt_null = "please select loan amount";
                    return(View());
                }
                //}
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ActionResult collectfund(valuesto_sp_funds_ofMember tab)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //DateTime date_pass=Convert.ToDateTime(tab.paid_dt);

                    long avl_bl = Convert.ToInt64(db.sp_checkbal().FirstOrDefault());
                    if (0 < tab.inst_amt || tab.inst_amt != 0)
                    {
                        ObjectParameter retbal      = new ObjectParameter("bal_amt", 0);
                        ObjectParameter trans_type  = new ObjectParameter("trans_type", 0);
                        ObjectParameter retsl_no    = new ObjectParameter("sl_no", 0);
                        ObjectParameter ret_avl_bal = new ObjectParameter("avl_bal", 0);
                        ObjectParameter ret_loan_id = new ObjectParameter("loan_idout", typeof(int));

                        // DateTime resdate = Convert.ToDateTime(retdate.Value);
                        int no_ofdue = Convert.ToInt32(db.sp_no_ofweeks(tab.name, tab.paid_dt).FirstOrDefault());
                        if (0 == no_ofdue || no_ofdue == 1)
                        {
                            //suppose,if i'm paying for next week. The above procedure will return 1.
                            //but,there will be no dues.
                            //if the member skips one week it will return 2. then, due =1
                            //because,one week skipped

                            //int res = db.sp_fund_collection_new(Convert.ToInt32(Session["id"]), tab.name, Convert.ToInt64(Session["mob"]),
                            //Convert.ToInt32(Session["loan"]), tab.inst_amt,
                            // 0, tab.paid_dt, trans_type, retsl_no, ret_avl_bal);
                            int result = db.sp_funds_ofMember(tab.loan_id, Convert.ToInt32(Session["col_id"]), tab.name, Convert.ToInt32(Session["col_loan"]),
                                                              tab.inst_amt, retbal, 0, tab.paid_dt, trans_type, retsl_no, ret_avl_bal, ret_loan_id);
                        }
                        else
                        {
                            int due = no_ofdue - 1;

                            //int res = db.sp_fund_collection_new(Convert.ToInt32(Session["id"]), tab.name, Convert.ToInt64(Session["mob"]),
                            //Convert.ToInt32(Session["loan"]), tab.inst_amt,
                            // due, tab.paid_dt, trans_type, retsl_no, ret_avl_bal);

                            int result = db.sp_funds_ofMember(tab.loan_id, Convert.ToInt32(Session["col_id"]), tab.name, Convert.ToInt32(Session["col_loan"]),
                                                              tab.inst_amt, retbal, due, tab.paid_dt, trans_type, retsl_no, ret_avl_bal, ret_loan_id);
                        }

                        this.db.SaveChanges();
                        TempData["Trans_message"] = "Amount of 'Rs:" + tab.inst_amt + "' has been credited by '" + tab.name + "'.";
                        return(RedirectToAction("fundlist", new { id = (Convert.ToInt32(Session["col_id"])) }));
                    }
                    else
                    {
                        TempData["amt_negtive_or_zero"] = "Invalid amount.";
                        return(RedirectToAction("collectfund", new { id = (Convert.ToInt32(Session["col_id"])) }));
                    }
                }
                ViewBag.nonullvaluestoaddmember = "please enter the details correctly..!";
                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }