示例#1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     using (DataContext dataContext = new DataContext())
     {
         DonationDetail donationDetail =
             donationDetailBindingSource.Current as DonationDetail;
         if (donationDetail != null)
         {
             if (dataContext.Entry <DonationDetail>(donationDetail).State == EntityState.Detached)
             {
                 dataContext.Set <DonationDetail>().Attach(donationDetail);
             }
             if (donationDetail.Id == 0)
             {
                 dataContext.Entry <DonationDetail>(donationDetail).State = EntityState.Added;
             }
             else
             {
                 dataContext.Entry <DonationDetail>(donationDetail).State = EntityState.Modified;
             }
             dataContext.SaveChanges();
             MetroFramework.MetroMessageBox.Show(this, "Entrada guardada");
             grdDatos.Refresh();
             pnlDatos.Enabled = false;
         }
     }
 }
示例#2
0
 private void btnEditar_Click(object sender, EventArgs e)
 {
     pnlDatos.Enabled = true;
     txtNombre.Focus();
     DonationDetail donationDetail =
         donationDetailBindingSource.Current as DonationDetail;
 }
示例#3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (MetroFramework.MetroMessageBox.Show(this,
                                                    "¿Quieres eliminar esta entrada?",
                                                    "Eliminar",
                                                    MessageBoxButtons.YesNo,
                                                    MessageBoxIcon.Question) == DialogResult.Yes)
            {
                using (DataContext dataContext = new DataContext())
                {
                    DonationDetail donationDetail =
                        donationDetailBindingSource.Current as DonationDetail;
                    if (donationDetail != null)
                    {
                        if (dataContext.Entry <DonationDetail>(donationDetail).State == EntityState.Detached)
                        {
                            dataContext.Set <DonationDetail>().Attach(donationDetail);
                        }
                        dataContext.Entry <DonationDetail>(donationDetail).State = EntityState.Deleted;
                        dataContext.SaveChanges();
                        MetroFramework.MetroMessageBox.Show(this, "Entrada eliminada");
                        donationDetailBindingSource.RemoveCurrent();

                        pnlDatos.Enabled = false;
                    }
                }
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            DonationDetail donationDetail = db.DonationDetails.Find(id);

            db.DonationDetails.Remove(donationDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#5
0
        private void frmEntrada_Load(object sender, EventArgs e)
        {
            using (DataContext dataContext = new DataContext())
            {
                donationDetailBindingSource.DataSource = dataContext.DonationDetails.ToList();
            }
            pnlDatos.Enabled = false;

            DonationDetail donationDetail = donationDetailBindingSource.Current as DonationDetail;
        }
 public ActionResult Edit([Bind(Include = "DonationID,DonationName,Description,ImageURL,Price,isMonthly")] DonationDetail donationDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(donationDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(donationDetail));
 }
        public ActionResult Create([Bind(Include = "DonationID,DonationName,Description,ImageURL,Price,isMonthly")] DonationDetail donationDetail)
        {
            if (ModelState.IsValid)
            {
                db.DonationDetails.Add(donationDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(donationDetail));
        }
示例#8
0
        // GET: PersonalInfoes/Create
        public ActionResult Create(DonationDetail donation)
        {
            if (Session["isAdmin"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            ViewBag.UserID = new SelectList(db.Users, "UserID", "FirstName");
            //ViewBag.DonationName = donation.DonationName;
            ViewData["DonationName"] = donation.DonationName;
            //TempData["DonationID"] = donation.DonationID;

            return(View());
        }
        public ActionResult Edit([Bind(Include = "DonationID,DonationName,Description,ImageURL,Price,isMonthly")] DonationDetail donationDetail, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                string path = Path.Combine(Server.MapPath("~/Images/"), Path.GetFileName(file.FileName));
                file.SaveAs(path);
                donationDetail.ImageURL = "~/Images/" + file.FileName;

                db.Entry(donationDetail).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(donationDetail));
        }
示例#10
0
        public void SaveDonationDetail(CreateTicketCommand command)
        {
            // Donation Categories
            var donationTicket = command.Tickets.Where(s => s.TicketCategoryId == 19452 || s.TicketCategoryId == 12259).FirstOrDefault();

            if (donationTicket != null)
            {
                var donationDetail  = new DonationDetail();
                var donationDetail1 = _donationDetailRepository.GetByEventId(command.EventId);
                donationDetail.Id = donationDetail1 != null ? donationDetail1.Id : 0;
                donationDetail.DonationAmount1 = donationTicket.DonationAmount1;
                donationDetail.DonationAmount2 = donationTicket.DonationAmount2;
                donationDetail.DonationAmount3 = donationTicket.DonationAmount3;
                donationDetail.EventId         = command.EventId;
                donationDetail.IsFreeInput     = true;
                donationDetail.CreatedUtc      = DateTime.UtcNow;
                donationDetail.CreatedBy       = Guid.NewGuid();
                donationDetail.IsEnabled       = true;
                _donationDetailRepository.Save(donationDetail);
            }
        }
        // GET: DonationDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (Session["isAdmin"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            else if (Session["isAdmin"].ToString() != "True")
            {
                return(RedirectToAction("Login", "Home"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DonationDetail donationDetail = db.DonationDetails.Find(id);

            if (donationDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(donationDetail));
        }
示例#12
0
 private void grdDatos_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     DonationDetail donationDetail = donationDetailBindingSource.Current as DonationDetail;
 }