I have three Tables in SQL with following fileds
1) Order : [OrderID (pk)], [OrderSize], [Thickness], [OD]
2) PipeAllocation : [PipeNo(PK)], [OrderID (fk)], [Length], [Status]
3) Process: [ProcessID (pk)], [PipeNo(fk)], [Date], [MPP]
for adding record in process table I want set value for MPP on criteria of Thickness so I write following code but I got error of "Object reference not set to an instance of an object.". I dont have any null value in thickness field.
my code is
- [HttpPost]
- public ActionResult CreateP3(Process process)
- {
- var tr = process.StageID + process.PIPENO + process.Status;
- var checkme = (from x in db.Processes
- where x.StageID + x.PIPENO + x.Status == tr && x.Status == "OK"
- select x).ToList();
- if (checkme.Count > 0)
- {
- ModelState.AddModelError("PIPENO", "You are trying Duplicate Pipe Entry");
- }
- if (ModelState.IsValid)
- {
- if (process.PipeAl.Order.THK > 1)
- {
- process.MPP = 10;
- }
- process.CuttingSpeed = (process.ActualMeter*1000)/process.CuttingTime;
- db.Processes.Add(process);
- db.SaveChanges();
- return RedirectToAction("IndexP3");
- }
- var EmpAtnList = db.Attens.ToList();
- IEnumerable
AttnList = from s in EmpAtnList.OrderByDescending(s => s.ATTNDATE) - select new SelectListItem
- {
- Value = s.ATTNSYSID.ToString(),
- Text = s.ATTNDATE + "--" + s.Emp.EmpName
- };
- ViewBag.ATTNSYSID = new SelectList(AttnList, "Value", "Text");
- //ViewBag.ATTNSYSID = new SelectList(db.Attens, "ATTNSYSID", "EMPCODE", process.ATTNSYSID);
- ViewBag.StageID = new SelectList(db.OMStages, "StageID", "StageName");
- ViewBag.NextStageID = new SelectList(db.OMStages.OrderBy(x => x.StageValue), "StageID", "StageName");
- ViewBag.PIPENO = new SelectList(db.PipeAls, "PIPENO", "PIPENO");
- ViewBag.Status = new SelectList(db.ValueAddLists.Where(x => x.RefName == "PipeStatus"), "RefValue", "Description", process.Status);
- return View(process);
- }

Laxmidhar SahooPosted Oct 3, 2018, 11:54 PM
Suraj KumarPosted Oct 3, 2018, 11:50 PM
Raju FodsePosted Oct 3, 2018, 11:40 PM
Suraj KumarPosted Oct 3, 2018, 1:13 AM
Raju FodsePosted Oct 3, 2018, 12:53 AM
Raju FodsePosted Oct 3, 2018, 12:30 AM
Laxmidhar SahooPosted Oct 3, 2018, 12:15 AM
Suraj KumarPosted Oct 2, 2018, 11:29 PM
Raju FodsePosted Oct 2, 2018, 11:25 PM
Laxmidhar SahooPosted Oct 2, 2018, 10:31 PM
Raju FodsePosted Oct 1, 2018, 11:35 PM
Laxmidhar SahooPosted Oct 1, 2018, 6:37 AM
Raju FodsePosted Oct 1, 2018, 6:27 AM
Laxmidhar SahooPosted Sep 29, 2018, 8:32 AM