/// <summary> /// 将整盒TCU插入表中 /// </summary> private void InsertCode() { try { string storageId = null; foreach (KeyValuePair <string, CE_MarketingType> item in m_dicMarkInfo) { switch (item.Value) { case CE_MarketingType.退库: case CE_MarketingType.出库: case CE_MarketingType.退货: case CE_MarketingType.领料: case CE_MarketingType.调出: case CE_MarketingType.库房报废: storageId = item.Key; break; default: break; } } if (storageId == null) { throw new Exception("找不到出库库房"); } DataTable dtCodes = m_findSellIn.GetBoxInfo(txtBoxNo.Text, storageId); if (dtCodes == null || dtCodes.Rows.Count == 0) { return; } bool blInsert = false; m_dtProductCodes = (DataTable)dataGridView1.DataSource; DataTable dt = m_dtProductCodes.Copy(); for (int i = 0; i < dtCodes.Rows.Count; i++) { blInsert = false; for (int k = 0; k < dt.Rows.Count; k++) { if (dt.Rows[k]["ProductCode"].ToString() == dtCodes.Rows[i]["ProductCode"].ToString()) { blInsert = true; } } if (!blInsert) { foreach (KeyValuePair <string, CE_MarketingType> item in m_dicMarkInfo) { if (m_findSellIn.IsProductCodeOperationStandard(item.Value.ToString(), typeof(CE_MarketingType), Convert.ToInt32(txtGoodsName.Tag), dtCodes.Rows[i]["ProductCode"].ToString(), item.Key, out m_err)) { DataRow dr = m_dtProductCodes.NewRow(); dr["Number"] = m_dtProductCodes.Rows.Count + 1; dr["ProductCode"] = dtCodes.Rows[i]["ProductCode"].ToString(); dr["BoxNo"] = dtCodes.Rows[i]["BoxNo"].ToString(); m_dtProductCodes.Rows.Add(dr); } else { throw new Exception(m_err); } } } } dataGridView1.DataSource = m_dtProductCodes; } catch (Exception ex) { MessageDialog.ShowPromptMessage(ex.Message); } }