protected override void DeleteChildEntities(string[] childEntityList, string parentID) { foreach (string ChildEntity in childEntityList) { switch (ChildEntity) { #region /* Case Statements - All child grids */ case "ScaleDetails": if (Convert.ToInt32(parentID) > 0) { ScaleDetailsLibrary ScaleDetailsLibrary = new ScaleDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ScaleDetails> resultList = ScaleDetailsLibrary.GetAllByParentID(Convert.ToInt32(parentID)); foreach (ScaleDetails scaleDetails in resultList) { ScaleDetailsLibrary.Delete(scaleDetails.ID.ToString()); } } break; case "ScaleNotes": if (Convert.ToInt32(parentID) > 0) { ScaleNotesLibrary ScaleNotesLibrary = new ScaleNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ScaleNotes> resultList = ScaleNotesLibrary.GetAllByParentID(Convert.ToInt32(parentID)); foreach (ScaleNotes ScaleNote in resultList) { ScaleNotesLibrary.Delete(ScaleNote.ID.ToString()); } } break; case "ScaleAttachments": if (Convert.ToInt32(parentID) > 0) { ScaleAttachmentsLibrary ScaleLibrary = new ScaleAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ScaleAttachments> resultList = ScaleLibrary.GetAllByParentID(Convert.ToInt32(parentID)); foreach (ScaleAttachments scaleAttachment in resultList) { ScaleLibrary.Delete(scaleAttachment.ID.ToString()); } } break; //case "ScaleIDCardAttachments": // if (Convert.ToInt32(parentID) > 0) { // ScaleIDCardAttachmentsLibrary ScaleLibrary = new ScaleIDCardAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); // IEnumerable<ScaleIDCardAttachments> resultList = ScaleLibrary.GetAllByParentID(Convert.ToInt32(parentID)); // foreach (ScaleIDCardAttachments scaleAttachment in resultList) { // ScaleLibrary.Delete(scaleAttachment.ID.ToString()); // } // } //break; #endregion } } }
protected override void SaveChildEntities(string[] childEntityList, Scale entity) { foreach (string ChildEntity in childEntityList) { switch (ChildEntity) { #region /* Case Statements - All child grids */ case "ScaleDetails": if (Session[ChildEntity] != null) { ScaleDetailsLibrary ScaleDetailsLibrary = new ScaleDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ScaleDetails> resultList = (IList <ScaleDetails>)Session[ChildEntity]; foreach (ScaleDetails scaleDetails in resultList) { scaleDetails.Scale = new Scale { ID = entity.ID }; ScaleDetailsLibrary.Add(scaleDetails); } } break; case "ScaleNotes": if (Session[ChildEntity] != null) { ScaleNotesLibrary ScaleNotesLibrary = new ScaleNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ScaleNotes> resultList = (IList <ScaleNotes>)Session[ChildEntity]; foreach (ScaleNotes ScaleNote in resultList) { ScaleNote.Parent = new Scale { ID = entity.ID }; //itemNote.Notes = System.Web.HttpUtility.HtmlDecode(itemNote.Notes); ScaleNotesLibrary.Add(ScaleNote); } } break; case "ScaleAttachments": if (Session[ChildEntity] != null) { ScaleAttachmentsLibrary ScaleLibrary = new ScaleAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ScaleAttachments> resultList = (IList <ScaleAttachments>)Session[ChildEntity]; string destinationPath; string sourcePath; FilelHelper fileHelper = new FilelHelper(); foreach (ScaleAttachments Scale in resultList) { destinationPath = fileHelper.GetSourceDirByFileRefId(Scale.Document_RefId.ToString()); // Path.Combine(Configuration.GetsmARTDocPath(), Scale.Document_RefId.ToString()); sourcePath = fileHelper.GetTempSourceDirByFileRefId(Scale.Document_RefId.ToString()); // Path.Combine(Configuration.GetsmARTTempDocPath(), Scale.Document_RefId.ToString()); Scale.Document_Path = fileHelper.GetFilePath(sourcePath); fileHelper.MoveFile(Scale.Document_Name, sourcePath, destinationPath); Scale.Parent = new Scale { ID = entity.ID }; ScaleLibrary.Add(Scale); } } break; //case "ScaleIDCardAttachments": // if (Session[ChildEntity] != null) { // ScaleIDCardAttachmentsLibrary ScaleLibrary = new ScaleIDCardAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); // IEnumerable<ScaleIDCardAttachments> resultList = (IList<ScaleIDCardAttachments>) Session[ChildEntity]; // string destinationPath; // string sourcePath; // FilelHelper fileHelper = new FilelHelper(); // foreach (ScaleIDCardAttachments Scale in resultList) { // destinationPath = fileHelper.GetSourceDirByFileRefId(Scale.Document_RefId.ToString());// Path.Combine(Configuration.GetsmARTDocPath(), Scale.Document_RefId.ToString()); // sourcePath = fileHelper.GetTempSourceDirByFileRefId(Scale.Document_RefId.ToString()); // Path.Combine(Configuration.GetsmARTTempDocPath(), Scale.Document_RefId.ToString()); // Scale.Document_Path = fileHelper.GetFilePath(sourcePath); // fileHelper.MoveFile(Scale.Document_Name, sourcePath, destinationPath); // Scale.Parent = new Scale { // ID = entity.ID // }; // ScaleLibrary.Add(Scale); // } // } // break; case "ScaleExpense": if (Session[ChildEntity] != null) { ScaleExpenseLibrary lib = new ScaleExpenseLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ExpensesRequest> resultList = (IList <ExpensesRequest>)Session[ChildEntity]; foreach (ExpensesRequest exp in resultList) { exp.Reference = new Invoice { ID = entity.ID }; exp.Reference_Table = entity.GetType().Name; exp.Reference_ID = entity.ID; lib.Add(exp); } } break; #endregion } } }