// GET: Payments/Create public ActionResult PaymentsCreate(int? id) { Payments payment = new Payments(); Events currEvent = db.Events.Find(id); PaymentSetup ps = db.PaymentSetup.FirstOrDefault(x => x.EventKey == (int)id); payment.Amount = ps.Amount; if (ps.hasSpecial) { //payment.paymentSpecValues = new List<PaymentSpecValues>(); //Dist23MVC.Models.clsDataGetter dg = new Models.clsDataGetter(ConfigurationManager.ConnectionStrings["Dist23Data"].ConnectionString); //int paymentSetupKey = payment.paymentSetup.pKey; //string sql = "SELECT * FROM PaymentSpecValues WHERE PaymentSetupKey=" + paymentSetupKey.ToString(); //System.Data.SqlClient.SqlDataReader dr = dg.GetDataReader(sql); //while (dr.Read()) //{ // PaymentSpecValues psv = new PaymentSpecValues(); // psv.pKey = (int)dr["pKey"]; // psv.SpecialValue = dr["SpecialValue"].ToString(); // psv.SpecialAmount = (decimal)dr["SpecialAmount"]; // psv.PaymentSetupKey = paymentSetupKey; // payment.paymentSpecValues.Add(psv); //} } ViewBag.EventName = currEvent.EventName; if (id != null) payment.EventKey = (int)id; payment.PaymentDate = DateTime.Now; payment.PaymentType = "event"; return View(payment); }
public ActionResult PaymentsCreate(Payments payments) { if (ModelState.IsValid) { db.Payments.Add(payments); db.SaveChanges(); return RedirectToAction("PaymentsDetails",new { id = payments.pKey }); } return View(payments); }
public ActionResult PaymentsEdit(Payments payments) { if (ModelState.IsValid) { db.Entry(payments).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("PaymentsIndex"); } return View(payments); }