public ActionResult Add(int id, int ProjectOrMinorWork, string PMWEnquiryReceivedDate, int? DirectorateID,
            int? PMWContact, int? AuthorisedByName,
            string PMWDescription, FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                var pmw = new ProjectMinorWork();
                pmw.PremiseID = id;
                pmw.PMWDescription = PMWDescription;
                pmw.ProjectOrMinorWork = ProjectOrMinorWork;
                pmw.PMWContact = PMWContact;
                pmw.AuthorisedByName = AuthorisedByName;
                if (collection["PMWIsTBA"] == "1")
                {
                    pmw.PMWIsTBA = 1;
                }
                else
                {
                    pmw.PMWIsTBA = 0;
                    pmw.NotesActions = collection["NotesActions"];
                    pmw.EstimatedCost = collection["EstimatedCost"];
                }
                pmw.PMWStatus = collection["PMWStatus"];
                pmw.PMWEnquiryReceivedDate =(DateTime)_db.ConvertDate(PMWEnquiryReceivedDate,"dd/MM/yyyy");
                pmw.AuthorisedDate = _db.ConvertDate(collection["AuthorisedDate"], "dd/MM/yyyy");
                pmw.ActualStartDate = _db.ConvertDate(collection["ActualStartDate"], "dd/MM/yyyy");
                pmw.AnticipatedCompletion = _db.ConvertDate(collection["AnticipatedCompletion"], "dd/MM/yyyy");
                pmw.ActualCompletionDate = _db.ConvertDate(collection["ActualCompletionDate"], "dd/MM/yyyy");
                pmw.ActualCost = collection["ActualCost"];
                pmw.Directorate = DirectorateID;
                pmw.PMWIsActive = 1;
                _db.Insert(pmw);

                ViewBag.Alert = "true";
                ViewBag.Message = "Action success!";
                ViewBag.URL = "/Premise/Amend/" + id + "#tabs-7";

                return View("../Shared/Redirect");
            }
            catch
            {
                return View("../Shared/Error");
            }
        }
 //insert
 public void Insert(ProjectMinorWork pmw)
 {
     _db.ProjectMinorWorks.InsertOnSubmit(pmw);
     _db.SubmitChanges();
 }
 partial void UpdateProjectMinorWork(ProjectMinorWork instance);
 partial void DeleteProjectMinorWork(ProjectMinorWork instance);
 partial void InsertProjectMinorWork(ProjectMinorWork instance);
		private void detach_ProjectMinorWorks1(ProjectMinorWork entity)
		{
			this.SendPropertyChanging();
			entity.Contact1 = null;
		}
		private void attach_ProjectMinorWorks(ProjectMinorWork entity)
		{
			this.SendPropertyChanging();
			entity.Contact = this;
		}
		private void detach_ProjectMinorWorks(ProjectMinorWork entity)
		{
			this.SendPropertyChanging();
			entity.Premise = null;
		}
		private void detach_ProjectMinorWorks(ProjectMinorWork entity)
		{
			this.SendPropertyChanging();
			entity.Directorate1 = null;
		}