Пример #1
0
        public ActionResult Create([Bind(Include = "Id,JobDate,CustomerId,Description,NoOfPax,NoOfDays,AgreedAmt,JobRemarks,JobStatusId,StatusRemarks,BranchId,JobThruId,CustContactEmail,CustContactNumber")] JobMain jobMain)
        {
            if (ModelState.IsValid)
            {
                if (jobMain.CustContactEmail == null && jobMain.CustContactNumber == null)
                {
                    var cust = db.Customers.Find(jobMain.CustomerId);
                    jobMain.CustContactEmail  = cust.Email;
                    jobMain.CustContactNumber = cust.Contact1;
                }

                db.JobMains.Add(jobMain);
                db.SaveChanges();

                dbc.addEncoderRecord("joborder", jobMain.Id.ToString(), HttpContext.User.Identity.Name, "Create New Job");


                if (jobMain.CustomerId == NewCustSysId)
                {
                    return(RedirectToAction("CreateCustomer", new { jobid = jobMain.Id }));
                }
                else
                {
                    return(RedirectToAction("Services", "JobServices", new { id = jobMain.Id }));
                }
                //return RedirectToAction("JobTable", new { span = 30 });
                //return RedirectToAction("Index");
            }

            ViewBag.CustomerId  = new SelectList(db.Customers.Where(d => d.Status == "ACT"), "Id", "Name", jobMain.CustomerId);
            ViewBag.BranchId    = new SelectList(db.Branches, "Id", "Name", jobMain.BranchId);
            ViewBag.JobStatusId = new SelectList(db.JobStatus, "Id", "Status", jobMain.JobStatusId);
            ViewBag.JobThruId   = new SelectList(db.JobThrus, "Id", "Desc", jobMain.JobThruId);
            return(View(jobMain));
        }
        public ActionResult CreateQuotation([Bind(Include = "Id,JobDate,CustomerId,Description,NoOfPax,NoOfDays,AgreedAmt,JobRemarks,JobStatusId,StatusRemarks,BranchId,JobThruId,CustContactEmail,CustContactNumber")] JobMain jobMain, int rsvid)
        {
            if (ModelState.IsValid)
            {
                if (jobMain.CustContactEmail == null && jobMain.CustContactNumber == null)
                {
                    var cust = db.Customers.Find(jobMain.CustomerId);
                    jobMain.CustContactEmail  = cust.Email;
                    jobMain.CustContactNumber = cust.Contact1;
                }

                db.JobMains.Add(jobMain);
                db.SaveChanges();

                //link job to reservation
                linkQuotation(rsvid, jobMain.Id);

                dbc.addEncoderRecord("joborder-reservation", jobMain.Id.ToString(), HttpContext.User.Identity.Name, "Create New Job for Reservation");

                return(RedirectToAction("Index", "JobOrder", new { sortid = 1 }));
            }

            ViewBag.CustomerId  = new SelectList(db.Customers.Where(d => d.Status != "INC"), "Id", "Name", jobMain.CustomerId);
            ViewBag.BranchId    = new SelectList(db.Branches, "Id", "Name", jobMain.BranchId);
            ViewBag.JobStatusId = new SelectList(db.JobStatus, "Id", "Status", jobMain.JobStatusId);
            ViewBag.JobThruId   = new SelectList(db.JobThrus, "Id", "Desc", jobMain.JobThruId);

            return(View(jobMain));
        }