///<Summary>This is normally done in FormSheetFillEdit, but if we bypass that window for some reason, we can also save a new sheet here. Signature ///fields are inserted as they are, so they must be keyed to the field values already. Saves the sheet and sheetfields exactly as they are. Used by ///webforms, for example, when a sheet is retrieved from the web server and the sheet signatures have already been keyed to the field values and ///need to be inserted as-is into the user's db.</Summary> public static void SaveNewSheet(Sheet sheet) { //This remoting role check is technically unnecessary but it significantly speeds up the retrieval process for Middle Tier users due to looping. if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), sheet); return; } if (!sheet.IsNew) { throw new ApplicationException("Only new sheets allowed"); } Insert(sheet); //insert 'blank' sheetfields to get sheetfieldnums assigned, then use ordered sheetfieldnums with actual field data to update 'blank' db fields List <long> listSheetFieldNums = sheet.SheetFields.Select(x => SheetFields.Insert(new SheetField() { SheetNum = sheet.SheetNum })) .OrderBy(x => x)//PKs of all sheet fields that were just inserted. Signatures require sheet fields be ordered by PK. .ToList(); if (listSheetFieldNums.Count != sheet.SheetFields.Count) //shouldn't be possible, just in case { Delete(sheet.SheetNum); //any blank inserted sheetfields will be linked to the sheet marked deleted throw new ApplicationException("Incorrect sheetfield count."); } //now that we have an ordered list of sheetfieldnums, update db blank fields with all field data from field in memory for (int i = 0; i < sheet.SheetFields.Count; i++) { SheetField fld = sheet.SheetFields[i]; fld.SheetFieldNum = listSheetFieldNums[i]; fld.SheetNum = sheet.SheetNum; SheetFields.Update(fld); } }
///<summary>Converts parameters into sheetfield objects, and then saves those objects in the database. The parameters will never again enjoy full parameter status, but will just be read-only fields from here on out. It ignores PatNum parameters, since those are already part of the sheet itself.</summary> public static void SaveParameters(Sheet sheet) { //No need to check RemotingRole; no call to db SheetField field; for (int i = 0; i < sheet.Parameters.Count; i++) { if (sheet.Parameters[i].ParamName == "PatNum") { continue; } field = new SheetField(); field.IsNew = true; field.SheetNum = sheet.SheetNum; field.FieldType = SheetFieldType.Parameter; field.FieldName = sheet.Parameters[i].ParamName; field.FieldValue = sheet.Parameters[i].ParamValue.ToString(); //the object will be an int. Stored as a string. field.FontSize = 0; field.FontName = ""; field.FontIsBold = false; field.XPos = 0; field.YPos = 0; field.Width = 0; field.Height = 0; field.GrowthBehavior = GrowthBehaviorEnum.None; field.RadioButtonValue = ""; SheetFields.Insert(field); } }
///<Summary>This is normally done in FormSheetFillEdit, but if we bypass that window for some reason, we can also save a new sheet here. Does not save any drawings. Does not save signatures. Does not save any parameters (PatNum parameters never get saved anyway).</Summary> public static void SaveNewSheet(Sheet sheet) { //No need to check RemotingRole; no call to db. if (!sheet.IsNew) { throw new Exception("Only new sheets allowed"); } Insert(sheet); foreach (SheetField fld in sheet.SheetFields) { fld.SheetNum = sheet.SheetNum; SheetFields.Insert(fld); } }
///<Summary>This is normally done in FormSheetFillEdit, but if we bypass that window for some reason, we can also save a new sheet here. Does not save any drawings. Does not save signatures. Does not save any parameters (PatNum parameters never get saved anyway).</Summary> public static void SaveNewSheet(Sheet sheet) { //This remoting role check is technically unnecessary but it significantly speeds up the retrieval process for Middle Tier users due to looping. if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), sheet); return; } if (!sheet.IsNew) { throw new Exception("Only new sheets allowed"); } Insert(sheet); foreach (SheetField fld in sheet.SheetFields) { fld.SheetNum = sheet.SheetNum; SheetFields.Insert(fld); } }