Example #1
0
        /// <summary>
        /// 从领料单导入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLoadDataFromMRB_Click(object sender, EventArgs e)
        {
            if (!CheckData())
            {
                return;
            }

            FormQueryInfo dialog = QueryInfoDialog.GetMaterialRequisitionBillDialog(BasicInfo.LoginID, CE_BillTypeEnum.领料单);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string billNo = dialog.GetStringDataItem("领料单号");

                if (MessageDialog.ShowEnquiryMessage("您确定要导入 " + billNo
                                                     + " 领料单的信息吗?此过程需要一段时间,是否继续?") == DialogResult.No)
                {
                    return;
                }

                // 领料单服务
                IMaterialRequisitionServer billServer = ServerModuleFactory.GetServerModule <IMaterialRequisitionServer>();

                // 领料单物品清单服务
                IMaterialRequisitionGoodsServer goodsServer = ServerModuleFactory.GetServerModule <IMaterialRequisitionGoodsServer>();

                View_S_MaterialRequisition bill = billServer.GetBillView(billNo);

                List <View_S_MaterialRequisitionGoods> lstMRGoods = (from r in goodsServer.GetGoods(billNo)
                                                                     orderby r.显示位置
                                                                     select r).ToList();

                if (lstMRGoods.Count > 0)
                {
                    if (是否一次性物品.Checked && GlobalObject.GeneralFunction.IsNullOrEmpty(m_productNumber))
                    {
                        m_productNumber = cmbProductCode.Text;
                    }

                    List <StorageGoods> lstGoods = new List <StorageGoods>(lstMRGoods.Count);

                    foreach (var item in lstMRGoods)
                    {
                        StorageGoods goods = new StorageGoods();

                        goods.GoodsCode = item.图号型号;
                        goods.GoodsName = item.物品名称;
                        goods.Spec      = item.规格;
                        goods.Provider  = item.供应商编码;
                        goods.BatchNo   = item.批次号;
                        goods.Quantity  = item.实领数;
                        goods.StorageID = item.StorageID;

                        lstGoods.Add(goods);
                    }

                    if (!m_mbpServer.AddFromBill(BasicInfo.LoginID, Convert.ToInt32(
                                                     cmbPurpose.SelectedValue), m_productNumber, billNo, lstGoods, out m_error))
                    {
                        MessageDialog.ShowErrorMessage(m_error);
                    }
                    else
                    {
                        MessageDialog.ShowPromptMessage("操作成功");

                        SearchData(0);
                    }
                }
            }
        }