コード例 #1
0
        private async Task Get_Remarks_Doc()
        {
            ComboBoxItem    item;
            SolidColorBrush background;

            using (var db = new DigitalDatasheetContext())
            {
                var remarksDocument = await Task.Run(() => db.RemarksDocument.OrderBy(r => r.ID));

                var sectionTitles = remarksDocument.Select(r => new { r.SectionTitle }).Distinct();
                foreach (var section in sectionTitles)
                {
                    item = new ComboBoxItem()
                    {
                        Content    = section.SectionTitle.ToUpper(),
                        FontWeight = FontWeights.SemiBold,
                        FontSize   = 15,
                        Padding    = new Thickness(4),
                        IsEnabled  = false,
                        MaxWidth   = 1000
                    };
                    remark_selection.Items.Add(item);
                    int row = 0;
                    foreach (var remark in remarksDocument)
                    {
                        //if (string.IsNullOrEmpty(remark.Remark))
                        if (remark.Remark == remark.SectionTitle)
                        {
                            continue;
                        }
                        if (remark.SectionTitle == section.SectionTitle)
                        {
                            if (row++ % 2 == 0)
                            {
                                background = new SolidColorBrush(Color.FromRgb(240, 240, 240));
                            }
                            else
                            {
                                background = new SolidColorBrush(Colors.Transparent);
                            }

                            item = new ComboBoxItem()
                            {
                                Content    = remark.Remark,
                                Background = background,
                                MaxWidth   = 1000
                            };
                            remark_selection.Items.Add(item);
                        }
                    }
                    remark_selection.Items.Add(new Separator());
                }
            }
        }
コード例 #2
0
        private async Task Get_Specifications()
        {
            using (var db = new DigitalDatasheetContext())
            {
                var specifications = await Task.Run(() => db.SpecificationRequirementsTable.OrderBy(s => s.Specification).Select(s => new { s.Specification }));

                foreach (var spec in specifications)
                {
                    specificationSelectInput.Items.Add(spec.Specification);
                }
            }
        }
コード例 #3
0
        private async void Update_Click(object sender, RoutedEventArgs e)
        {
            if (!SpecificationSelected)
            {
                return;
            }
            //if (Specification != NewSpecification)
            //{
            //    if (MessageBox.Show($"The name of the specification will be changed from {Specification} to {NewSpecification}, along with the updated requirements (if any). Would you like to continue?", "Specification Name Change", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            //        return;
            //    MessageBox.Show($"The Specification you are trying to add already exists. Select \"Update\" to change requirements for {NewSpecification} otherwise change the name of the new specification you want to add", "Specification Already Exists", MessageBoxButton.OK, MessageBoxImage.Error);
            //    return;
            //}
            using (var db = new DigitalDatasheetContext())
            {
                DigitalDatasheetEntityLib.SpecificationRequirements specificationRequirements = await Task.Run(() => db.SpecificationRequirementsTable.Find(Specification));

                //specificationRequirements.Specification = NewSpecification;
                specificationRequirements.HoleCuPlating       = SpecificationRequirements.HoleCuPlating;
                specificationRequirements.WrapCu              = SpecificationRequirements.WrapCu;
                specificationRequirements.CapCu               = SpecificationRequirements.CapCu;
                specificationRequirements.MinEtchback         = SpecificationRequirements.MinEtchback;
                specificationRequirements.MaxEtchback         = SpecificationRequirements.MaxEtchback;
                specificationRequirements.InternalAnnularRing = SpecificationRequirements.InternalAnnularRing;
                specificationRequirements.ExternalAnnularRing = SpecificationRequirements.ExternalAnnularRing;
                specificationRequirements.Dielectric          = SpecificationRequirements.Dielectric;
                specificationRequirements.Wicking             = SpecificationRequirements.Wicking;
                specificationRequirements.WickingNote         = SpecificationRequirements.WickingNote;
                int affected = await Task.Run(() => db.SaveChangesAsync().Result);

                if (affected == 1)
                {
                    Specification             = string.Empty;
                    NewSpecification          = string.Empty;
                    SpecificationRequirements = new SpecificationRequirements();
                    SpecificationSelected     = false;
                    MessageBox.Show("Specification successfully updated.", "Specification Updated!", MessageBoxButton.OK, MessageBoxImage.Information);
                    //ResetSpecifications = true;
                    //specificationSelectInput.Items.Clear();
                    //await Get_Specifications();
                }
                else
                {
                    MessageBox.Show($"The specification was unable to be added. Please close and try again.", "Specification Add Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
        }
コード例 #4
0
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     UpdatedSectionTitle = sectionTitleInput.Text;
     UpdatedRemark       = remarkEditInput.Text;
     if (string.IsNullOrEmpty(UpdatedSectionTitle) || string.IsNullOrEmpty(UpdatedRemark))
     {
         MessageBox.Show("Section title and remark fields must both be filled. Please correct this issue and try again.", "Remark Add Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     using (var db = new DigitalDatasheetContext())
     {
         DocumentRemark newRemark = new DocumentRemark()
         {
         };
     }
 }
コード例 #5
0
        private void Select_Click(object sender, RoutedEventArgs e)
        {
            if (remarkSelectionInput.SelectedIndex < 0)
            {
                MessageBox.Show("No remark has been selected for editing. Please choose a remark before clicking \"Select\"", "No Remark Selected", MessageBoxButton.OK, MessageBoxImage.Error);
                remarkEditInput.Text = string.Empty;
                sectionTitleInput.Items.Clear();
                return;
            }
            SelectedRemark = remarkSelectionInput.Text;
            //if (!int.TryParse(remarkSelection.Substring(0, remarkSelection.IndexOf('.')), out remarkID))
            //{
            //    MessageBox.Show("Error in selecting remark to edit. Please close and try again.", "Remark Selection Error", MessageBoxButton.OK, MessageBoxImage.Error);
            //    return;
            //}

            using (var db = new DigitalDatasheetContext())
            {
                RemarkID = db.RemarksDocument.Where(r => r.Remark == SelectedRemark).First().ID;
                // populate section titles
                ComboBoxItem  item;
                List <string> sectionTitles = db.RemarksDocument.Where(r => !string.IsNullOrEmpty(r.Remark)).OrderBy(r => r.ID).Select(r => r.SectionTitle).Distinct().ToList();
                foreach (string section in sectionTitles)
                {
                    item = new ComboBoxItem()
                    {
                        Content    = section.ToUpper(),
                        FontWeight = FontWeights.SemiBold,
                        FontSize   = 15,
                        Padding    = new Thickness(4),
                        MaxWidth   = 1000
                    };
                    sectionTitleInput.Items.Add(item);
                }

                var remark = db.RemarksDocument.Find(RemarkID);
                SelectedSectionTitle   = remark.SectionTitle;
                sectionTitleInput.Text = SelectedSectionTitle.ToUpper();
                //SelectedRemark = remark.Remark;
            }

            //SelectedRemark = remarkSelection.Substring(remarkSelection.IndexOf('.') + 2);
            remarkEditInput.Text = SelectedRemark;
            remarkSelectionInput.SelectedIndex = -1;
            //MessageBox.Show($"{RemarkID}");
        }
コード例 #6
0
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new DigitalDatasheetContext())
            {
                DigitalDatasheetEntityLib.SpecificationRequirements specCheck = await Task.Run(() => db.SpecificationRequirementsTable.Find(Specification));

                if (specCheck != null)
                {
                    MessageBox.Show($"The Specification you are trying to add already exists. Select \"Update\" to change requirements for {NewSpecification} otherwise change the name of the new specification you want to add", "Specification Already Exists", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                DigitalDatasheetEntityLib.SpecificationRequirements specificationRequirements = new DigitalDatasheetEntityLib.SpecificationRequirements
                {
                    Specification       = NewSpecification,
                    HoleCuPlating       = SpecificationRequirements.HoleCuPlating,
                    WrapCu              = SpecificationRequirements.WrapCu,
                    CapCu               = SpecificationRequirements.CapCu,
                    MinEtchback         = SpecificationRequirements.MinEtchback,
                    MaxEtchback         = SpecificationRequirements.MaxEtchback,
                    InternalAnnularRing = SpecificationRequirements.InternalAnnularRing,
                    ExternalAnnularRing = SpecificationRequirements.ExternalAnnularRing,
                    Dielectric          = SpecificationRequirements.Dielectric,
                    Wicking             = SpecificationRequirements.Wicking,
                    WickingNote         = SpecificationRequirements.WickingNote
                };
                await db.SpecificationRequirementsTable.AddAsync(specificationRequirements);

                int affected = await Task.Run(() => db.SaveChangesAsync().Result);

                if (affected == 1)
                {
                    Specification             = string.Empty;
                    NewSpecification          = string.Empty;
                    SpecificationRequirements = new SpecificationRequirements();
                    MessageBox.Show("Specification successfully added.", "Specification Added!", MessageBoxButton.OK, MessageBoxImage.Information);
                    ResetSpecifications = true;
                    specificationSelectInput.Items.Clear();
                    await Get_Specifications();
                }
                else
                {
                    MessageBox.Show($"The specification was unable to be added. Please close and try again.", "Specification Add Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
        }
コード例 #7
0
        private async void Select_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(Specification))
            {
                MessageBox.Show($"Specification must be selected to view requirements.", "No Specification Selected", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                Specification             = string.Empty;
                NewSpecification          = string.Empty;
                SpecificationRequirements = new SpecificationRequirements();
                SpecificationSelected     = false;
                return;
            }
            using (var db = new DigitalDatasheetContext())
            {
                var specRequirements = await Task.Run(() => db.SpecificationRequirementsTable.Find(Specification));

                if (specRequirements == null)
                {
                    MessageBox.Show($"{Specification} specification not found. Only specifications selected from dropdown list can be used to view requirements.", "Specification Not Found", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    Specification             = string.Empty;
                    NewSpecification          = string.Empty;
                    SpecificationRequirements = new SpecificationRequirements();
                    SpecificationSelected     = false;
                }
                else
                {
                    NewSpecification = Specification;
                    SpecificationRequirements.HoleCuPlating       = specRequirements.HoleCuPlating;
                    SpecificationRequirements.WrapCu              = specRequirements.WrapCu;
                    SpecificationRequirements.CapCu               = specRequirements.CapCu;
                    SpecificationRequirements.MinEtchback         = specRequirements.MinEtchback;
                    SpecificationRequirements.MaxEtchback         = specRequirements.MaxEtchback;
                    SpecificationRequirements.InternalAnnularRing = specRequirements.InternalAnnularRing;
                    SpecificationRequirements.ExternalAnnularRing = specRequirements.ExternalAnnularRing;
                    SpecificationRequirements.Dielectric          = specRequirements.Dielectric;
                    SpecificationRequirements.Wicking             = specRequirements.Wicking;
                    SpecificationRequirements.WickingNote         = specRequirements.WickingNote;

                    SpecificationSelected = true;
                }
            }
        }
コード例 #8
0
 private void CheckJobForm()
 {
     using (var db = new DigitalDatasheetContext())
     {
         JobForm jobForm = db.JobForms.Find(OpenJobData.FullWorkOrder, OpenJobData.TestCondition, OpenJobData.TestPerformedOn);
         if (jobForm == null)
         {
             WoCheck = false;
             wo_check_icon.Source = new BitmapImage(new Uri("../Images/error_icon.png", UriKind.Relative));
         }
         else
         {
             WoCheck = true;
             wo_check_icon.Source = new BitmapImage(new Uri("../Images/success_icon.png", UriKind.Relative));
         }
     }
     if (wo_check_icon.Visibility == Visibility.Hidden)
     {
         wo_check_icon.Visibility = Visibility.Visible;
     }
 }
コード例 #9
0
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            UpdatedRemark = remarkEditInput.Text;
            if (UpdatedRemark == SelectedRemark)
            {
                MessageBox.Show("No update to the remark has been made. Please edit the remark before saving.", "No Update Made", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            int updated = 0;

            using (var db = new DigitalDatasheetContext())
            {
                var remark = db.RemarksDocument.Find(RemarkID);
                remark.Remark = UpdatedRemark;
                updated       = db.SaveChangesAsync().Result;
            }
            if (updated == 1)
            {
                MessageBox.Show("Remark updated.");
                SelectedRemark = UpdatedRemark;
                remarkSelectionInput.Items.Clear();
                _ = Get_Remarks_Doc();
            }
        }
コード例 #10
0
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            if (!SpecificationSelected)
            {
                return;
            }
            if (MessageBox.Show($"You are about to remove specification {Specification} from this list. Would you like to continue?", "Specification Removal", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }
            using (var db = new DigitalDatasheetContext())
            {
                DigitalDatasheetEntityLib.SpecificationRequirements specificationRequirements = await Task.Run(() => db.SpecificationRequirementsTable.Find(Specification));

                db.SpecificationRequirementsTable.Remove(specificationRequirements);
                int affected = await Task.Run(() => db.SaveChangesAsync().Result);

                if (affected == 1)
                {
                    specificationSelectInput.Items.Remove(specificationSelectInput.SelectedItem);
                    Specification             = string.Empty;
                    NewSpecification          = string.Empty;
                    SpecificationRequirements = new SpecificationRequirements();
                    SpecificationSelected     = false;
                    MessageBox.Show("Specification successfully removed.", "Specification Removed!", MessageBoxButton.OK, MessageBoxImage.Information);
                    ResetSpecifications = true;
                    //specificationSelectInput.Items.Clear();
                    //await Get_Specifications();
                }
                else
                {
                    MessageBox.Show($"The specification was unable to be removed. Please close and try again.", "Specification Removal Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
        }
コード例 #11
0
        public async Task SetData()
        {
            try
            {
                await using (var db = new DigitalDatasheetContext())
                {
                    // check locations for multiple coupon set condition
                    var locations = db.JobDataTable
                                    .Where(data => data.WorkOrderNumber.Equals(WorkOrderNumber) && data.TestCondition.Equals(TestCondition) && data.TestPerformedOn.Equals(TestPerformedOn))
                                    .Select(r => r.Location)
                                    .Distinct();
                    if (locations.Count() > 1)
                    {
                        WordApp.Selection.Find.Execute("<cpn set>", true, true, false, false, false, true, 1, false, "Multiple Coupon Set", 2, false, false, false, false);
                    }
                    else
                    {
                        WordApp.Selection.Find.Execute("<cpn set>", true, true, false, false, false, true, 1, false, "", 2, false, false, false, false);
                    }

                    var records = await db.JobDataTable
                                  .Where(data => data.WorkOrderNumber.Equals(WorkOrderNumber) && data.TestCondition.Equals(TestCondition) && data.TestPerformedOn.Equals(TestPerformedOn))
                                  .OrderBy(data => data.StructureOrder)
                                  .ThenBy(data => data.Row)
                                  .ToListAsync();

                    var dataTable = WordDoc.Tables[2];
                    // create inital set table based on number of structures there are
                    // base table will have one row for each structure and below each structure, one row for measurements

                    var structureList = records
                                        .OrderBy(r => r.StructureOrder)
                                        .Select(r => new { r.StructureTitle })
                                        .Distinct()
                                        .ToList();

                    for (int i = 1; i < structureList.Count; i++)
                    {
                        dataTable.Rows.Add(dataTable.Rows[dataTable.Rows.Count]);
                        dataTable.Rows.Add(dataTable.Rows[dataTable.Rows.Count]);
                        dataTable.Cell(dataTable.Rows.Count - 1, 1).Merge(dataTable.Cell(dataTable.Rows.Count - 1, 20));
                    }
                    //data_table.Cell(1, 1).Range.Text = structure_list[0];

                    // set row for structure titles to same format (center vertical and horizontal alignment and font)
                    for (int i = 3; i < dataTable.Rows.Count; i += 2)
                    {
                        dataTable.Cell(i, 1).Range.Font        = dataTable.Cell(1, 1).Range.Font;
                        dataTable.Cell(i, 1).VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                    }

                    int endRow = dataTable.Rows.Count;
                    // loop through each structure starting from the end
                    for (int i = structureList.Count - 1; i >= 0; i--)
                    {
                        var recordSet = records
                                        .Where(r => r.StructureTitle == structureList[i].StructureTitle)
                                        .OrderBy(r => r.Row)
                                        .ToList();
                        // set last structure title row to correct structure
                        dataTable.Cell(endRow - 1, 1).Range.Text = structureList[i].StructureTitle;
                        // loop through each location/serial number combo for each structure starting from the end
                        for (int j = recordSet.Count - 1; j >= 0; j--)
                        {
                            // if serial number has associated location add location and set font color to red
                            if (string.IsNullOrEmpty(recordSet[j].Location))
                            {
                                // set first column of row to serial number
                                dataTable.Cell(endRow, 1).Range.Text       = recordSet[j].SerialNumber;
                                dataTable.Cell(endRow, 1).Range.Font.Color = Word.WdColor.wdColorBlack;
                                dataTable.Cell(endRow, 1).Shading.BackgroundPatternColor = Word.WdColor.wdColorWhite;
                            }
                            else
                            {
                                // set first column of row to location/serial number
                                dataTable.Cell(endRow, 1).Range.Text       = $"loc {recordSet[j].Location}\n{recordSet[j].SerialNumber}";
                                dataTable.Cell(endRow, 1).Range.Font.Color = Word.WdColor.wdColorBlack;
                                dataTable.Cell(endRow, 1).Shading.BackgroundPatternColor = Word.WdColor.wdColorWhite;
                                // set location font color to red
                                int wordCount = dataTable.Cell(endRow, 1).Range.Words.Count;
                                for (int k = 1; k < wordCount; k++)
                                {
                                    Word.Range word = dataTable.Cell(endRow, 1).Range.Words[k];
                                    if (word.Text.StartsWith("loc"))
                                    {
                                        while (dataTable.Cell(endRow, 1).Range.Words[k].Text != "\r" && k != wordCount)
                                        {
                                            dataTable.Cell(endRow, 1).Range.Words[k++].Font.Color = Word.WdColor.wdColorRed;
                                        }
                                    }
                                }
                            }

                            // set remaining columns of row to measurements and observations
                            List <string> dataRow = new List <string>
                            {
                                recordSet[j].HoleCuPlating,
                                recordSet[j].ExternalConductor,
                                recordSet[j].SurfaceCladCu,
                                recordSet[j].WrapCu,
                                recordSet[j].CapCu,
                                recordSet[j].InternalCladCu,
                                recordSet[j].MinEtchback,
                                recordSet[j].MaxEtchback,
                                recordSet[j].InternalAnnularRing,
                                recordSet[j].ExternalAnnularRing,
                                recordSet[j].Dielectric,
                                recordSet[j].Wicking,
                                recordSet[j].InnerlayerSeparation,
                                recordSet[j].PlatingCrack,
                                recordSet[j].PlatingVoid,
                                recordSet[j].DelamBlisters,
                                recordSet[j].LaminateVoidCrack,
                                recordSet[j].AcceptReject
                            };
                            // loop through data row setting columns to each value
                            int column = 2;
                            foreach (string data in dataRow)
                            {
                                if (string.IsNullOrEmpty(data))
                                {
                                    column++;
                                    continue;
                                }
                                if (column == 19)
                                {
                                    column++;
                                }
                                // check if measurement starts with an R (if it does, set the cell background color to yellow and remove the R)
                                if (column <= 13)
                                {
                                    string newData = data;

                                    if (data.StartsWith("R"))
                                    {
                                        if (data.Contains("^"))
                                        {
                                            string[] splitData = data.Split('^');
                                            newData = $"{splitData[1]}\n{splitData[0]}";
                                        }
                                        newData = newData.Remove(newData.IndexOf('R'), 1);
                                        dataTable.Cell(endRow, column).Range.Text = newData;
                                        dataTable.Cell(endRow, column).Shading.BackgroundPatternColor = Word.WdColor.wdColorYellow;
                                        dataTable.Cell(endRow, 1).Shading.BackgroundPatternColor      = Word.WdColor.wdColorYellow;
                                    }
                                    else if (data.Contains("^"))
                                    {
                                        string[] splitData = data.Split('^');
                                        newData = $"{splitData[1]}\n{splitData[0]}";

                                        dataTable.Cell(endRow, column).Range.Text = $"{newData}";
                                        dataTable.Cell(endRow, column).Shading.BackgroundPatternColor = Word.WdColor.wdColorWhite;
                                    }
                                    else
                                    {
                                        dataTable.Cell(endRow, column).Range.Text = data;
                                        if (data == "N/A")
                                        {
                                            dataTable.Cell(endRow, column).Shading.BackgroundPatternColor = Word.WdColor.wdColorGray10;
                                        }
                                        else
                                        {
                                            dataTable.Cell(endRow, column).Shading.BackgroundPatternColor = Word.WdColor.wdColorWhite;
                                        }
                                    }
                                }
                                else
                                {
                                    dataTable.Cell(endRow, column).Range.Text = data;
                                    if (data == "R")
                                    {
                                        dataTable.Cell(endRow, column).Shading.BackgroundPatternColor = Word.WdColor.wdColorYellow;
                                        dataTable.Cell(endRow, 1).Shading.BackgroundPatternColor      = Word.WdColor.wdColorYellow;
                                    }
                                    else
                                    {
                                        dataTable.Cell(endRow, column).Shading.BackgroundPatternColor = Word.WdColor.wdColorWhite;
                                    }
                                }
                                column++;
                            }

                            // if this is the final row of the data list, do not add new row to word document
                            if (j != 0)
                            {
                                dataTable.Rows.Add(dataTable.Rows[endRow]);
                            }
                        }
                        endRow -= 2;
                    }
                }
            }
            catch (Exception err)
            {
                sw = new StreamWriter(ErrorLogFilePath, true);
                sw.WriteLine($"{DateTime.Now.ToShortTimeString()}\nHardCopy Set_Data -- {err.Source}; {err.TargetSite}\n{err.Message}\n");
                sw.Close();

                if (WordDoc != null)
                {
                    WordDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges, Word.WdOriginalFormat.wdOriginalDocumentFormat, false);
                }
                if (WordApp != null)
                {
                    WordApp.Quit();
                }
                throw;
            }
        }