Example #1
0
        private void InsertProduct(ProductColumns col, SqlTransaction trans)
        {
            phyQuery.ProfJobSet.Type       = EReportType.Physical;
            phyQuery.ProfJobSet.JobNo      = "";
            phyQuery.ProfJobSet.AreaNo     = bomSet.AreaNo;
            phyQuery.ProfJobSet.ItemNo     = col.Code;
            phyQuery.ProfJobSet.ExtendASTM = false;
            phyQuery.ProfJobSet.Select(trans);
            phyQuery.ProfJobSet.Fetch();
            string jobNo = phyQuery.ProfJobSet.JobNo;

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

                if (phyMainSet.Empty == true)
                {
                    phyQuery.Insert(trans);
                }
            }

            productSet.BomNo  = bomSet.RecNo;
            productSet.Valid  = false;
            productSet.AreaNo = bomSet.AreaNo;
            productSet.Code   = col.Code;
            productSet.JobNo  = jobNo;
            productSet.Name   = col.Name;
            productSet.Image  = col.Image;
            productSet.Insert(trans);
        }
        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);
        }
 public void Add(ProductColumns col)
 {
     Products.Add(col);
 }