// GET: AddDonorPerson
        public ActionResult Index()
        {
            var db          = new CodeFirst.CodeFirst();
            var DonorPerson = new Models.Donor_Person();

            return(View(DonorPerson));
        }
        public ActionResult Modify([Bind(Prefix = "")] Models.Donor_Person model)
        {
            var db = new CodeFirst.CodeFirst();

            if (ModelState.IsValid)
            {
                var DonorPerson = db.Donor_Person.Where(v => v.DonorPID == model.DonorPID).SingleOrDefault();

                if (DonorPerson != null)
                {
                    DonorPerson.DonorPID      = model.DonorPID;
                    DonorPerson.FirstName     = model.FirstName;
                    DonorPerson.MiddleName    = model.MiddleName;
                    DonorPerson.SecondName    = model.SecondName;
                    DonorPerson.Initials      = model.Initials;
                    DonorPerson.CellNum       = model.CellNum;
                    DonorPerson.PersonalEmail = model.PersonalEmail;
                    DonorPerson.Thanked       = model.Thanked;
                    DonorPerson.StreetAddress = model.StreetAddress;
                    DonorPerson.City          = model.City;
                    DonorPerson.AreaCode      = model.AreaCode;
                    db.SaveChanges();
                }

                TempData["js"] = "myUpdateSuccess()";
                return(RedirectToAction("Index", "DonorPerson"));
            }

            return(View("Index", model));
        }
        // GET: ModifyDonorPerson
        public ActionResult Index(string donorPID)
        {
            CodeFirst.CodeFirst db      = new CodeFirst.CodeFirst();
            Models.Donor_Person myModel = new Models.Donor_Person();
            if (donorPID != null)
            {
                var intDonorPersonID = Int32.Parse(donorPID);
                var myDonorPerson    = db.Donor_Person.Where(i => i.DonorPID == intDonorPersonID).FirstOrDefault();

                myModel.DonorPID      = myDonorPerson.DonorPID;
                myModel.FirstName     = myDonorPerson.FirstName;
                myModel.MiddleName    = myDonorPerson.MiddleName;
                myModel.SecondName    = myDonorPerson.SecondName;
                myModel.Initials      = myDonorPerson.Initials;
                myModel.CellNum       = myDonorPerson.CellNum;
                myModel.PersonalEmail = myDonorPerson.PersonalEmail;
                myModel.Thanked       = myDonorPerson.Thanked;
                myModel.StreetAddress = myDonorPerson.StreetAddress;
                myModel.City          = myDonorPerson.City;
                myModel.AreaCode      = myDonorPerson.AreaCode;

                return(View(myModel));
            }

            return(View(myModel));
        }
예제 #4
0
 // GET: DonorPerson
 public ActionResult Index()
 {
     Models.Donor_Person myModel = new Models.Donor_Person();
     if (TempData["model"] != null)
     {
         myModel = (Models.Donor_Person)TempData["model"];
         TempData.Remove("model");
     }
     return(View(myModel));
 }
        public ActionResult Create([Bind(Prefix = "")] Models.Donor_Person model)
        {
            var db = new CodeFirst.CodeFirst();

            if (ModelState.IsValid)
            {
                if (db.Donor_Person.Count() > 0)
                {
                    var item = db.Donor_Person.OrderByDescending(a => a.DonorPID).FirstOrDefault();

                    db.Donor_Person.Add(new CodeFirst.Donor_Person
                    {
                        DonorPID      = item.DonorPID + 1,
                        FirstName     = model.FirstName,
                        MiddleName    = model.MiddleName,
                        SecondName    = model.SecondName,
                        Initials      = model.Initials,
                        CellNum       = model.CellNum,
                        PersonalEmail = model.PersonalEmail,
                        Thanked       = false,
                        StreetAddress = model.StreetAddress,
                        City          = model.City,
                        AreaCode      = model.AreaCode,
                    });
                }
                else
                {
                    db.Donor_Person.Add(new CodeFirst.Donor_Person
                    {
                        DonorPID      = 1,
                        FirstName     = model.FirstName,
                        MiddleName    = model.MiddleName,
                        SecondName    = model.SecondName,
                        Initials      = model.Initials,
                        CellNum       = model.CellNum,
                        PersonalEmail = model.PersonalEmail,
                        Thanked       = false,
                        StreetAddress = model.StreetAddress,
                        City          = model.City,
                        AreaCode      = model.AreaCode,
                    });
                }

                db.SaveChanges();
                model.JavaScriptToRun = "mySuccess()";
                TempData["model"]     = model;
                return(RedirectToAction("Index", "DonorPerson"));
            }

            return(View("Index", model));
        }
예제 #6
0
        public ActionResult DonorPersonTYLetter([Bind(Prefix = "")] Models.Donor_Person model)
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Report/DonorPersonThankYouLetter.rpt")));
            rd.SetParameterValue("@PersonID", model.DonorPID);
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.WordForWindows);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/doc", "DonorThankYouLetterTemplate.doc"));
            }
            catch
            {
                throw;
            }
        }