Exemple #1
0
        /// <summary>
        /// 自动生成领料单
        /// </summary>
        /// <param name="contxt">数据上下文</param>
        /// <param name="djh">单据号</param>
        void CreateMaterialRequisition(DepotManagementDataContext contxt, string djh)
        {
            MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer();
            string error = null;

            try
            {
                string strBillID = m_assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

                S_StorageCheck billInfo = GetBill(contxt, djh);
                List <View_S_StorageCheckList> listInfo           = (from a in GetList(contxt, djh) where a.盈亏数量 < 0 select a).ToList();
                S_MaterialRequisition          lnqRequisitionBill = new S_MaterialRequisition();

                if (listInfo.Count > 0)
                {
                    #region 领料单主表
                    lnqRequisitionBill.AssociatedBillNo    = djh;
                    lnqRequisitionBill.AssociatedBillType  = "盘点单";
                    lnqRequisitionBill.Bill_ID             = strBillID;
                    lnqRequisitionBill.Bill_Time           = ServerTime.Time;
                    lnqRequisitionBill.BillStatus          = "已出库";
                    lnqRequisitionBill.Department          = "ZZ05";
                    lnqRequisitionBill.DepartmentDirector  = UniversalFunction.GetPersonnelInfo(contxt, billInfo.SHRY).姓名;
                    lnqRequisitionBill.DepotManager        = BasicInfo.LoginName;
                    lnqRequisitionBill.FetchCount          = 0;
                    lnqRequisitionBill.FetchType           = "零星领料";
                    lnqRequisitionBill.FillInPersonnel     = UniversalFunction.GetPersonnelInfo(contxt, billInfo.BZRY).姓名;
                    lnqRequisitionBill.FillInPersonnelCode = billInfo.BZRY;
                    lnqRequisitionBill.OutDepotDate        = ServerTime.Time;
                    lnqRequisitionBill.ProductType         = "";
                    lnqRequisitionBill.PurposeCode         = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.盘点).Code;
                    lnqRequisitionBill.Remark    = "库房盘点(盘亏)";
                    lnqRequisitionBill.StorageID = billInfo.StorageID;

                    if (!serverMaterialBill.AutoCreateBill(contxt, lnqRequisitionBill, out error))
                    {
                        throw new Exception(error);
                    }
                    #endregion

                    foreach (View_S_StorageCheckList listSingle in listInfo)
                    {
                        #region 领料单明细

                        S_MaterialRequisitionGoods lnqRequisitionGoods = new S_MaterialRequisitionGoods();

                        lnqRequisitionGoods.BasicCount   = 0;
                        lnqRequisitionGoods.BatchNo      = listSingle.批次号;
                        lnqRequisitionGoods.Bill_ID      = strBillID;
                        lnqRequisitionGoods.GoodsID      = (int)listSingle.物品ID;
                        lnqRequisitionGoods.ProviderCode = listSingle.供货单位;
                        lnqRequisitionGoods.RealCount    = -(decimal)listSingle.盈亏数量;
                        lnqRequisitionGoods.Remark       = "库房盘点(盘亏)";
                        lnqRequisitionGoods.RequestCount = -(decimal)listSingle.盈亏数量;
                        lnqRequisitionGoods.ShowPosition = 1;

                        MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer();

                        if (!serverMaterialGoods.AutoCreateGoods(contxt, lnqRequisitionGoods, out error))
                        {
                            throw new Exception(error);
                        }

                        #endregion
                    }
                    contxt.SubmitChanges();

                    serverMaterialBill.OpertaionDetailAndStock(contxt, lnqRequisitionBill);
                    contxt.SubmitChanges();

                    m_assignBill.UseBillNo(CE_BillTypeEnum.领料单.ToString(), strBillID);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #2
0
        /// <summary>
        /// 自动生成领料单
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="isolation">隔离单单据信息</param>
        /// <param name="flag">是否为废弃数,若为废弃数则用“废弃数”表示</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>自动生成成功返回True,自动生成失败返回False</returns>
        private bool CreateMeterialRequisition(DepotManagementDataContext context,
                                               S_IsolationManageBill isolation, string flag, out string error)
        {
            error = null;

            MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer();

            try
            {
                string strBillID = m_assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

                var varIsolation = from a in context.S_IsolationManageBill
                                   where a.DJH == isolation.DJH
                                   select a;

                S_IsolationManageBill lnqNewIsolation = new S_IsolationManageBill();

                if (varIsolation.Count() != 1)
                {
                    error = "数据不唯一或者为空";
                    return(false);
                }
                else
                {
                    lnqNewIsolation = varIsolation.Single();
                }

                #region 领料总单
                S_MaterialRequisition lnqMater = new S_MaterialRequisition();

                lnqMater.Bill_Time          = ServerTime.Time;
                lnqMater.Bill_ID            = strBillID;
                lnqMater.BillStatus         = "已出库";
                lnqMater.Department         = "ZK";
                lnqMater.DepartmentDirector = "";
                lnqMater.DepotManager       = "";
                lnqMater.FetchCount         = 0;
                lnqMater.FetchType          = "零星领料";
                lnqMater.FillInPersonnel    = flag == "废弃数" ? "陈岁年" : UniversalFunction.GetPersonnelName(lnqNewIsolation.JYRY);
                //质管部要求[废弃数]变更编制人为陈岁年 2012.3.15
                lnqMater.FillInPersonnelCode = flag == "废弃数" ? "0621" : lnqNewIsolation.JYRY;
                //质管部要求[废弃数]变更编制人为陈岁年 2012.3.15
                lnqMater.OutDepotDate = ServerTime.Time;
                lnqMater.ProductType  = "";
                lnqMater.PurposeCode  = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.破坏性检测).Code;
                lnqMater.Remark       = flag == "废弃数" ?
                                        "不合格品隔离处置单废弃处理,关联的隔离单号:  " + isolation.DJH
                    : "不合格品隔离处置单检测报废,关联的隔离单号:  " + isolation.DJH;
                lnqMater.StorageID          = isolation.StorageID;
                lnqMater.AssociatedBillNo   = "";
                lnqMater.AssociatedBillType = "";

                if (!serverMaterialBill.AutoCreateBill(context, lnqMater, out error))
                {
                    return(false);
                }

                #endregion

                #region 领料单明细
                S_MaterialRequisitionGoods lnqMaterGoods = new S_MaterialRequisitionGoods();

                var varMaterialStock = from a in context.S_Stock
                                       where a.GoodsID == isolation.GoodsID &&
                                       a.BatchNo == isolation.BatchNo &&
                                       a.StorageID == isolation.StorageID &&
                                       a.Provider == isolation.Provider
                                       select a;

                S_Stock lnqStock = new S_Stock();

                if (varMaterialStock.Count() != 1)
                {
                    error = "数据不唯一或者为空";
                    return(false);
                }
                else
                {
                    lnqStock = varMaterialStock.Single();
                }

                lnqMaterGoods.BasicCount   = 0;
                lnqMaterGoods.BatchNo      = isolation.BatchNo;
                lnqMaterGoods.Bill_ID      = strBillID;
                lnqMaterGoods.GoodsID      = (int)isolation.GoodsID;
                lnqMaterGoods.ProviderCode = isolation.Provider;
                lnqMaterGoods.RealCount    = flag == "废弃数" ? isolation.QC_FQS : isolation.QC_BFS;
                lnqMaterGoods.Remark       = flag == "废弃数" ?
                                             "不合格品隔离处置单废弃处理,关联的隔离单号:  " + isolation.DJH
                    : "不合格品隔离处置单检测报废,关联的隔离单号:  " + isolation.DJH;
                lnqMaterGoods.RequestCount = flag == "废弃数" ? isolation.QC_FQS : isolation.QC_BFS;
                lnqMaterGoods.ShowPosition = 1;

                MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer();

                if (!serverMaterialGoods.AutoCreateGoods(context, lnqMaterGoods, out error))
                {
                    return(false);
                }

                context.SubmitChanges();

                #endregion

                serverMaterialBill.OpertaionDetailAndStock(context, lnqMater);
                context.SubmitChanges();

                m_assignBill.UseBillNo(CE_BillTypeEnum.领料单.ToString(), strBillID);

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }