private void btnCreate_Click(object sender, EventArgs e) { Dictionary <CE_GoodsAttributeName, object> dic = UniversalFunction.GetGoodsInfList_Attribute_AttchedInfoList(Convert.ToInt32(cmbProduct.Tag)); if (!dic.Keys.ToList().Contains(CE_GoodsAttributeName.装箱数)) { throw new Exception(UniversalFunction.GetGoodsMessage(Convert.ToInt32(cmbProduct.Tag)) + "基础属性未设置【装箱数】"); } DataTable dt = (DataTable)dataGridView1.DataSource; if (dt == null || dt.Rows.Count == 0) { return; } dt.Columns.Add("BoxNo"); string prefix = ""; if (Convert.ToBoolean(dic[CE_GoodsAttributeName.CVT])) { prefix = CE_GoodsAttributeName.CVT.ToString(); } else if (Convert.ToBoolean(dic[CE_GoodsAttributeName.TCU])) { prefix = CE_GoodsAttributeName.TCU.ToString(); } string boxNo = m_findSellIn.GetBoxNo(prefix); int boxCount = 0; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["入库方式"].ToString() == "未知") { MessageDialog.ShowPromptMessage("入库方式不能为【未知】,请选择正确的入库方式"); return; } if (cmbStorage.Text == "售后库房" && (dt.Rows[i]["入库方式"].ToString() == "生产入库" || dt.Rows[i]["入库方式"].ToString() == "生产返修入库")) { MessageDialog.ShowPromptMessage("入库方式错误,请选择正确的入库方式"); return; } if (boxCount == Convert.ToInt32(dic[CE_GoodsAttributeName.装箱数])) { boxNo = prefix + (Convert.ToInt64(boxNo.Substring(prefix.Length, boxNo.Length - prefix.Length)) + 1).ToString(); boxCount = 0; } dt.Rows[i]["BoxNo"] = boxNo; boxCount += 1; } if (!m_findSellIn.BatchCreateBill(dt, out m_err)) { MessageDialog.ShowPromptMessage(m_err); return; } else { MessageDialog.ShowPromptMessage("自动生成成功!"); List <string> listBarcode = new List <string>(); for (int i = 0; i < dt.Rows.Count; i++) { listBarcode.Add(dt.Rows[i]["箱体编号"].ToString()); if (i + 1 == dt.Rows.Count || dt.Rows[i]["BoxNo"] != dt.Rows[i + 1]["BoxNo"]) { PrintPartBarcode.PrintBarcodeCVTNumberList(listBarcode); PrintPartBarcode.PrintBarcode_120X30(dt.Rows[i]["BoxNo"].ToString()); listBarcode = new List <string>(); } } this.Close(); } }