Ejemplo n.º 1
0
 public void Add(PartColumns col)
 {
     Parts.Add(col);
 }
        private bool ExtractProduct(Worksheet sheet)
        {
            SearchOptions options = new SearchOptions();

            options.MatchEntireCellContents = true;
            options.SearchIn = SearchIn.Values;

            // Find Cells in spreadsheet by 'Item Number'
            IEnumerable <Cell> productCells = sheet.Search("Item Number", options);

            if (productCells == null)
            {
                return(false);
            }

            // Find Cells in spreadsheet by 'PartName'
            IEnumerable <Cell> partCells = sheet.Search("PartName", options);

            if (partCells == null)
            {
                return(false);
            }

            int i = 0;

            foreach (Cell c1 in productCells)
            {
                ProductColumns productRec = new ProductColumns();
                // Read Item Number
                productRec.Code = sheet.Cells[c1.RowIndex, c1.ColumnIndex + 1].Value.ToString().Trim();
                // Read Product Description
                productRec.Name = sheet.Cells[c1.RowIndex + 1, c1.ColumnIndex + 1].Value.ToString().Trim();
                // Read Product Picture
                productRec.Image = new Bitmap(sheet.Pictures[i].Image.NativeImage,
                                              new Size(300, (int)(sheet.Pictures[i].Image.NativeImage.Height * (300.0 / sheet.Pictures[i].Image.NativeImage.Width))));

                int  j  = 1;
                Cell c2 = partCells.ElementAt <Cell>(i);

                while (j > 0)
                {
                    PartColumns partRec = new PartColumns();
                    // Read PartName
                    partRec.Name = sheet.Cells[c2.RowIndex + j, c2.ColumnIndex].Value.ToString().Trim();
                    // Read Materials
                    partRec.MaterialNo = sheet.Cells[c2.RowIndex + j, c2.ColumnIndex + 1].Value.ToString().Trim();
                    // Read Materiral Name
                    partRec.MaterialName = sheet.Cells[c2.RowIndex + j, c2.ColumnIndex + 2].Value.ToString().Trim();

                    if (string.IsNullOrWhiteSpace(partRec.Name) == false)
                    {
                        productRec.Add(partRec);
                        j++;
                    }
                    else
                    {
                        j = 0;
                    }
                }

                bomRec.Add(productRec);
                i++;
            }

            return(true);
        }
Ejemplo n.º 3
0
        private bool InsertPart(PartColumns col, SqlTransaction trans)
        {
            string jobNo       = "";
            string extendJobNo = "";

            cheQuery.ProfJobSet.Type       = EReportType.Chemical;
            cheQuery.ProfJobSet.JobNo      = "";
            cheQuery.ProfJobSet.AreaNo     = bomSet.AreaNo;
            cheQuery.ProfJobSet.ItemNo     = col.MaterialNo;
            cheQuery.ProfJobSet.ExtendASTM = true;
            cheQuery.ProfJobSet.Select(trans);

            int rowCount = cheQuery.ProfJobSet.RowCount;

            if (rowCount > 0)
            {
                cheQuery.ProfJobSet.Fetch(0);
                jobNo = cheQuery.ProfJobSet.JobNo;

                if (string.IsNullOrWhiteSpace(jobNo) == false)
                {
                    cheMainSet.RecNo          = jobNo;
                    cheMainSet.ReportApproval = EReportApproval.None;
                    cheMainSet.AreaNo         = EReportArea.None;
                    cheMainSet.From           = "";
                    cheMainSet.To             = "";
                    cheMainSet.MaterialNo     = "";
                    cheMainSet.Select(trans);

                    if (cheMainSet.Empty == true)
                    {
                        if (rowCount > 1)
                        {
                            // Find jobno for additional test results
                            for (int i = 1; i < cheQuery.ProfJobSet.RowCount; i++)
                            {
                                cheQuery.ProfJobSet.Fetch(i);

                                if (cheQuery.ProfJobSet.Image == null)
                                {
                                    extendJobNo = cheQuery.ProfJobSet.JobNo;
                                    break;
                                }
                            }

                            cheQuery.ProfJobSet.Fetch(0);
                        }

                        cheQuery.Insert(extendJobNo, trans);
                    }
                }
            }

            partSet.ProductNo    = productSet.RecNo;
            partSet.JobNo        = jobNo;
            partSet.MaterialNo   = col.MaterialNo;
            partSet.Name         = col.Name;
            partSet.MaterialName = col.MaterialName;
            partSet.Insert(trans);

            return((string.IsNullOrWhiteSpace(jobNo) == false) ? true : false);
        }