public void Delete(SqlTransaction trans = null) { if (local == true) { throw new Exception("Can't call ChemicalQuery.Delete() method in Local transaction mode!"); } string mainNo = MainSet.RecNo; trans = AppRes.DB.BeginTrans(); try { ImageSet.RecNo = mainNo; ImageSet.Delete(trans); JoinSet.RecNo = mainNo; JoinSet.Delete(trans); P2Set.MainNo = mainNo; P2Set.Delete(trans); P2ExtendSet.RecNo = mainNo; P2ExtendSet.Delete(trans); MainSet.Delete(trans); ResetReportValidation(trans); AppRes.DB.CommitTrans(); } catch { AppRes.DB.RollbackTrans(); } }
public void Delete() { if (local == true) { throw new Exception("Can't call PhysicalQuery.Delete() method in Local transaction mode!"); } string mainNo = MainSet.RecNo; SqlTransaction trans = AppRes.DB.BeginTrans(); try { P2Set.MainNo = mainNo; P2Set.Delete(trans); P3Set.MainNo = mainNo; P3Set.Delete(trans); P40Set.MainNo = mainNo; P40Set.Delete(trans); P41Set.MainNo = mainNo; P41Set.Delete(trans); P5Set.MainNo = mainNo; P5Set.Delete(trans); ImageSet.RecNo = mainNo; ImageSet.Delete(trans); MainSet.Delete(trans); productSet.JobNo = mainNo; productSet.UpdateJobNoReset(trans); AppRes.DB.CommitTrans(); } catch { AppRes.DB.RollbackTrans(); } }
private void SaveMain(EReportArea area, SqlTransaction trans) { if (area == EReportArea.US) { CtrlUs.SetControlToDataSet(); } else { CtrlEu.SetControlToDataSet(); } MainSet.Update(trans); }
private void InsertMain(EReportArea area, SqlTransaction trans) { MainSet.RecNo = ProfJobSet.JobNo; MainSet.RegTime = ProfJobSet.RegTime; MainSet.ReceivedTime = ProfJobSet.ReceivedTime; MainSet.RequiredTime = ProfJobSet.RequiredTime; MainSet.ReportedTime = ProfJobSet.ReportedTime; MainSet.Approval = false; MainSet.AreaNo = ProfJobSet.AreaNo; MainSet.StaffNo = ProfJobSet.StaffNo; MainSet.MaterialNo = ""; MainSet.P1ClientNo = ProfJobSet.ClientNo; MainSet.P1ClientName = ProfJobSet.ClientName; MainSet.P1ClientAddress = ProfJobSet.ClientAddress; MainSet.P1FileNo = ProfJobSet.FileNo; MainSet.P1SampleDescription = ProfJobSet.SampleRemark; MainSet.P1ItemNo = ProfJobSet.ItemNo; MainSet.P1OrderNo = "-"; MainSet.P1Manufacturer = ProfJobSet.Manufacturer; MainSet.P1CountryOfOrigin = ProfJobSet.CountryOfOrigin; MainSet.P1CountryOfDestination = "-"; MainSet.P1ReceivedDate = $"{ProfJobSet.ReceivedTime:yyyy. MM. dd}"; MainSet.P1TestPeriod = $"{ProfJobSet.ReceivedTime:yyyy. MM. dd} to {ProfJobSet.RequiredTime:yyyy. MM. dd}"; MainSet.P1TestMethod = "For further details, please refer to following page(s)"; MainSet.P1TestResults = "For further details, please refer to following page(s)"; MainSet.P1Comments = ProfJobSet.ReportComments; MainSet.P1Name = ""; if (string.IsNullOrWhiteSpace(MainSet.StaffNo) == true) { MainSet.Approval = false; } else { MainSet.Approval = true; } if (area == EReportArea.US) { MainSet.P1TestRequested = "Selected test(s) as requested by applicant for compliance with Public Law 110-314(Consumer Product Safety Improvement Act of 2008, CPSIA):-\r\n" + "- To determine Heavy Elements in the submitted samples with reference to ASTM F963-16\r\n" + " 4.3.5.2-Heavy Metal in Substrate Materials"; MainSet.P1Conclusion = "\r\n\r\n-\r\nPASS"; MainSet.P2Description1 = "ASTM F963-16, Clause 4.3.5.2 - Heavy Elements in Toys Substrate Materials"; MainSet.P2Description2 = "Method: With reference to ASTM F963-16 Clause 8.3. Analysis was performed by ICP-OES."; MainSet.P2Description3 = "1. Black textile\r\n\r\n" + "Note: - Soluble results shown are of the adjusted analytical result.\r\n" + " - ND = Not Detected(<MDL)"; MainSet.P2Description4 = "Method(non-metallic materials): CPSC-CH-E1002-08.3 - Standard Operation Procedure for Determining Total Lead(Pb) in Non-Metal Children Product. Analysis was performed by ICP-OES."; MainSet.P3Description1 = ""; } else { MainSet.P1TestRequested = "EN71-3:2013+A3:2018-Migration of certain elements\r\n" + "(By first action method testing only)"; MainSet.P1Conclusion = "PASS"; MainSet.P2Description1 = "EN71-3:2013+A3:2018 - Migration of certain elements"; MainSet.P2Description2 = "Method : With reference to EN71-3:2013+A3:2018. Analysis of general elements was performed by ICP-OES."; MainSet.P2Description3 = ProfJobSet.SampleDescription; MainSet.P2Description4 = ""; MainSet.P3Description1 = "Note. 1. mg/kg = milligram per kilogram\r\n" + " 2. ND = Not Detected(< MDL)\r\n" + " 3. 1% = 10000 mg/kg = 10000 ppm\r\n" + " 4. Soluble Chromium(III) = Soluble Total Chromium – Soluble Chromium(VI)\r\n" + " 5. ^ = Confirmation test of soluble organic tin is not required in case of soluble tin, after conversion, does not exceed the soluble organic tin requirement as specified in EN71-3:2019."; } MainSet.Insert(trans); }
protected void InitPage() { this.tablePage = new TablePage(); this.tablePage.CreateEditPanel.Content = this.CreateEditPage; try { MainSet.Load(); this.tablePage.tableGrid.ItemsSource = this.MainSet.Local.ToBindingList(); foreach (KeyValuePair <System.String, System.String> column in this.CreateEditPage.ColumnsNames) { this.tablePage.tableGrid.Columns.Add(new System.Windows.Controls.DataGridTextColumn() { Header = column.Value, Binding = new System.Windows.Data.Binding(column.Key) }); } } catch (Exception e) { System.Windows.MessageBox.Show(e.Message, "ERROR"); } this.tablePage.DelBut.Click += new System.Windows.RoutedEventHandler((object obj, System.Windows.RoutedEventArgs args) => { try { int sRow = -1; using (Entities context = new Entities()) { if (this.tablePage.tableGrid.SelectedItem != null) { sRow = this.tablePage.tableGrid.SelectedIndex; context.Set <T>().Remove(context.Set <T>().Single(this.CreateEditPage.GetSingleEntity)); } context.SaveChanges(); } if (this.tablePage.tableGrid.SelectedItem != null) { this.Context.Set <T>().Local.Remove((T)this.tablePage.tableGrid.SelectedItem); } this.tablePage.tableGrid.Items.Refresh(); if (sRow != -1 && this.tablePage.tableGrid.Items.Count > 0) { this.tablePage.tableGrid.SelectedIndex = sRow <= this.tablePage.tableGrid.Items.Count - 1 ? sRow : this.tablePage.tableGrid.Items.Count - 1; } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message, "Unfortunately, there is impossible to delete the record."); } }); this.tablePage.tableGrid.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler((object obj, System.Windows.Controls.SelectionChangedEventArgs args) => { try { T entity = (T)this.tablePage.tableGrid.SelectedItem; if (entity == null) { this.tablePage.OkBut.IsEnabled = false; this.CreateEditPage.CleanFields(); return; } else { this.CreateEditPage.AssingFields(entity); this.tablePage.OkBut.IsEnabled = this.CreateEditPage.FieldsNotEmpty; } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message, "Unfortunately, there is impossible to select the record."); } }); this.CreateEditPage.FieldsHasBeenChanged += new FieldsChanged(() => { this.tablePage.OkBut.IsEnabled = (this.tablePage.tableGrid.SelectedItem != null) && this.CreateEditPage.FieldsNotEmpty; this.tablePage.CompleteCreateBut.IsEnabled = this.CreateEditPage.FieldsNotEmpty; }); this.tablePage.OkBut.Click += new System.Windows.RoutedEventHandler((object obj, System.Windows.RoutedEventArgs args) => { try { try { this.CreateEditPage.StartingEditingEvent?.Invoke(); } catch (NotImplementedException) { } finally { Entities context = new Entities(); T inEditEntity = context.Set <T>().Single(this.CreateEditPage.GetSingleEntity); this.CreateEditPage.AssignEntity(ref context, ref inEditEntity); context.Entry <T>(inEditEntity).State = EntityState.Modified; context.SaveChanges(); context.Dispose(); //this.MainSet.Load(); this.Context.Entry <T>(this.MainSet.Single(this.CreateEditPage.GetSingleEntity)).Reload(); this.tablePage.tableGrid.Items.Refresh(); } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message, "Unfortunately, there is impossible to edit the record."); } }); Action Save = new Action(() => { try { if (this.CreateEditPage.FieldsNotEmpty) { try { this.CreateEditPage.StartingCreateingEntity?.Invoke(); } catch (NotImplementedException) { } finally { T newToAdd = null; { Entities context = new Entities(); T toCreate = this.CreateEditPage.CreateEntity(); this.CreateEditPage.AssingNewId(ref toCreate, -1); this.CreateEditPage.AssignEntity(ref context, ref toCreate); int newId = this.MainSet.Count() > 0 ? (this.MainSet.Max(this.CreateEditPage.GetId) + 1) : 1; this.CreateEditPage.AssingNewId(ref toCreate, newId); context.Set <T>().Add(toCreate); context.SaveChanges(); /*T entry = context.Set<T>().Find(context.Entry<T>(toCreate).Property(this.CreateEditPage.GetId).CurrentValue); * context.Entry<T>(entry).State = EntityState.Detached;*/ context.Dispose(); newToAdd = this.MainSet.SingleOrDefault(this.CreateEditPage.GetById(newId)); this.MainSet.Local.Add(newToAdd); //this.MainSet.Load(); /*((App)System.Windows.Application.Current).Dispatcher.BeginInvoke(new Action(() => * { * if (this.MainSet.Select(this.CreateEditPage.GetId).Contains(newId) && !this.MainSet.Local.AsQueryable().Select(this.CreateEditPage.GetId).Contains(newId)) * { * IQueryable<T> queryable = this.MainSet.AsQueryable(); * this.MainSet.Local.Add(queryable.Where(p => queryable.Where(x => x == p).Select(this.CreateEditPage.GetId).Contains(newId)).FirstOrDefault()); * } * }), System.Windows.Threading.DispatcherPriority.Normal);*/ } this.tablePage.tableGrid.Items.Refresh(); this.tablePage.tableGrid.SelectedItem = newToAdd; } } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message + "\n" + ex.InnerException?.Message, "Unfortunately, there is impossible to create the record."); } }); this.tablePage.CompleteCreateBut.Click += new System.Windows.RoutedEventHandler((object obj, System.Windows.RoutedEventArgs args) => Save()); this.tablePage.ImportBut.Click += new RoutedEventHandler((object sender, RoutedEventArgs args) => { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.Filter = "Excel books (*.xls, *.xlsx) | *.xls; *.xlsx"; dialog.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); dialog.RestoreDirectory = true; if ((dialog.ShowDialog() ?? false) == true) { Excel.Application excel = (Excel.Application)Microsoft.VisualBasic.Interaction.CreateObject("Excel.Application"); if (excel != null) { Excel.Workbook workbook = null; workbook = excel.Workbooks.Open(dialog.FileName, Type.Missing, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); Excel.Worksheet worksheet = (Excel.Worksheet)excel.ActiveSheet; Excel.Range usedRange = worksheet.UsedRange; foreach (int i in Enumerable.Range(1, usedRange.Rows.Count)) { System.String[] values = new System.String[worksheet.UsedRange.Columns.Count]; foreach (int o in Enumerable.Range(1, usedRange.Columns.Count)) { values[o - 1] = (usedRange.Cells[i, o] as Excel.Range).Value2 as System.String; } this.CreateEditPage.AssingFields(this.CreateEditPage.AssignEntityFromFileCols(values)); Save(); } workbook.Close(false); System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook); System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(usedRange); ((App)System.Windows.Application.Current).KillExcel(ref excel); } else { MessageBox.Show("На жаль не можливо здійснити імпорт даних, в зв\'язку з відсутністю належної версії Miscrosoft Excel"); } } }); this.CreateEditPage.ContentPage = this.tablePage; }
private void InsertMain(EReportArea area, SqlTransaction trans) { MainSet.RecNo = ProfJobSet.JobNo; MainSet.RegTime = ProfJobSet.RegTime; MainSet.ReceivedTime = ProfJobSet.ReceivedTime; MainSet.RequiredTime = ProfJobSet.RequiredTime; MainSet.ReportedTime = ProfJobSet.ReportedTime; MainSet.Approval = false; MainSet.AreaNo = ProfJobSet.AreaNo; MainSet.StaffNo = ProfJobSet.StaffNo; MainSet.ProductNo = ProfJobSet.ItemNo; MainSet.P1ClientNo = ProfJobSet.ClientNo; MainSet.P1ClientName = ProfJobSet.ClientName; MainSet.P1ClientAddress = ProfJobSet.ClientAddress; MainSet.P1FileNo = ProfJobSet.FileNo; MainSet.P1SampleDescription = ProfJobSet.SampleRemark; MainSet.P1DetailOfSample = ProfJobSet.DetailOfSample; MainSet.P1ItemNo = ProfJobSet.ItemNo; MainSet.P1OrderNo = "-"; MainSet.P1Packaging = "Yes, provided"; MainSet.P1Instruction = "Not provided"; MainSet.P1Buyer = "-"; MainSet.P1Manufacturer = ProfJobSet.Manufacturer; MainSet.P1CountryOfOrigin = ProfJobSet.CountryOfOrigin; MainSet.P1CountryOfDestination = "-"; MainSet.P1LabeledAge = "None"; MainSet.P1TestAge = "None"; MainSet.P1AssessedAge = "All ages"; MainSet.P1ReceivedDate = ProfJobSet.ReceivedTime.ToString("yyyy. MM. dd"); MainSet.P1TestPeriod = $"{ProfJobSet.ReceivedTime.ToString("yyyy. MM. dd")} to {ProfJobSet.RequiredTime.ToString("yyyy. MM. dd")}"; MainSet.P1TestMethod = "For further details, please refer to following page(s)"; MainSet.P1TestResults = "For further details, please refer to following page(s)"; MainSet.P1Comments = ProfJobSet.ReportComments; MainSet.Approval = false; MainSet.P2Name = ""; if (string.IsNullOrWhiteSpace(MainSet.StaffNo) == true) { MainSet.Approval = false; } else { MainSet.Approval = true; } if (area == EReportArea.US) { MainSet.P3Description1 = "As specified in ASTM F963-17 standard consumer safety specification on toys safety."; MainSet.P3Description2 = "N/A = Not Applicable **Visual Examination\r\n" + "NT = Not tested as per client's request.\r\n\r\n" + "N.B. : - Only applicable clauses were shown"; MainSet.P4Description1 = "Flammability Test(Clause 4.2)"; MainSet.P4Description2 = "*Burning rate has been rounded to the nearest one tenth of an inch per second.\r\n\r\n" + "Requirement: A toy / component is considered a \"flammable solid\" if it ignites and burns with a self-sustaining\r\n" + " flame at a rate greater than 0.1 in./s along its major axis."; MainSet.P4Description3 = ""; MainSet.P5Description1 = "Suffing Materials(Clause 4.3.7)\r\n\r\n" + "Method: With reference to ASTM F963-17 Clause 8.29. Visual inspection is performed using a stereo widerfield\r\n" + "microscope, or equivalent, at 10 x magnification and adequate illumination."; MainSet.P5Description2 = "Polyester fiber"; } else { MainSet.P3Description1 = "European Standard on Safety of Toys\r\n" + "- Mechanical & Physical Properties\r\n" + "As specified in European standard on safety of toys EN 71 Part 1:2014+A1:2018"; MainSet.P3Description2 = ""; MainSet.P4Description1 = "- Flammability of Toys\r\n" + "As specified in European standard on safety of toys EN71 PART 2: 2011+A1:2014"; MainSet.P4Description2 = "* Surface Flash of Pile Fabrics (Clause 4.1)"; MainSet.P4Description3 = "NSFO = No surface flash occurred\r\n" + "DNI = Did not ignite\r\n" + "IBE = Ignite But Self-Extinguished\r\n" + "N / A = Not applicable since the requirements of this sub - clause do not apply to toys with a greatest dimension of 150mm or less\r\n" + "SE = Self - Extinguishing\r\n\r\n\r\n" + "N.B. : Only applicable clauses were shown."; MainSet.P5Description1 = "Labeling requirement (Washing/Cleaning Label, CE mark, importer / manufacturer mark (name, address), product identification) according to the Directive 2009/48/EC - Safety of toys"; MainSet.P5Description2 = "1. According to Directive 2009/48/EC, a toy intended for use by children under 36 months must be designed and\r\n" + " manufactured in such a way that it can be cleaned. A textile toy must, to this end, be washable, except if it\r\n" + " contains a mechanism that may be damaged if soak washed. The manufacturer should, if applicable, provide\r\n" + " instructions on how the toy has to be cleaned.\r\n\r\n" + "2. CE marking should be visible from outside the packaging and its height must be at least 5 mm.\r\n\r\n" + "3. Manufacturer's and Importer's name, registered trade name or registered trade mark and the address at which\r\n" + " the manufacturer can be contacted must be indicated on the toy or, where that is not possible, on its packaging\r\n" + " or in a document accompanying the toy.\r\n\r\n" + "4. Manufacturers must ensure that their toys bear a type, batch, serial or model number or other element allowing\r\n" + " their identification, or where the size or nature of the toy does not allow it, that the required information is\r\n" + " provided on the packaging or in a document accompanying the toy."; } MainSet.Insert(trans); }