예제 #1
0
        public ActionResult Edit(int id, Vyplata_kredita collection)
        {
            try
            {
                // TODO: Add update logic here

                List <Month> mlist = db.Month.ToList();
                ViewBag.Month = new SelectList(mlist, "ID", "Month");
                if (BudgetCheck(Convert.ToDecimal(collection.Sum_all)) && BudgetCheck(Convert.ToDecimal(collection.Procent)) && BudgetCheck(Convert.ToDecimal(collection.Sum)))
                {
                    db.Entry(collection).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var ex = "Недостаточно средств";
                    Session["error"] = ex;
                    return(RedirectToAction("Edit", new RouteValueDictionary(
                                                new { controller = "Vyplata_kredita", action = "Edit", id = collection.ID })));
                }
            }
            catch
            {
                return(View());
            }
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Vyplata_kredita vyplata_kredita = db.Vyplata_kredita.Find(id);

            db.Vyplata_kredita.Remove(vyplata_kredita);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        // GET: Vyplata_kredita/Edit/5
        public ActionResult Edit(int?id)
        {
            ViewBag.err      = Session["error"];
            Session["error"] = null;
            List <Poluchenie_kredita> wlist = db.Poluchenie_kredita.ToList();

            ViewBag.Poluchenie_kredita = new SelectList(wlist, "ID", "Bank");
            Vyplata_kredita rep = db.Vyplata_kredita.Find(id);

            return(View(rep));
        }
예제 #4
0
        // GET: Vyplata_kredita/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Vyplata_kredita vyplata_kredita = db.Vyplata_kredita.Find(id);

            if (vyplata_kredita == null)
            {
                return(HttpNotFound());
            }
            return(View(vyplata_kredita));
        }
예제 #5
0
        public ActionResult Create(Vyplata_kredita collection)
        {
            try
            {
                // TODO: Add insert logic here
                List <Poluchenie_kredita> wlist = db.Poluchenie_kredita.ToList();
                ViewBag.Poluchenie_kredita = new SelectList(wlist, "ID", "Bank");
                //DB.Repayment.Add(collection);
                //DB.SaveChanges();
                string connectionString = @"Data Source=DESKTOP-M4OCJ2O\SQLEXPRESS;Initial Catalog=shop;Integrated Security=True";
                string sqlExpression    = "insert_into_repayment";
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(sqlExpression, connection);
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    SqlParameter bankParameter = new SqlParameter
                    {
                        ParameterName = "@credit",
                        Value         = collection.Kredit
                    };
                    command.Parameters.Add(bankParameter);
                    SqlParameter dateParameter = new SqlParameter
                    {
                        ParameterName = "@payment_date",
                        Value         = collection.Date
                    };

                    command.Parameters.Add(dateParameter);
                    // var result = command.ExecuteNonQuery();
                    command.ExecuteNonQuery();
                }
                List <Vyplata_kredita> list = db.Vyplata_kredita.ToList();
                Vyplata_kredita        rep  = list.Last();
                return(RedirectToAction("Edit", new RouteValueDictionary(
                                            new { controller = "Vyplata_kredita", action = "Edit", id = rep.ID })));
            }
            catch
            {
                return(View());
            }
        }