private void btnBarcodePrint_Click(object sender, EventArgs e)
        {
            List <string> listBarcode = new List <string>();
            DataTable     barcode     = m_findSellIn.GetBarcodeTable(dgv_Show.CurrentRow.Cells["DJH"].Value.ToString());

            for (int i = 0; i < barcode.Rows.Count; i++)
            {
                if (i == 0 || barcode.Rows[i]["BoxNo"].ToString() != barcode.Rows[i - 1]["BoxNo"].ToString())
                {
                    listBarcode = new List <string>();
                }

                listBarcode.Add(barcode.Rows[i]["ProductCode"].ToString());

                if (barcode.Rows.Count - 1 == i || barcode.Rows[i]["BoxNo"].ToString() != barcode.Rows[i + 1]["BoxNo"].ToString())
                {
                    PrintPartBarcode.PrintBarcodeCVTNumberList(listBarcode);
                    PrintPartBarcode.PrintBarcode_120X30(barcode.Rows[i]["BoxNo"].ToString());
                }
            }
        }
        void PrintBoxCode(List <string> lstBoxCode)
        {
            m_dtProductCodes = (DataTable)dataGridView1.DataSource;

            if (lstBoxCode == null || lstBoxCode.Count() == 0)
            {
                return;
            }

            if (m_dtProductCodes == null || m_dtProductCodes.Rows.Count == 0)
            {
                return;
            }

            lstBoxCode = lstBoxCode.Distinct().ToList();

            foreach (string boxCode in lstBoxCode)
            {
                if (UniversalFunction.GetGoodsAttributeInfo(m_barCodeInfo.GoodsID, CE_GoodsAttributeName.CVT).ToString() == "True")
                {
                    DataTable tempTable = DataSetHelper.SiftDataTable(m_dtProductCodes, "BoxNo = '" + boxCode + "'");

                    List <string> lstBarcode = new List <string>();

                    foreach (DataRow dr in tempTable.Rows)
                    {
                        lstBarcode.Add(dr["ProductCode"].ToString());
                    }

                    PrintPartBarcode.PrintBarcodeCVTNumberList(lstBarcode);
                    PrintPartBarcode.PrintBarcode_120X30(boxCode);
                }
                else if (UniversalFunction.GetGoodsAttributeInfo(m_barCodeInfo.GoodsID, CE_GoodsAttributeName.TCU).ToString() == "True")
                {
                    PrintPartBarcode.PrintBarcode_60X20(boxCode);
                }
            }
        }
示例#3
0
        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();
            }
        }