// 从excel获取多肽对象
        private NnPolypeptide getPolypeptideFromExcel(int row)
        {
            string        oId         = m_range.Cells[row, orderId].Text;
            string        seq         = m_range.Cells[row, sequence].Text;
            NnPolypeptide polypeptide = new NnPolypeptide(oId, seq);

            polypeptide.PurityString  = m_range.Cells[row, purity].Text;
            polypeptide.QualityString = m_range.Cells[row, quality].Text;
            polypeptide.MwObj         = m_range.Cells[row, mw].Value;
            polypeptide.Modification  = m_range.Cells[row, modification].Text;
            polypeptide.WorkNoObj     = m_range.Cells[row, workNo].Value;
            polypeptide.Comments      = m_range.Cells[row, comments].Text;
            return(polypeptide);
        }
        private void _start()
        {
            int count = 0;

            m_range = excelReader[1].UsedRange;
            m_range.Columns[_info, Type.Missing].Clear();

            int rows = m_range.Rows.Count;

            for (int i = 2; i <= rows; ++i)
            {
                if (!isContinue)
                {
                    return;                               // 如果用户取消查找库存,就结束
                }
                SearchProgress.progress((float)i / rows); // 通知搜索进度

                try
                {
                    // 包含在try catch里避免一条订单出错影响其他订单的查找
                    NnPolypeptide newPolypeptide = getPolypeptideFromExcel(i); // 得到excel中数据
                    if (newPolypeptide.IsAvailable)                            // 如果从excel读取的数据有效,则查找库存,存入数据库
                    {
                        ++scount;
                        // 将数据上传到数据库,这个函数有自己的异常处理,错误不会影响后面的执行
                        NnReader.Instance.InsertHistory(newPolypeptide);
                        if (_search(newPolypeptide, i))// 开始搜索数据并写入excel
                        {
                            ++count;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine($"第 {i} 行出错!");
                    Console.ResetColor();
                    Console.WriteLine(e.ToString());
                }
                //Console.WriteLine(m_range.Cells[i, 1].Value.GetType().Name+"\n"+ ((DateTime)m_range.Cells[i, 1].Value).ToShortDateString());
            }
            try
            {
                m_range.Cells[1, _info] = $"库存信息: {count}";
            }
            catch (Exception e) { Console.WriteLine(e.ToString()); }
        }
        // 查找库存
        private bool _search(NnPolypeptide p, int row)
        {
            // 从数据库搜索,得到stockInfo对象,注意,这里传入的参数是新单  order by quality desc
            NnStockInfo info = NnReader.Instance.GetStockInfo(p);

            if (!info.IsAvailable)
            {
                return(false);                  // 如果库存有效,写入excel并且设置好单元格颜色
            }
            m_range.Cells[row, _info] = info.ToString();
            switch (info.ColorFlg)
            {
            case NnColorFlg.Modification: m_range.Cells[row, _info].Interior.ColorIndex = 45; break;

            case NnColorFlg.Quality: m_range.Cells[row, _info].Interior.ColorIndex = 50; break;
            }
            return(true);
        }