// 查找库存 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); }
/// <summary> /// 获取库存信息 /// </summary> internal NnStockInfo GetStockInfo(NnPolypeptide p) { NnStockInfo info = new NnStockInfo(p); try { using (OleDbCommand cmd = new OleDbCommand("SELECT * FROM history,stock_new where history.orderId = stock_new.orderId AND history.sequence=@v1", mConnection)) { cmd.Parameters.AddWithValue("v1", p.Sequence); using (OleDbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { NnStock stock = new NnStock(); stock.InitStockByDb(reader); info.Add(stock);// 这里只添加,由stockInfo判断是否有效,决定是否添加(所以这里添加了,不一定会真添加到库存信息中) } } } } catch (Exception e) { Console.WriteLine(e.ToString()); } return(info); }