public void SavePermitInfo() { if (NewJob != null && NewPermit != null && NewPermit.Count > 0) { try { foreach (CS_JobPermit jobPermit in NewPermit) { CS_JobPermit jp = new CS_JobPermit(); jp.Active = jobPermit.Active; jp.AgencyOperator = jobPermit.AgencyOperator; jp.AgentOperatorName = jobPermit.AgentOperatorName; jp.CreatedBy = jobPermit.CreatedBy; jp.CreationDate = jobPermit.CreationDate; jp.CreationID = jobPermit.CreationID; jp.FileName = jobPermit.FileName; jp.ID = jobPermit.ID; jp.JobID = NewJob.ID; jp.Location = jobPermit.Location; jp.ModificationDate = jobPermit.ModificationDate; jp.ModificationID = jobPermit.ModificationID; jp.ModifiedBy = jobPermit.ModifiedBy; jp.Number = jobPermit.Number; jp.Path = jobPermit.Path; jp.PermitDate = jobPermit.PermitDate; jp.Type = jobPermit.Type; // jobPermit.JobID = NewJob.ID; _jobPermitRepository.Add(jp); } } catch (Exception ex) { throw new Exception("There was an error saving the Job Permit data. Please verify the content of the fields and try again.", ex); } } }
protected void btnAdd_Click(object sender, EventArgs e) { if (Page.IsValid) { _permitInfoItem = new CS_JobPermit(); _permitInfoItem.Type = int.Parse(cbPermitType.SelectedValue); _permitInfoItem.CS_JobPermitType = new CS_JobPermitType() { Description = cbPermitType.SelectedItem.Text }; _permitInfoItem.Number = txtPermitNumber.Text; _permitInfoItem.Location = txtPermitLocation.Text; if (!string.IsNullOrEmpty(txtAgencyOperator.Text.Trim())) _permitInfoItem.AgencyOperator = txtAgencyOperator.Text.Trim(); else _permitInfoItem.AgencyOperator = null; if (!string.IsNullOrEmpty(txtAgentOperator.Text.Trim())) _permitInfoItem.AgentOperatorName = txtAgentOperator.Text.Trim(); else _permitInfoItem.AgentOperatorName = null; if (dpPermitDate.Value.HasValue) _permitInfoItem.PermitDate = dpPermitDate.Value; else _permitInfoItem.PermitDate = null; if (null != FileName) { _permitInfoItem.FileName = FileName; _permitInfoItem.Path = FilePath; } _permitInfoItem.CreatedBy = ((ContentPage)Page.Master).Username; _permitInfoItem.CreationDate = DateTime.Now; _permitInfoItem.ModifiedBy = ((ContentPage)Page.Master).Username; _permitInfoItem.ModificationDate = DateTime.Now; _presenter.AddPermit(); } ScriptManager.GetCurrent(this.Page).SetFocus(btnAdd); }