/// <summary>
        /// 获取某一条形码的货物信息
        /// </summary>
        /// <param name="barCode">条形码序号即条形码</param>
        /// <param name="goodsInfo">物品信息</param>
        /// <param name="error">获取失败时返回的错误信息</param>
        /// <returns>获取成功返回True,获取失败返回False</returns>
        public bool GetData(int barCode, out View_S_InDepotGoodsBarCodeTable goodsInfo, out string error)
        {
            goodsInfo = null;

            error = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from r in dataContxt.View_S_InDepotGoodsBarCodeTable
                             where r.条形码 == barCode
                             select r;

                if (result.Count() == 0)
                {
                    error = "条形码有误";
                    return(false);
                }

                goodsInfo = result.Single();

                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Exemple #2
0
        private void btnPrintAllBarCode_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = (DataTable)dgv_Main.DataSource;

                if (dt.Rows.Count < 1)
                {
                    MessageDialog.ShowPromptMessage("表中无数据集");
                    return;
                }

                List <View_S_InDepotGoodsBarCodeTable> lstBarCodeInfo = new List <View_S_InDepotGoodsBarCodeTable>();

                // 保存条形码与实领数对应关系的字典
                Dictionary <int, decimal> dicAmount = new Dictionary <int, decimal>();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    View_S_InDepotGoodsBarCodeTable barcode = new View_S_InDepotGoodsBarCodeTable();

                    barcode.条形码 = m_serverBarCode.GetBarCode(Convert.ToInt32(dt.Rows[i]["CPID"].ToString()), dt.Rows[i]["BatchNo"].ToString(),
                                                             UniversalFunction.GetStorageID(cmbStorage.Text), dt.Rows[i]["Provider"].ToString());

                    barcode.图号型号 = dt.Rows[i]["GoodsCode"].ToString();
                    barcode.物品名称 = dt.Rows[i]["GoodsName"].ToString();
                    barcode.规格   = dt.Rows[i]["Spec"].ToString();
                    barcode.供货单位 = dt.Rows[i]["Provider"].ToString();
                    barcode.批次号  = dt.Rows[i]["BatchNo"].ToString();
                    barcode.货架   = "";
                    barcode.层    = "";
                    barcode.列    = "";
                    barcode.工位   = dt.Rows[i]["Remark"].ToString();
                    barcode.物品ID = Convert.ToInt32(dt.Rows[i]["CPID"].ToString());

                    lstBarCodeInfo.Add(barcode);

                    if (!dicAmount.ContainsKey(barcode.条形码))
                    {
                        dicAmount.Add(barcode.条形码, (decimal)dt.Rows[i]["Count"]);
                    }
                }

                List <View_S_InDepotGoodsBarCodeTable> barCodeInfo = (from r in lstBarCodeInfo orderby r.工位 ascending select r).ToList();

                foreach (var item in barCodeInfo)
                {
                    ServerModule.PrintPartBarcode.PrintBarcodeList(item, dicAmount[item.条形码]);
                }

                MessageDialog.ShowPromptMessage("条码全部打印完成");
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                return;
            }
        }
        private void btnPrintBarCode_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.CurrentRow == null)
                {
                    throw new Exception("选择打印的条形码记录行不允许为空!");
                }

                List <View_S_InDepotGoodsBarCodeTable> lstBarCodeInfo = new List <View_S_InDepotGoodsBarCodeTable>();
                IBarCodeServer serviceBarCode = ServerModuleFactory.GetServerModule <IBarCodeServer>();

                foreach (DataGridViewRow dgvr in this.dataGridView1.SelectedRows)
                {
                    View_S_InDepotGoodsBarCodeTable barcode = new View_S_InDepotGoodsBarCodeTable();

                    QueryCondition_Store tempInfo = new QueryCondition_Store();

                    tempInfo.BatchNo   = dgvr.Cells["批次号"].Value.ToString();
                    tempInfo.GoodsID   = Convert.ToInt32(dgvr.Cells["物品ID"].Value);
                    tempInfo.Provider  = m_strProvider;
                    tempInfo.StorageID = m_strStorage;

                    S_Stock stockInfo = UniversalFunction.GetStockInfo(tempInfo);

                    View_F_GoodsPlanCost goodsInfo = UniversalFunction.GetGoodsInfo(tempInfo.GoodsID);

                    barcode.条形码 =
                        serviceBarCode.GetBarCode(stockInfo.GoodsID, stockInfo.BatchNo, stockInfo.StorageID, stockInfo.Provider);

                    barcode.图号型号   = goodsInfo.图号型号;
                    barcode.物品名称   = goodsInfo.物品名称;
                    barcode.规格     = goodsInfo.规格;
                    barcode.供货单位   = stockInfo.Provider;
                    barcode.批次号    = stockInfo.BatchNo;
                    barcode.货架     = stockInfo.ShelfArea;
                    barcode.层      = stockInfo.LayerNumber;
                    barcode.列      = stockInfo.ColumnNumber;
                    barcode.材料类别编码 = dgvr.Cells["退货数"].Value.ToString();
                    barcode.物品ID   = stockInfo.GoodsID;

                    lstBarCodeInfo.Add(barcode);
                }

                foreach (var item in lstBarCodeInfo)
                {
                    ServerModule.PrintPartBarcode.PrintBarcodeList(item, Convert.ToDecimal(item.材料类别编码));
                }

                MessageBox.Show("条码全部打印完成");
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
            }
        }
        /// <summary>
        /// 获取条形码信息
        /// </summary>
        /// <param name="barCodeID">条形码编号</param>
        /// <returns>成功返回获取到的条形码信息,失败返回null</returns>
        private View_S_InDepotGoodsBarCodeTable GetBarCodeInfo(int barCodeID)
        {
            View_S_InDepotGoodsBarCodeTable goodsInfo = null;

            if (!m_barCodeServer.GetData(barCodeID, out goodsInfo, out m_error))
            {
                MessageDialog.ShowErrorMessage(m_error);
                return(null);
            }

            return(goodsInfo);
        }
Exemple #5
0
        private void 条形码打印ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count < 1)
            {
                MessageDialog.ShowPromptMessage("请选择记录后再打印条形码");
                return;
            }

            List <View_S_InDepotGoodsBarCodeTable> lstBarCodeInfo = new List <View_S_InDepotGoodsBarCodeTable>();

            for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
            {
                string goodsCode = dataGridView1.SelectedRows[i].Cells["图号型号"].Value.ToString();
                string goodsName = dataGridView1.SelectedRows[i].Cells["物品名称"].Value.ToString();
                string spec      = dataGridView1.SelectedRows[i].Cells["规格"].Value.ToString();
                string provider  = dataGridView1.SelectedRows[i].Cells["供应商"].Value.ToString();
                string batchCode = dataGridView1.SelectedRows[i].Cells["批次号"].Value.ToString();
                string StorageID = dataGridView1.SelectedRows[i].Cells["库房编码"].Value.ToString();

                IBarCodeServer server = ServerModuleFactory.GetServerModule <IBarCodeServer>();
                View_S_InDepotGoodsBarCodeTable barcode = server.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID);

                if (barcode == null)
                {
                    S_InDepotGoodsBarCodeTable newBarcode = new S_InDepotGoodsBarCodeTable();

                    IBasicGoodsServer basicServer = ServerModuleFactory.GetServerModule <IBasicGoodsServer>();
                    newBarcode.GoodsID     = basicServer.GetGoodsID(goodsCode, goodsName, spec);
                    newBarcode.Provider    = provider;
                    newBarcode.BatchNo     = batchCode;
                    newBarcode.ProductFlag = "0";
                    newBarcode.StorageID   = StorageID;

                    if (!server.Add(newBarcode, out m_err))
                    {
                        MessageDialog.ShowErrorMessage(m_err);
                        return;
                    }

                    barcode = server.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID);
                }

                lstBarCodeInfo.Add(barcode);
            }

            foreach (var item in lstBarCodeInfo)
            {
                ServerModule.PrintPartBarcode.PrintBarcodeList(item);
            }
        }
Exemple #6
0
        private void btnPrintBarCode_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count < 1)
            {
                MessageDialog.ShowPromptMessage("请选择记录后再打印条形码");
                return;
            }

            List <View_S_InDepotGoodsBarCodeTable> lstBarCodeInfo = new List <View_S_InDepotGoodsBarCodeTable>();

            for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
            {
                string batchCode = dataGridView1.SelectedRows[i].Cells["批次号"].Value.ToString();
                string goodsCode = dataGridView1.SelectedRows[i].Cells["图号型号"].Value.ToString();
                string goodsName = dataGridView1.SelectedRows[i].Cells["物品名称"].Value.ToString();
                string spec      = dataGridView1.SelectedRows[i].Cells["规格"].Value.ToString();
                string provider  = dataGridView1.SelectedRows[i].Cells["供货单位"].Value.ToString();
                string StorageID = dataGridView1.SelectedRows[i].Cells["库房代码"].Value.ToString();
                View_S_InDepotGoodsBarCodeTable barcode = m_barCodeServer.GetBarCodeInfo(
                    goodsCode, goodsName, spec, provider, batchCode, StorageID);

                // 找不到此物品的条形码时生成一个
                if (barcode == null)
                {
                    S_InDepotGoodsBarCodeTable newBarcode = new S_InDepotGoodsBarCodeTable();

                    newBarcode.GoodsID     = (int)dataGridView1.SelectedRows[i].Cells["物品ID"].Value;
                    newBarcode.Provider    = provider;
                    newBarcode.BatchNo     = batchCode;
                    newBarcode.ProductFlag = "0";
                    newBarcode.StorageID   = StorageID;

                    if (!m_barCodeServer.Add(newBarcode, out m_error))
                    {
                        MessageDialog.ShowErrorMessage(m_error);
                        return;
                    }

                    barcode = m_barCodeServer.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID);
                }

                lstBarCodeInfo.Add(barcode);
            }

            foreach (var item in lstBarCodeInfo)
            {
                ServerModule.PrintPartBarcode.PrintBarcodeList(item);
            }
        }
        /// <summary>
        /// 获取条形码信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetBarCodeInfo_Click(object sender, EventArgs e)
        {
            if (numBarcode.Value == 0m)
            {
                MessageDialog.ShowPromptMessage("条形码不能是0");
                return;
            }

            View_S_InDepotGoodsBarCodeTable goodsInfo = GetBarCodeInfo(Convert.ToInt32(numBarcode.Value));

            if (goodsInfo != null)
            {
                bool isValid = false;

                if (goodsInfo.图号型号 == txtGoodsCode.Text)
                {
                    // 是否选配零件,是选配零件则不要检查规格
                    if (m_choseConfectServer.IsExistChoseConfectInfo(goodsInfo.图号型号))
                    {
                        isValid = true;
                    }
                    else
                    {
                        if (goodsInfo.规格 == m_dataRow["规格"])
                        {
                            isValid = true;
                        }
                    }
                }

                if (isValid)
                {
                    txtBatchNo.Text  = goodsInfo.批次号;
                    txtProvider.Text = goodsInfo.供货单位;
                    txtSpec.Text     = goodsInfo.规格;
                }
                else
                {
                    MessageDialog.ShowErrorMessage(
                        string.Format("您录入的条形码【{0}】物品名称为【{1}】规格为【{2}】,与返修零件不符合",
                                      goodsInfo.条形码, goodsInfo.物品名称, goodsInfo.规格));
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// 打印条形码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPrintBarCode_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count < 1)
            {
                MessageDialog.ShowPromptMessage("选择打印的条形码记录行不允许为空!");
                return;
            }

            List <View_S_InDepotGoodsBarCodeTable> lstBarCodeInfo = new List <View_S_InDepotGoodsBarCodeTable>();

            for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
            {
                DataGridViewCellCollection      cells   = dataGridView1.SelectedRows[i].Cells;
                View_S_InDepotGoodsBarCodeTable barcode = new View_S_InDepotGoodsBarCodeTable();

                barcode.条形码  = (int)cells["条形码"].Value;
                barcode.图号型号 = cells["图号型号"].Value.ToString();
                barcode.物品名称 = cells["物品名称"].Value.ToString();
                barcode.规格   = cells["规格"].Value.ToString();
                barcode.供货单位 = cells["供货单位"].Value.ToString();
                barcode.批次号  = cells["批次号"].Value.ToString();
                barcode.货架   = cells["货架"].Value.ToString();
                barcode.层    = cells["层"].Value.ToString();
                barcode.列    = cells["列"].Value.ToString();
                barcode.工位   = cells["工位"].Value.ToString();

                //View_S_InDepotGoodsBarCodeTable barcode = m_barCodeServer.GetBarCodeInfo(
                //    cells["图号型号"].Value.ToString(), cells["物品名称"].Value.ToString(), cells["规格"].Value.ToString(),
                //    cells["供货单位"].Value.ToString(), cells["批次号"].Value.ToString(), cells["库房代码"].Value.ToString());

                lstBarCodeInfo.Add(barcode);
            }

            foreach (var item in lstBarCodeInfo)
            {
                ServerModule.PrintPartBarcode.PrintBarcodeList(item);
            }
        }
Exemple #9
0
        private void btnPrintCVTBarcodes_Click(object sender, EventArgs e)
        {
            StringBuilder error     = new StringBuilder();
            string        errorTemp = null;

            打印整台份返修箱条码 form = new 打印整台份返修箱条码();

            form.ShowDialog();

            List <View_ZPX_ReparativeBarcode> lstPrintData = form.PrintData;

            if (lstPrintData != null && form.blPrintFlag && lstPrintData.Count > 0)
            {
                if (MessageDialog.ShowEnquiryMessage("此过程需要一段时间,是否继续?") == DialogResult.No)
                {
                    return;
                }

                List <View_S_InDepotGoodsBarCodeTable> lstBarCodeInfo = new List <View_S_InDepotGoodsBarCodeTable>();
                DateTime              dt = ServerModule.ServerTime.Time;
                IBasicGoodsServer     basicGoodsServer = ServerModuleFactory.GetServerModule <IBasicGoodsServer>();
                Dictionary <int, int> dicBarcode       = new Dictionary <int, int>();

                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    foreach (var item in lstPrintData)
                    {
                        // 装配挑选回收件
                        string batchCode = "ZTJ" + dt.ToString("yyyyMMdd");
                        string goodsCode = item.零部件编码;
                        string goodsName = item.零部件名称;
                        string spec      = item.规格;
                        string provider  = item.供货单位;
                        string StorageID = "01";

                        View_S_InDepotGoodsBarCodeTable barcode    = null;
                        S_InDepotGoodsBarCodeTable      newBarcode = new S_InDepotGoodsBarCodeTable();

                        newBarcode.GoodsID = basicGoodsServer.GetGoodsID(goodsCode, goodsName, spec);

                        if (newBarcode.GoodsID == 0)
                        {
                            error.AppendLine("[" + goodsCode + "]" + "[" + goodsName + "]" + "[" + spec + "] 无物品ID");
                            continue;
                        }

                        newBarcode.Provider    = provider;
                        newBarcode.BatchNo     = batchCode;
                        newBarcode.ProductFlag = "0";
                        newBarcode.StorageID   = StorageID;

                        barcode = m_barCodeServer.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID);

                        if (barcode == null)
                        {
                            if (!m_barCodeServer.Add(newBarcode, out errorTemp))
                            {
                                MessageDialog.ShowErrorMessage(errorTemp);
                                return;
                            }
                        }

                        barcode      = m_barCodeServer.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID);
                        barcode.物品ID = item.数量;

                        dicBarcode.Add(barcode.条形码, item.数量);

                        if (barcode.工位 != null)
                        {
                            string[] workBench = barcode.工位.Split(new char[] { ',' });

                            if (workBench.Length == 1)
                            {
                                lstBarCodeInfo.Add(barcode);
                            }
                            else
                            {
                                foreach (var wb in workBench)
                                {
                                    View_S_InDepotGoodsBarCodeTable barCode =
                                        GlobalObject.CloneObject.CloneProperties <View_S_InDepotGoodsBarCodeTable>(barcode);

                                    barCode.工位 = wb;
                                    lstBarCodeInfo.Add(barCode);
                                }
                            }
                        }
                        else
                        {
                            barcode.工位 = "";
                            lstBarCodeInfo.Add(barcode);
                        }
                    }

                    lstBarCodeInfo.Sort(this.SortMethod);

                    foreach (var barcode in lstBarCodeInfo)
                    {
                        // barcode.物品ID 中保存的为数量
                        ServerModule.PrintPartBarcode.PrintBarcodeList(barcode, barcode.物品ID);
                    }

                    if (MessageDialog.ShowEnquiryMessage("是否将当前打印物品数量增加到多批次管理信息中?") == DialogResult.Yes)
                    {
                        IMultiBatchPartServer multiBatchPartServer = ServerModuleFactory.GetServerModule <IMultiBatchPartServer>();

                        if (!multiBatchPartServer.AddFromReparativePartList(GlobalObject.BasicInfo.LoginID,
                                                                            form.PurposeID, dicBarcode, out m_err))
                        {
                            MessageDialog.ShowErrorMessage(m_err);
                        }
                    }
                }
                catch (Exception exce)
                {
                    MessageDialog.ShowErrorMessage(exce.Message);
                }
                finally
                {
                    Cursor.Current = Cursors.Arrow;
                }
            }

            if (error.Length > 0)
            {
                MessageDialog.ShowErrorMessage(error.ToString());
            }
        }
Exemple #10
0
 private int SortMethod(View_S_InDepotGoodsBarCodeTable data1, View_S_InDepotGoodsBarCodeTable data2)
 {
     return(data1.工位.CompareTo(data2.工位));
 }
        /// <summary>
        /// 根据返修零件增加条形码
        /// </summary>
        /// <param name="userCode">用户编码</param>
        /// <param name="purposeID">用途编号</param>
        /// <param name="dicBarcode">条形码字典</param>
        /// <param name="error">出错时的错误信息</param>
        /// <returns>操作是否成功的标志</returns>
        public bool AddFromReparativePartList(string userCode, int purposeID, Dictionary <int, int> dicBarcode, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext      ctx           = CommentParameter.DepotDataContext;
                IBarCodeServer                  barCodeServer = BasicServerFactory.GetServerModule <IBarCodeServer>();
                View_S_InDepotGoodsBarCodeTable barCode       = null;
                DateTime dt = ServerTime.Time;

                foreach (KeyValuePair <int, int> item in dicBarcode)
                {
                    var result = from r in ctx.ZPX_MultiBatchPart
                                 where r.BarCode == item.Key && r.PurposeID == purposeID
                                 select r;

                    ZPX_MultiBatchPart mbp = null;

                    if (result.Count() == 0)
                    {
                        mbp = new ZPX_MultiBatchPart();

                        mbp.BarCode    = item.Key;
                        mbp.PurposeID  = purposeID;
                        mbp.CVTNumber  = "";
                        mbp.Counts     = item.Value;
                        mbp.CreateDate = dt;
                        mbp.UpdateDate = dt;
                        mbp.Remark    += dt.ToString("yyyy-MM-dd HH:mm:ss") + ", 用户 " + userCode + " 增加数量为:" + mbp.Counts.ToString() + " ;";

                        if (!barCodeServer.GetData(item.Key, out barCode, out error))
                        {
                            return(false);
                        }

                        mbp.InputDate           = barCode.入库时间;
                        mbp.Msrepl_tran_version = Guid.NewGuid();

                        ctx.ZPX_MultiBatchPart.InsertOnSubmit(mbp);
                    }
                    else
                    {
                        mbp = result.Single();

                        mbp.Counts    += item.Value;
                        mbp.UpdateDate = dt;

                        if (mbp.Remark.Length > 0)
                        {
                            mbp.Remark += "\r\n";
                        }

                        mbp.Remark += dt.ToString("yyyy-MM-dd HH:mm:ss") + ", 用户 " + userCode + " 增加数量:" + item.Value.ToString() + " ;";
                    }
                }

                ctx.SubmitChanges();
                return(true);
            }
            catch (Exception err)
            {
                error = err.Message;
                return(false);
            }
        }
        /// <summary>
        /// 由用户直接添加多批次信息
        /// </summary>
        /// <param name="userCode">用户编号</param>
        /// <param name="purposeID">用途编号</param>
        /// <param name="barCodeId">条形码ID</param>
        /// <param name="cvtNumber">变速箱号</param>
        /// <param name="count">装配数量</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回true</returns>
        public bool Add(string userCode, int purposeID, int barCodeId, string cvtNumber, int count, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext      ctx           = CommentParameter.DepotDataContext;
                IBarCodeServer                  barCodeServer = BasicServerFactory.GetServerModule <IBarCodeServer>();
                View_S_InDepotGoodsBarCodeTable barCode       = null;

                if (!barCodeServer.GetData(barCodeId, out barCode, out error))
                {
                    return(false);
                }

                var result = from r in ctx.ZPX_MultiBatchPart
                             where r.BarCode == barCodeId && r.PurposeID == purposeID && r.CVTNumber == cvtNumber
                             select r;

                if (result.Count() > 0)
                {
                    error = string.Format("条形码 [{0}] 的物品已经存在!", barCode.条形码);
                    return(false);
                }

                ZPX_MultiBatchPart mbp = new ZPX_MultiBatchPart();
                DateTime           dt  = ServerTime.Time;

                // 下线车间再制造
                if (purposeID == 5)
                {
                    string productType = cvtNumber.Split(new char[] { ' ' })[0];

                    IProductParts productParts = BasicServerFactory.GetServerModule <IProductParts>();

                    // 如果是一次性物品, 则不用CVT编号
                    if (productParts.IsDisposableParts(productType, barCode.图号型号))
                    {
                        cvtNumber = "";
                    }
                }

                mbp.BarCode             = barCode.条形码;
                mbp.PurposeID           = purposeID;
                mbp.CVTNumber           = cvtNumber;
                mbp.Counts              = count;
                mbp.Remark              = dt.ToString("yyyy-MM-dd HH:mm:ss") + ", 用户 " + userCode + " 增加数量 " + count.ToString() + " ;";
                mbp.CreateDate          = dt;
                mbp.UpdateDate          = dt;
                mbp.InputDate           = barCode.入库时间;
                mbp.Msrepl_tran_version = Guid.NewGuid();

                ctx.ZPX_MultiBatchPart.InsertOnSubmit(mbp);

                ctx.SubmitChanges();
                return(true);
            }
            catch (Exception err)
            {
                error = err.Message;
                return(false);
            }
        }
        /// <summary>
        /// 根据单据物品明细添加多批次信息(从领料单、营销出库单)
        /// </summary>
        /// <param name="userCode">操作用户</param>
        /// <param name="purposeID">多批次用途编号</param>
        /// <param name="cvtNumber">变速箱号</param>
        /// <param name="billNo">单据号</param>
        /// <param name="lstGoods">领料物品明细列表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回true</returns>
        public bool AddFromBill(string userCode, int purposeID, string cvtNumber, string billNo, List <StorageGoods> lstGoods, out string error)
        {
            error = null;

            if (lstGoods == null || lstGoods.Count == 0)
            {
                error = "物品明细为空,无法添加多批次信息";
                return(false);
            }

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            ctx.Connection.Open();
            ctx.Transaction = ctx.Connection.BeginTransaction();

            try
            {
                IBarCodeServer         barCodeServer = PMS_ServerFactory.GetServerModule <IBarCodeServer>();
                DateTime               dt            = ServerTime.Time;
                List <P_AssemblingBom> bomDatas      = null;
                string   productType    = cvtNumber.Trim();
                string[] arrayCvtNumber = null; // 存放分隔后的箱号

                // 下线车间再制造
                if (purposeID == 5)
                {
                    if (GlobalObject.GeneralFunction.IsNullOrEmpty(productType))
                    {
                        error = "产品类型不允许为空";
                        return(false);
                    }

                    arrayCvtNumber = productType.Split(new char[] { ' ' });

                    productType = arrayCvtNumber[0] + " FX";

                    bomDatas = (from r in ctx.P_AssemblingBom
                                where r.ProductCode == productType
                                select r).ToList();

                    if (bomDatas.Count < 100)
                    {
                        error = string.Format("还未配置 [{0}] 型号装配BOM的数据请配置后再进行此操作", productType);
                        return(false);
                    }
                }

                // 是否向多批次中添加了数据的标志
                bool addDataFlag = false;

                for (int i = 0; i < lstGoods.Count; i++)
                {
                    string tempCVTNumber = cvtNumber;

                    // 下线车间再制造
                    if (purposeID == 5)
                    {
                        IProductParts productParts = BasicServerFactory.GetServerModule <IProductParts>();

                        // 如果不是一次性物品, 而且在装配BOM中找不到则报错
                        if (!productParts.IsDisposableParts(productType, lstGoods[i].GoodsCode))
                        {
                            if (arrayCvtNumber.Length != 2)
                            {
                                error = "您导入的单据中包含非一次性物料,缺少产品箱号,无法进行此操作";
                                return(false);
                            }

                            if (!bomDatas.Exists(p => p.PartCode == lstGoods[i].GoodsCode && p.PartName == lstGoods[i].GoodsName))
                            {
                                error = string.Format("无法在装配BOM的 {0} 的数据中找到{1}, {2} 的物品信息,无法进行此操作!",
                                                      productType, lstGoods[i].GoodsCode, lstGoods[i].GoodsName);

                                return(false);
                            }
                        }
                        else
                        {
                            tempCVTNumber = "";
                        }
                    }

                    View_S_InDepotGoodsBarCodeTable barCode = barCodeServer.GetBarCodeInfo(
                        lstGoods[i].GoodsCode, lstGoods[i].GoodsName, lstGoods[i].Spec,
                        lstGoods[i].Provider, lstGoods[i].BatchNo, lstGoods[i].StorageID.ToString());

                    if (barCode == null)
                    {
                        error = string.Format("无法找到 {0}, {1}, 规格:{2}, 供应商:{3}, 批次号:{4}, 库存编码:{5} 物品的条形码信息,无法进行此操作!",
                                              lstGoods[i].GoodsCode, lstGoods[i].GoodsName, lstGoods[i].Spec,
                                              lstGoods[i].Provider, lstGoods[i].BatchNo, lstGoods[i].StorageID);

                        return(false);
                    }

                    var result = from r in ctx.ZPX_MultiBatchPart
                                 where r.BarCode == barCode.条形码 && r.PurposeID == purposeID && r.CVTNumber == tempCVTNumber
                                 select r;

                    ZPX_MultiBatchPart mbp = null;

                    if (result.Count() > 0)
                    {
                        mbp         = result.Single();
                        mbp.Counts += Convert.ToInt32(lstGoods[i].Quantity);

                        if (mbp.Remark.Length > 0)
                        {
                            mbp.Remark += "\r\n";
                        }

                        mbp.UpdateDate = dt;
                        mbp.Remark    += ServerTime.Time.ToString("yyyy-MM-dd HH:mm:ss") + ", 用户 " + userCode + ", 单据号:" + billNo + ", 增加数量:" + lstGoods[i].Quantity.ToString() + ";";
                    }
                    else
                    {
                        mbp = new ZPX_MultiBatchPart();

                        mbp.BarCode             = barCode.条形码;
                        mbp.PurposeID           = purposeID;
                        mbp.CVTNumber           = tempCVTNumber;
                        mbp.Counts              = Convert.ToInt32(lstGoods[i].Quantity);
                        mbp.Remark              = dt.ToString("yyyy-MM-dd HH:mm:ss") + ", 用户 " + userCode + ", 单据号:" + billNo + ",数量:" + mbp.Counts.ToString() + ";";
                        mbp.CreateDate          = dt;
                        mbp.UpdateDate          = dt;
                        mbp.InputDate           = barCode.入库时间;
                        mbp.Msrepl_tran_version = Guid.NewGuid();

                        ctx.ZPX_MultiBatchPart.InsertOnSubmit(mbp);
                    }

                    if (mbp.Counts < 0)
                    {
                        throw new Exception("【图号型号】:" + lstGoods[i].GoodsCode
                                            + "【物品名称】:" + lstGoods[i].GoodsName + "【规格】:" + lstGoods[i].Spec
                                            + "【批次号】:" + lstGoods[i].BatchNo + " 物品数量不能小于0");
                    }

                    addDataFlag = true;
                    ctx.SubmitChanges();
                }

                if (addDataFlag)
                {
                    ZPX_MultiBatchPart_LLD lld = new ZPX_MultiBatchPart_LLD();

                    lld.Bill_ID = billNo;

                    ctx.ZPX_MultiBatchPart_LLD.InsertOnSubmit(lld);
                    ctx.SubmitChanges();
                }
                else
                {
                    throw new Exception("没有添加任何数据,可能是单据中的零件不属于装配BOM");
                }

                ctx.Transaction.Commit();
                return(true);
            }
            catch (Exception err)
            {
                ctx.Transaction.Rollback();
                error = err.Message;
                return(false);
            }
        }
 /// <summary>
 /// 打印实物卡片条形码
 /// </summary>
 /// <param name="barcodeInfo">打印条形码时所需信息</param>
 /// <returns>成功返回true, 失败返回false</returns>
 static public bool PrintBarcodeList(View_S_InDepotGoodsBarCodeTable barcodeInfo)
 {
     return(PrintBarcodeList(barcodeInfo, 0));
 }
        /// <summary>
        /// 打印实物卡片条形码
        /// </summary>
        /// <param name="barcodeInfo">打印条形码时所需信息</param>
        /// <param name="amount">数量</param>
        /// <returns>成功返回true, 失败返回false</returns>
        static public bool PrintBarcodeList(View_S_InDepotGoodsBarCodeTable barcodeInfo, decimal amount)
        {
            IntPtr hDC = IntPtr.Zero;
            bool   bRet = true;
            double x, y, width = 0;

            if (barcodeInfo.条形码.ToString().Length <= 4)
            {
                width = 15;
            }
            else
            {
                width = 30;
            }

            bRet &= BarcodePrint.UTC_Begin(hDC, false);

            bRet &= BarcodePrint.UTC_Rectangle(14, 1, 98, 30, 5);
            x     = 15;
            y     = 2.0;

            bRet &= BarcodePrint.UTC_SetFont("黑体", 8, true, false, false, false);

            //图号型号
            string goodsCode = "图号/型号:" + barcodeInfo.图号型号;

            bRet &= BarcodePrint.UTC_Text(x, y, goodsCode, 0);

            //产品名称
            string goodsName = "产品名称 :" + barcodeInfo.物品名称;

            bRet &= BarcodePrint.UTC_Text(x, y + 4, goodsName, 0);

            //规格
            string spec = "规    格 :" + barcodeInfo.规格;

            if (spec.Length > 34)
            {
                BarcodePrint.UTC_SetFont("黑体", 8, true, false, false, false);

                bRet &= BarcodePrint.UTC_Text(x, y + 8, spec, 0);

                BarcodePrint.UTC_SetFont("黑体", 8, true, false, false, false);
            }
            else if (spec.Length > 29)
            {
                bRet &= BarcodePrint.UTC_Text(x, y + 8, spec, 0);
            }
            else
            {
                bRet &= BarcodePrint.UTC_Text(x, y + 8, spec, 0);
            }

            //供应商
            string provider = "供 应 商 :" + barcodeInfo.供货单位;

            if (amount > 0)
            {
                provider += "   数量 :" + amount.ToString("F2");
            }

            bRet &= BarcodePrint.UTC_Text(x, y + 12, provider, 0);

            //批次
            string batchCode = "批    次 :" + barcodeInfo.批次号;

            if (barcodeInfo.材料类别名称 == "回收件" || barcodeInfo.材料类别名称 == "返修件")
            {
                batchCode += "(" + barcodeInfo.材料类别名称 + ")";
            }

            bRet &= BarcodePrint.UTC_Text(x, y + 16, batchCode, 0);

            //货架
            string shelf = string.Format("货    架 :{0}  层:{1}  列:{2}", barcodeInfo.货架, barcodeInfo.层, barcodeInfo.列);

            bRet &= BarcodePrint.UTC_Text(x, y + 20, shelf, 0);

            if (barcodeInfo.工位 != null)
            {
                //工位
                string workBench = string.Format("工    位 :{0}", barcodeInfo.工位);

                bRet &= BarcodePrint.UTC_Text(x, y + 24, workBench, 0);
            }

            if (spec.Length > 20)
            {
                x     += 9;
                width -= 2;
            }

            if (barcodeInfo.条形码.ToString().Length < 2)
            {
                x += 5;
            }

            bRet &= bRet = BarcodePrint.UTC_Barcode(x + 52, y + 5, width, 15, barcodeInfo.条形码.ToString(), "CODE128B", 0, false);

            bRet &= BarcodePrint.UTC_SetFont("黑体", 14, true, false, false, false);

            string barCodeText = barcodeInfo.条形码.ToString();

            x     = x + 48 + (width - BarcodePrint.UTC_GetTextWidth(barCodeText)) / 2;
            bRet &= BarcodePrint.UTC_Text(x, y + 21, barCodeText, 0);
            bRet &= BarcodePrint.UTC_End(); //分页

            return(bRet);
        }