private async void PartSaveControl(object obj) { try { Dbcontext = new ServiceReference1.Service1Client(ServiceReference1.Service1Client.EndpointConfiguration.BasicHttpBinding_IService1); ServiceReference1.InternalControlOfficeLogData logData = new ServiceReference1.InternalControlOfficeLogData(); logData.AoNr = AONr; logData.Created = PerformedDate; if (SelectedEmployee != null) { logData.CreatedById = SelectedEmployee.Id; } logData.InternalControlOfficeId = IniControlId; logData.IsPartSaved = true; logData.RegNr = RegNr; if (SelectedVehicleBrand != null) { logData.VehicleBrandId = SelectedVehicleBrand.Id; } ServiceReference1.InternalControlOfficeLogRowData rowData; if (AllRows != null && AllRows.Count > 0) { ObservableCollection <ServiceReference1.InternalControlOfficeLogRowData> temp = new ObservableCollection <ServiceReference1.InternalControlOfficeLogRowData>();; logData.Rows = new ServiceReference1.InternalControlOfficeLogRowData[AllRows.Count]; int i = 0; foreach (InternalControlPerformRow row in AllRows) { rowData = new ServiceReference1.InternalControlOfficeLogRowData(); rowData.Deleted = false; rowData.InternalControlOfficeRowId = row.InternalControlOffieRowId; rowData.IsEA = row.IsEA; rowData.IsNo = row.IsNotOk; rowData.IsYes = row.IsOk; rowData.Text = row.Question; rowData.Comment = row.Comment; logData.Rows[i] = rowData; i++; if (row.SelectedErrorCodes != null && row.SelectedErrorCodes.Count > 0) { rowData.ErrorCodes = new ServiceReference1.ICErrorCodeData[row.SelectedErrorCodes.Count]; int j = 0; ServiceReference1.ICErrorCodeData codeData; foreach (ICErrorCodeCls code in row.SelectedErrorCodes) { codeData = new ServiceReference1.ICErrorCodeData(); codeData.Code = code.Code; codeData.Id = code.Id; rowData.ErrorCodes[j] = codeData; j++; } } if (row.AddedPhotos != null && row.AddedPhotos.Count > 0) { rowData.ImageFiles = new ServiceReference1.ICOLogRowFileData[row.AddedPhotos.Count]; int h = 0; ServiceReference1.ICOLogRowFileData file; foreach (PhotoCls photo in row.AddedPhotos) { file = new ServiceReference1.ICOLogRowFileData(); file.FileName = photo.Name; file.FilePath = photo.Path; rowData.ImageFiles[h] = file; h++; } } } } string result = Dbcontext.InsertOfficeInternalControlPerformControl(Application.Current.Properties["UN"].ToString(), Application.Current.Properties["PW"].ToString(), Application.Current.Properties["Ucid"].ToString(), logData); await Dbcontext.CloseAsync(); await Application.Current.MainPage.DisplayAlert("Spara", "Kontrollen är delsparad", "Stäng"); await Application.Current.MainPage.Navigation.PopAsync(); } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Spara", e.Message, "Stäng"); } }
private async void PartSaveControl(object obj) { try { ServiceReference1.InternalControlOfficeLogData logData = new ServiceReference1.InternalControlOfficeLogData { AoNr = AONr, Created = PerformedDate, CreatedById = SelectedEmployee.Id, Deleted = false, InternalControlOfficeId = IniControlLogId, IsPartSaved = true, RegNr = RegNr, VehicleBrandId = SelectedVehicleBrand.Id, Id = IniControlLogId }; ServiceReference1.InternalControlOfficeLogRowData rowData; if (AllRows != null && AllRows.Count > 0) { ObservableCollection <ServiceReference1.InternalControlOfficeLogRowData> temp = new ObservableCollection <ServiceReference1.InternalControlOfficeLogRowData>();; logData.Rows = new ServiceReference1.InternalControlOfficeLogRowData[AllRows.Count]; int i = 0; foreach (InternalControlPerformRow row in AllRows) { rowData = new ServiceReference1.InternalControlOfficeLogRowData(); rowData.Deleted = false; // rowData.InternalControlOfficeLogRowId = row.Id; rowData.IsEA = row.IsEA; rowData.IsNo = row.IsNotOk; rowData.IsYes = row.IsOk; rowData.Text = row.Question; rowData.Id = row.Id; rowData.Comment = row.Comment; logData.Rows[i] = rowData; i++; if (row.SelectedErrorCodes != null && row.SelectedErrorCodes.Count > 0) { rowData.ErrorCodes = new ServiceReference1.ICErrorCodeData[row.SelectedErrorCodes.Count]; int j = 0; ServiceReference1.ICErrorCodeData codeData; foreach (ICErrorCodeCls code in row.SelectedErrorCodes) { codeData = new ServiceReference1.ICErrorCodeData(); codeData.Code = code.Code; codeData.Id = code.Id; rowData.ErrorCodes[j] = codeData; j++; } } if (row.AddedPhotos != null && row.AddedPhotos.Count > 0) { rowData.ImageFiles = new ServiceReference1.ICOLogRowFileData[row.AddedPhotos.Count]; int h = 0; ServiceReference1.ICOLogRowFileData file; foreach (PhotoCls photo in row.AddedPhotos) { file = new ServiceReference1.ICOLogRowFileData(); file.FileName = photo.Name; file.FilePath = photo.Path; if (photo.Id != null) { file.Id = (int)photo.Id; } rowData.ImageFiles[h] = file; h++; } } } } string result = Dbcontext.UpdateOfficeInternalControlLog(Application.Current.Properties["UN"].ToString(), Application.Current.Properties["PW"].ToString(), Application.Current.Properties["Ucid"].ToString(), logData); await Application.Current.MainPage.DisplayAlert("Delspara", result, "Stäng"); await Application.Current.MainPage.Navigation.PopAsync(); } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Spara", e.Message, "Stäng"); } }