예제 #1
0
        public ActionResult Edit(proposal_info proposal_info)
        {
            if (ModelState.IsValid)
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];

                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Guid.NewGuid() + Path.GetFileName(file.FileName);
                        pros_attachments_info attachment_info = new pros_attachments_info()
                        {
                            fileName = fileName,

                            pid = proposal_info.Id
                        };


                        var extension = Path.GetExtension(file.FileName);
                        var path      = Path.Combine(Server.MapPath("~/App_Data/PUpload/"), attachment_info.fileName);
                        file.SaveAs(path);
                        db.Entry(attachment_info).State = EntityState.Added;
                    }
                }



                db.Entry(proposal_info).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.eid = new SelectList(db.enquiry, "Id", "projectname", proposal_info.eid);
            return(View(proposal_info));
        }
        // GET: proposal_info/Delete/5

        /*  public ActionResult Delete(long? id)
         * {
         *    if (id == null)
         *    {
         *        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         *    }
         *    proposal_info proposal_info = db.proposal.Find(id);
         *    if (proposal_info == null)
         *    {
         *        return HttpNotFound();
         *    }
         *    return View(proposal_info);
         * }
         *
         * // POST: proposal_info/Delete/5
         * [HttpPost, ActionName("Delete")]
         * [ValidateAntiForgeryToken] */

        public ActionResult DeleteConfirmed(long id)
        {
            proposal_info proposal_info = db.proposal.Find(id);

            db.proposal.Remove(proposal_info);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,eid,prop_enquiry,sentdate,sent_to,sent_via")] proposal_info proposal_info)
 {
     if (ModelState.IsValid)
     {
         db.Entry(proposal_info).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.eid = new SelectList(db.enquiry, "Id", "projectname", proposal_info.eid);
     return(View(proposal_info));
 }
예제 #4
0
        // GET: proposal_info/Delete/5

        /*  public ActionResult Delete(long? id)
         * {
         *    if (id == null)
         *    {
         *        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         *    }
         *    proposal_info proposal_info = db.proposal.Find(id);
         *    if (proposal_info == null)
         *    {
         *        return HttpNotFound();
         *    }
         *    return View(proposal_info);
         * }
         *
         * // POST: proposal_info/Delete/5
         * [HttpPost, ActionName("Delete")]
         * [ValidateAntiForgeryToken] */

        public ActionResult DeleteConfirmed(long id)
        {
            proposal_info proposal_info = db.proposal.Find(id);

            db.proposal.Remove(proposal_info);
            var invoice_main = db.invoice_main.Where(m => m.pid == proposal_info.Id);

            db.invoice_main.RemoveRange(invoice_main);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: proposal_info/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            proposal_info proposal_info = db.proposal.Find(id);

            if (proposal_info == null)
            {
                return(HttpNotFound());
            }
            return(View(proposal_info));
        }
        // GET: proposal_info/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            proposal_info proposal_info = db.proposal.Find(id);

            if (proposal_info == null)
            {
                return(HttpNotFound());
            }
            ViewBag.eid = new SelectList(db.enquiry, "Id", "projectname", proposal_info.eid);
            return(View(proposal_info));
        }
예제 #7
0
        // GET: proposal_info/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            proposal_info proposal_info = db.proposal.Include(s => s.pros_attachments).SingleOrDefault(x => x.Id == id);

            if (proposal_info == null)
            {
                return(HttpNotFound());
            }
            ViewBag.eid = new SelectList(db.enquiry, "Id", "projectname", proposal_info.eid);
            return(View(proposal_info));
        }
        public ActionResult Create([Bind(Include = "Id,eid,prop_enquiry,sentdate,sent_to,sent_via")] proposal_info proposal_info)
        {
            if (ModelState.IsValid)
            {
                /*   var result = (from r in db.enquiry
                 *               join t in db.client_info on r.cid equals t.id
                 *               where r.projectname.ToLower().Contains(term.ToLower())
                 *               select new { r.projectname, t.email_id, r.Id });
                 *
                 *  return Json(result, JsonRequestBehavior.AllowGet); */

                //  if (userexist != null)
                // {

                List <pros_attachments_info> attachment = new List <pros_attachments_info>();
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];

                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Guid.NewGuid() + Path.GetFileName(file.FileName);
                        pros_attachments_info attachment_info = new pros_attachments_info()
                        {
                            fileName = fileName
                        };

                        attachment.Add(attachment_info);
                        var extension = Path.GetExtension(file.FileName);
                        var path      = Path.Combine(Server.MapPath("~/App_Data/PUpload/"), attachment_info.fileName);
                        file.SaveAs(path);
                    }
                }

                /*    var q = from c in db.enquiry where c.projectname == proposal_info.prop_enquiry select c;
                 *
                 *  if (q != null)
                 *     {
                 *       foreach (var cust in q)
                 *        {
                 *            proposal_info.eid = cust.Id;
                 *        }
                 *     }
                 *  else
                 *     {
                 *       proposal_info.eid = null;
                 *    } */
                if (proposal_info.eid != null)
                {
                    enquiry_info e_info = db.enquiry.Find(proposal_info.eid);

                    e_info.status          = Status.Proposal;
                    db.Entry(e_info).State = EntityState.Modified;
                    db.SaveChanges();
                }

                db.proposal.Add(proposal_info);
                proposal_info.pros_attachments = attachment;
                db.SaveChanges();

                return(RedirectToAction("Index"));
                //  }

                /*  else
                 * {
                 *    ModelState.AddModelError("", "project doesnot exists");
                 *
                 *    return View(proposal_info);
                 *
                 * }*/
            }



            ViewBag.cid = new SelectList(db.enquiry, "id", "projectname", proposal_info.eid);

            return(View(proposal_info));

            /*  if (ModelState.IsValid)
             * {
             *    db.proposal.Add(proposal_info);
             *    db.SaveChanges();
             *    return RedirectToAction("Index");
             * }
             *
             * ViewBag.eid = new SelectList(db.enquiry, "Id", "projectname", proposal_info.eid);
             * return View(proposal_info); */
        }