/// <summary>
        /// 提交入库信息
        /// </summary>
        /// <param name="inDepotInfo">入库信息, 只取其中入库部分</param>
        /// <param name="returnInfo">添加完毕后查询数据库的返回结果</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作结果</returns>
        public bool SubmitInDepotInfo(S_OrdinaryInDepotBill inDepotInfo, out IQueryResult returnInfo, out string error)
        {
            returnInfo = null;
            error      = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from r in dataContxt.S_OrdinaryInDepotBill where r.Bill_ID == inDepotInfo.Bill_ID select r;

                if (result.Count() == 0)
                {
                    error = string.Format("找不到入库单号为 [{0}] 的普通入库单!", inDepotInfo.Bill_ID);
                    return(false);
                }

                S_OrdinaryInDepotBill bill = result.Single();

                if (bill.BillStatus == CheckInDepotBillStatus.已入库.ToString())
                {
                    error = string.Format("入库单号为 [{0}] 单据状态为已入库", inDepotInfo.Bill_ID);
                    return(false);
                }

                bill.DepotManager = inDepotInfo.DepotManager;
                bill.BillStatus   = inDepotInfo.BillStatus;
                bill.InDepotDate  = ServerTime.Time;

                // 添加信息到入库明细表
                OpertaionDetailAndStock(dataContxt, bill);

                //更新工装库存状态

                IDepotTypeForPersonnel serverDepot = ServerModuleFactory.GetServerModule <IDepotTypeForPersonnel>();

                if (serverDepot.GetDepotInfo(bill.Depot).DepotName == GlobalObject.CE_GoodsType.工装.ToString() &&
                    bill.Bill_Time > Convert.ToDateTime("2012-4-21") &&
                    !UpdateFrockStockStatus(dataContxt, bill.Bill_ID, out error))
                {
                    return(false);
                }

                // 正式使用单据号
                m_assignBill.UseBillNo(dataContxt, "普通入库单", bill.Bill_ID);

                dataContxt.SubmitChanges();

                return(GetAllBill(out returnInfo, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 完成自制件退货单
        /// </summary>
        /// <param name="billNo">自制件退货单据号</param>
        /// <param name="storeManager">仓库管理员</param>
        /// <param name="returnBill">返回更新后重新查询的自制件退货单数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功添加采购退货单</returns>
        public bool FinishBill(string billNo, string storeManager, out IQueryResult returnBill, out string error)
        {
            returnBill = null;
            error      = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from r in dataContxt.S_HomemadeRejectBill
                             where r.Bill_ID == billNo
                             select r;

                if (result.Count() == 0)
                {
                    error = string.Format("没有找到单据号为 {0} 的自制件退货单信息,无法进行此操作", billNo);
                    return(false);
                }

                S_HomemadeRejectBill bill = result.Single();

                if (bill.BillStatus == MaterialRejectBillBillStatus.已完成.ToString())
                {
                    error = "单据不能重复退货";
                    return(false);
                }

                bill.DepotManager = storeManager;
                bill.BillStatus   = MaterialRejectBillBillStatus.已完成.ToString();
                bill.OutDepotDate = ServerTime.Time;

                IHomemadeRejectBill goodsServer = ServerModuleFactory.GetServerModule <IHomemadeRejectBill>();

                //操作账务信息与库存信息
                OpertaionDetailAndStock(dataContxt, bill);

                //更新隔离单单据状态
                if (!UpdateIsolationBillStatus(dataContxt, billNo, out error))
                {
                    return(false);
                }

                // 正式使用单据号
                m_assignBill.UseBillNo(dataContxt, "自制件退货单", bill.Bill_ID);
                dataContxt.SubmitChanges();

                return(GetAllBill(out returnBill, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 提交入库信息
        /// </summary>
        /// <param name="inDepotInfo">入库信息, 只取其中入库部分</param>
        /// <param name="returnInfo">添加完毕后查询数据库的返回结果</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作结果</returns>
        public bool SubmitInDepotInfo(S_FrockInDepotBill inDepotInfo, out IQueryResult returnInfo, out string error)
        {
            returnInfo = null;
            error      = null;

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            try
            {
                var result = from r in dataContxt.S_FrockInDepotBill
                             where r.Bill_ID == inDepotInfo.Bill_ID
                             select r;

                if (result.Count() == 0)
                {
                    error = string.Format("找不到入库单号为 [{0}] 的自制件工装报检信息!", inDepotInfo.Bill_ID);
                    return(false);
                }

                S_FrockInDepotBill lnqBill = result.Single();

                if (lnqBill.Bill_Status.Equals("已入库"))
                {
                    error = string.Format("单据号为 [{0}] 单据状态为已入库", inDepotInfo.Bill_ID);
                    return(false);
                }

                lnqBill.DepotManager = inDepotInfo.DepotManager;
                lnqBill.Bill_Status  = inDepotInfo.Bill_Status;
                lnqBill.InDepotDate  = ServerTime.Time;

                //操作账务信息与库存信息
                OpertaionDetailAndStock(dataContxt, lnqBill);

                //更新工装库存状态
                if (!UpdateFrockStockStatus(dataContxt, lnqBill.Bill_ID, out error))
                {
                    return(false);
                }

                // 正式使用单据号
                m_assignBill.UseBillNo(dataContxt, CE_BillTypeEnum.自制件工装报检.ToString(), lnqBill.Bill_ID);

                dataContxt.SubmitChanges();

                return(GetAllBill(out returnInfo, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 完成单据
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="storeManager">仓库管理员</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool FinishBill(string billNo, string storeManager, out string error)
        {
            using (DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext)
            {
                try
                {
                    error = null;
                    dataContxt.Connection.Open();
                    dataContxt.Transaction = dataContxt.Connection.BeginTransaction();

                    var result = from r in dataContxt.S_ScrapBill where r.Bill_ID == billNo select r;

                    if (result.Count() == 0)
                    {
                        error = string.Format("没有找到单据号为 {0} 的报废单信息,无法进行此操作", billNo);
                        return(false);
                    }

                    S_ScrapBill bill = result.Single();

                    bill.DepotManager = storeManager;
                    bill.DepotTime    = ServerTime.Time;
                    bill.BillStatus   = ScrapBillStatus.已完成.ToString();

                    //操作账务信息与库存信息
                    OpertaionDetailAndStock(dataContxt, bill);

                    var goodsData = from a in dataContxt.S_ScrapGoods
                                    where a.Bill_ID == billNo &&
                                    a.ResponsibilityDepartment == "GYS"
                                    select a;

                    if (goodsData.Count() > 0)
                    {
                        goodsData = from a in dataContxt.S_ScrapGoods
                                    where a.Bill_ID == billNo &&
                                    a.ResponsibilityDepartment != "GYS"
                                    select a;

                        if (goodsData.Count() > 0)
                        {
                            throw new Exception("【责任部门】有误,请回退单据到新建人员进行修改");
                        }

                        InsertReturnBill(dataContxt, billNo);
                        InsertRejectBill(dataContxt, billNo);
                    }

                    // 正式使用单据号
                    m_assignBill.UseBillNo(dataContxt, "报废单", bill.Bill_ID);
                    dataContxt.SubmitChanges();

                    dataContxt.Transaction.Commit();

                    return(true);
                }
                catch (Exception err)
                {
                    error = err.Message;
                    dataContxt.Transaction.Rollback();
                    return(false);
                }
            }
        }
        /// <summary>
        /// 有检测废的物品直接生成领料单
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="inDepotInfo">自制件入库单信息</param>
        /// <param name="mrBillNo">分配的领料单单号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool InsertIntoMaterialRequisition(DepotManagementDataContext ctx, S_HomemadePartBill inDepotInfo,
                                                  out string mrBillNo, out string error)
        {
            error    = null;
            mrBillNo = null;
            string billNo = null;
            MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer();

            billNo = m_assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

            mrBillNo = billNo;

            try
            {
                var varData = from a in ctx.S_MaterialRequisition
                              where a.Bill_ID == billNo
                              select a;

                S_MaterialRequisition lnqMaterial = null;

                if (varData.Count() != 0)
                {
                    error = string.Format("自动生成的报废物品领料单单号 {0} 已被占用,请尝试重新进行此操作,再三出现无法生成可用的单号时与管理员联系", billNo);
                    return(false);
                }
                else
                {
                    lnqMaterial = new S_MaterialRequisition();

                    lnqMaterial.Bill_ID             = billNo;
                    lnqMaterial.Bill_Time           = ServerModule.ServerTime.Time;
                    lnqMaterial.AssociatedBillNo    = "";
                    lnqMaterial.AssociatedBillType  = "";
                    lnqMaterial.BillStatus          = "已出库";
                    lnqMaterial.Department          = "ZK01";
                    lnqMaterial.DepartmentDirector  = "";
                    lnqMaterial.DepotManager        = "";
                    lnqMaterial.FetchCount          = 0;
                    lnqMaterial.FetchType           = "零星领料";
                    lnqMaterial.FillInPersonnel     = inDepotInfo.QualityInputer;
                    lnqMaterial.FillInPersonnelCode = UniversalFunction.GetPersonnelInfo(inDepotInfo.QualityInputer).工号;
                    lnqMaterial.ProductType         = "";
                    lnqMaterial.PurposeCode         = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.破坏性检测).Code;
                    lnqMaterial.Remark    = "因入库零件进行了破坏性检测,由系统自动生成的破坏件领料单,对应单据号:" + inDepotInfo.Bill_ID;
                    lnqMaterial.StorageID = inDepotInfo.StorageID;

                    if (!serverMaterialBill.AutoCreateBill(ctx, lnqMaterial, out error))
                    {
                        return(false);
                    }
                    //ctx.S_MaterialRequisition.InsertOnSubmit(lnqMaterial);
                }

                var varDataList = from a in ctx.S_MaterialRequisitionGoods
                                  where a.Bill_ID == billNo
                                  select a;

                if (varDataList.Count() != 0)
                {
                    error = "此单据号已被占用";
                    return(false);
                }
                else
                {
                    S_MaterialRequisitionGoods lnqMaterialGoods = new S_MaterialRequisitionGoods();

                    lnqMaterialGoods.Bill_ID      = billNo;
                    lnqMaterialGoods.BasicCount   = 0;
                    lnqMaterialGoods.BatchNo      = inDepotInfo.BatchNo;
                    lnqMaterialGoods.GoodsID      = inDepotInfo.GoodsID;
                    lnqMaterialGoods.ProviderCode = inDepotInfo.Provider;
                    lnqMaterialGoods.RealCount    = Convert.ToDecimal(inDepotInfo.DeclareWastrelCount);
                    lnqMaterialGoods.Remark       = "";
                    lnqMaterialGoods.RequestCount = Convert.ToDecimal(inDepotInfo.DeclareWastrelCount);
                    lnqMaterialGoods.ShowPosition = 1;

                    MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer();

                    if (!serverMaterialGoods.AutoCreateGoods(ctx, lnqMaterialGoods, out error))
                    {
                        return(false);
                    }
                    //ctx.S_MaterialRequisitionGoods.InsertOnSubmit(lnqMaterialGoods);
                }

                ctx.SubmitChanges();

                if (!serverMaterialBill.FinishBill(ctx, lnqMaterial.Bill_ID, "", out error))
                {
                    throw new Exception(error);
                }

                ctx.SubmitChanges();

                return(m_assignBill.UseBillNo(CE_BillTypeEnum.领料单.ToString(), billNo));
            }
            catch (Exception ex)
            {
                serverMaterialBill.DeleteBill(billNo, out error);
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 完成采购退货单
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="storeManager">仓库管理员</param>
        /// <param name="returnBill">返回更新后重新查询的采购退货单数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功添加采购退货单</returns>
        public bool FinishBill(string billNo, string storeManager, out IQueryResult returnBill, out string error)
        {
            returnBill = null;
            error      = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from r in dataContxt.S_MaterialRejectBill
                             where r.Bill_ID == billNo
                             select r;

                if (result.Count() == 0)
                {
                    error = string.Format("没有找到单据号为 {0} 的采购退货单信息,无法进行此操作", billNo);
                    return(false);
                }

                //if (!CheckBillIsInIsolationManageBill(billNo,out error))
                //{
                //    return false;
                //}

                S_MaterialRejectBill bill = result.Single();

                if (bill.BillStatus == MaterialRejectBillBillStatus.已完成.ToString())
                {
                    error = "单据不能重复退货";
                    return(false);
                }

                bill.DepotManager = storeManager;
                bill.BillStatus   = MaterialRejectBillBillStatus.已完成.ToString();
                bill.OutDepotDate = ServerTime.Time;

                if (bill.BillType.ToString() == "总仓库退货单")
                {
                    //操作账务信息与库存信息
                    OpertaionDetailAndStock(dataContxt, bill);

                    ////更新隔离单单据状态
                    //if (!UpdateIsolationBillStatus(dataContxt, billNo, out error))
                    //{
                    //    return false;
                    //}
                }
                else
                {
                    if (!SetScrapFlag(dataContxt, bill.Bill_ID, out error))
                    {
                        return(false);
                    }
                }

                // 正式使用单据号
                m_assignBill.UseBillNo(dataContxt, "采购退货单", bill.Bill_ID);

                dataContxt.SubmitChanges();

                return(GetAllBill(out returnBill, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Beispiel #7
0
 /// <summary>
 /// 使用单据号
 /// </summary>
 /// <param name="billNo">要使用的单据号</param>
 public void UseBill(string billNo)
 {
     m_assignBill.UseBillNo(m_billType.ToString(), billNo);
 }
Beispiel #8
0
        /// <summary>
        /// 自动生成领料退库单
        /// </summary>
        /// <param name="contxt">数据上下文</param>
        /// <param name="djh">单据号</param>
        void CreateMaterialReturnedInTheDepot(DepotManagementDataContext contxt, string djh)
        {
            MaterialReturnedInTheDepot serverReturnedBill = new MaterialReturnedInTheDepot();

            try
            {
                string strBillID = m_assignBill.AssignNewNo(serverReturnedBill, 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_MaterialReturnedInTheDepot   lnqReturnedInTheDepot = new S_MaterialReturnedInTheDepot();

                if (listInfo.Count > 0)
                {
                    #region 领料退库单主表
                    lnqReturnedInTheDepot.Bill_ID             = strBillID;
                    lnqReturnedInTheDepot.Bill_Time           = ServerTime.Time;
                    lnqReturnedInTheDepot.BillStatus          = "已完成";
                    lnqReturnedInTheDepot.Department          = "ZZ05";
                    lnqReturnedInTheDepot.DepartmentDirector  = UniversalFunction.GetPersonnelInfo(contxt, billInfo.SHRY).姓名;
                    lnqReturnedInTheDepot.DepotManager        = BasicInfo.LoginName;
                    lnqReturnedInTheDepot.FillInPersonnel     = UniversalFunction.GetPersonnelInfo(contxt, billInfo.BZRY).姓名;
                    lnqReturnedInTheDepot.FillInPersonnelCode = billInfo.BZRY;
                    lnqReturnedInTheDepot.InDepotDate         = ServerTime.Time;
                    lnqReturnedInTheDepot.PurposeCode         = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.盘点).Code;
                    lnqReturnedInTheDepot.QualityInputer      = "";
                    lnqReturnedInTheDepot.Remark       = "库房盘点(盘盈)";
                    lnqReturnedInTheDepot.ReturnMode   = "领料退库";
                    lnqReturnedInTheDepot.ReturnReason = "库房盘点(盘盈)";
                    lnqReturnedInTheDepot.ReturnType   = null;
                    lnqReturnedInTheDepot.StorageID    = billInfo.StorageID;

                    contxt.S_MaterialReturnedInTheDepot.InsertOnSubmit(lnqReturnedInTheDepot);

                    #endregion

                    foreach (View_S_StorageCheckList listSingle in listInfo)
                    {
                        #region 领料单退库明细
                        S_MaterialListReturnedInTheDepot lnqReturnedInTheDepotList = new S_MaterialListReturnedInTheDepot();

                        lnqReturnedInTheDepotList.BatchNo         = listSingle.批次号;
                        lnqReturnedInTheDepotList.Bill_ID         = strBillID;
                        lnqReturnedInTheDepotList.ColumnNumber    = listSingle.列;
                        lnqReturnedInTheDepotList.GoodsID         = (int)listSingle.物品ID;
                        lnqReturnedInTheDepotList.LayerNumber     = listSingle.层;
                        lnqReturnedInTheDepotList.Provider        = listSingle.供货单位;
                        lnqReturnedInTheDepotList.ProviderBatchNo = listSingle.供方批次号;
                        lnqReturnedInTheDepotList.Remark          = "库房盘点(盘亏)";
                        lnqReturnedInTheDepotList.ReturnedAmount  = (decimal)listSingle.盈亏数量;
                        lnqReturnedInTheDepotList.ShelfArea       = listSingle.货架;

                        contxt.S_MaterialListReturnedInTheDepot.InsertOnSubmit(lnqReturnedInTheDepotList);

                        #endregion
                    }

                    contxt.SubmitChanges();

                    serverReturnedBill.OpertaionDetailAndStock(contxt, lnqReturnedInTheDepot);
                    contxt.SubmitChanges();

                    m_assignBill.UseBillNo(CE_BillTypeEnum.领料退库单.ToString(), strBillID);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #9
0
        /// <summary>
        /// 确认防锈
        /// </summary>
        /// <param name="goodsTable">需要执行的物品数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>True 成功 false  失败</returns>
        public bool AuthorizeAntirustInfo(DataTable goodsTable, out string error)
        {
            error = null;
            MaterialRequisitionServer  serverMaterialBill = new MaterialRequisitionServer();
            DepotManagementDataContext contxt             = CommentParameter.DepotDataContext;

            contxt.Connection.Open();
            contxt.Transaction = contxt.Connection.BeginTransaction();
            try
            {
                DataTable dtTemp = GlobalObject.DataSetHelper.SelectDistinct("", goodsTable, "库房ID");

                for (int k = 0; k < dtTemp.Rows.Count; k++)
                {
                    DataTable dtgoodsTable =
                        GlobalObject.DataSetHelper.SiftDataTable(goodsTable, "库房ID = '" + dtTemp.Rows[k][0].ToString() + "'", out error);

                    if (error != null)
                    {
                        throw new Exception(error);
                    }

                    string billID = m_assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

                    for (int i = 0; i < dtgoodsTable.Rows.Count; i++)
                    {
                        var varStock = from a in contxt.S_Stock
                                       where a.GoodsID == (int)dtgoodsTable.Rows[i]["物品ID"] &&
                                       a.BatchNo == dtgoodsTable.Rows[i]["批次号"].ToString() &&
                                       a.StorageID == dtgoodsTable.Rows[i]["库房ID"].ToString() &&
                                       a.Provider == dtgoodsTable.Rows[i]["供应商"].ToString()
                                       select a;

                        var varAntirust = from a in contxt.KF_GoodsAntirust
                                          where a.GoodsID == (int)dtgoodsTable.Rows[i]["物品ID"] &&
                                          a.BatchNo == dtgoodsTable.Rows[i]["批次号"].ToString() &&
                                          a.StorageID == dtgoodsTable.Rows[i]["库房ID"].ToString() &&
                                          a.Provider == dtgoodsTable.Rows[i]["供应商"].ToString()
                                          select a;

                        if (varStock.Count() != 1)
                        {
                            error = "数据不唯一或者为空";
                            throw new Exception(error);
                        }
                        else
                        {
                            S_Stock lnqStock = varStock.Single();

                            KF_GoodsAntirust lnqAntirust = varAntirust.Single();

                            if (Convert.ToDecimal(lnqAntirust.AntirustUnqualifiedCount) > 0)
                            {
                                if (!CreateMaterialRequisitionGoods(contxt, lnqAntirust, billID, out error))
                                {
                                    throw new Exception(error);
                                }
                            }

                            lnqAntirust.AntirustUnqualifiedCount = 0;
                            lnqAntirust.AuthorizePersonnel       = BasicInfo.LoginName;

                            if (lnqAntirust.AntirustState.ToString() == "等待确认")
                            {
                                lnqAntirust.AntirustDate  = ServerTime.Time;
                                lnqAntirust.AntirustState = "未防锈";
                            }
                            else
                            {
                                error = "状态不符,请重新确认";
                                throw new Exception(error);
                            }
                        }
                    }

                    contxt.SubmitChanges();

                    var requistionVar = from a in contxt.S_MaterialRequisition
                                        where a.Bill_ID == billID
                                        select a;

                    IMaterialRequisitionServer requisitionService = ServerModule.ServerModuleFactory.GetServerModule <IMaterialRequisitionServer>();

                    requisitionService.OpertaionDetailAndStock(contxt, requistionVar.Single());

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

                contxt.SubmitChanges();
                contxt.Transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                contxt.Transaction.Rollback();
                error = ex.Message;
                return(false);
            }
        }
Beispiel #10
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);
            }
        }
        /// <summary>
        /// 完成领料退库单
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="storeManager">仓库管理员</param>
        /// <param name="returnBill">返回更新后重新查询的领料退库单数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功添加领料退库单</returns>
        public bool FinishBill(string billNo, string storeManager, out IQueryResult returnBill, out string error)
        {
            returnBill = null;
            error      = null;

            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                if (!FinishFrock(ctx, billNo, out error))
                {
                    return(false);
                }

                //检查总成领用数量是否都设置了流水码
                if (!m_serverProductCode.IsFitCountInReturnBill(billNo, out error))
                {
                    return(false);
                }

                var result = from r in ctx.S_MaterialReturnedInTheDepot where r.Bill_ID == billNo select r;

                if (result.Count() == 0)
                {
                    error = string.Format("没有找到单据号为 {0} 的领料退库单信息,无法进行此操作", billNo);
                    return(false);
                }

                S_MaterialReturnedInTheDepot bill = result.Single();

                if (bill.BillStatus == MaterialReturnedInTheDepotBillStatus.已完成.ToString())
                {
                    error = "单据不能重复退库";
                    return(false);
                }

                bill.DepotManager = storeManager;
                bill.BillStatus   = MaterialReturnedInTheDepotBillStatus.已完成.ToString();
                bill.InDepotDate  = ServerTime.Time;

                if (bill.ReturnMode == "领料退库")
                {
                    DetailCheck(ctx, bill);//在退库模式为领料退库的模式情况下,只能退库房存在的库存记录的物品
                }

                IMaterialListReturnedInTheDepot goodsServer = ServerModuleFactory.GetServerModule <IMaterialListReturnedInTheDepot>();

                //操作账务信息与库存信息
                OpertaionDetailAndStock(ctx, bill);

                //操作总成库存状态
                var varList = from a in ctx.S_MaterialListReturnedInTheDepot
                              where a.Bill_ID == bill.Bill_ID
                              select a;

                foreach (var item in varList)
                {
                    bool blIsRepaired = false;

                    if (bill.StorageID == "05" && Convert.ToBoolean(item.RepairStatus))
                    {
                        blIsRepaired = true;
                    }

                    if (!m_serverProductCode.UpdateProductStock(ctx, bill.Bill_ID, "领料退库", bill.StorageID, blIsRepaired, item.GoodsID, out error))
                    {
                        return(false);
                    }

                    IStoreServer serverStore = ServerModuleFactory.GetServerModule <IStoreServer>();

                    YX_AfterServiceStock lnqAfterService = new YX_AfterServiceStock();

                    lnqAfterService.GoodsID        = item.GoodsID;
                    lnqAfterService.OperationCount = Convert.ToDecimal(item.ReturnedAmount);
                    lnqAfterService.RepairStatus   = Convert.ToBoolean(item.RepairStatus);
                    lnqAfterService.StorageID      = bill.StorageID;

                    if (!serverStore.OperationYXAfterService(ctx, lnqAfterService, out error))
                    {
                        return(false);
                    }
                }

                // 正式使用单据号
                m_assignBill.UseBillNo(ctx, "领料退库单", bill.Bill_ID);

                ctx.SubmitChanges();

                return(GetAllBill(out returnBill, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Beispiel #12
0
        /// <summary>
        /// 插入报废单
        /// </summary>
        /// <param name="ctx">LINQ数据上下文</param>
        /// <param name="outSourcing">Linq操作数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>插入成功返回True,插入失败返回False</returns>
        public bool AddScrapBill(DepotManagementDataContext ctx,
                                 S_CheckOutInDepotForOutsourcingBill outSourcing, out string error)
        {
            error = null;
            string strBillID = "";

            try
            {
                ScrapBillServer serverScrapBill = new ScrapBillServer();

                S_ScrapBill lnqBill = new S_ScrapBill();

                strBillID = m_assignBill.AssignNewNo(serverScrapBill, CE_BillTypeEnum.报废单.ToString());

                lnqBill.AuthorizeTime     = ServerTime.Time;
                lnqBill.Bill_ID           = strBillID;
                lnqBill.Bill_Time         = ServerTime.Time;
                lnqBill.BillStatus        = "已完成";
                lnqBill.Checker           = outSourcing.Checker;
                lnqBill.DeclareDepartment = m_serverDepartment.GetDeptInfoFromPersonnelInfo(
                    outSourcing.DeclarePersonnel).Rows[0]["DepartmentCode"].ToString();
                lnqBill.DepartmentDirector  = "";
                lnqBill.DepotManager        = outSourcing.ManagerPersonnel;
                lnqBill.DepotTime           = ServerTime.Time;
                lnqBill.FillInPersonnel     = outSourcing.DeclarePersonnel;
                lnqBill.FillInPersonnelCode = UniversalFunction.GetPersonnelCode(outSourcing.DeclarePersonnel);
                lnqBill.NotifyChecker       = UniversalFunction.GetPersonnelCode(outSourcing.Checker);
                lnqBill.ProductType         = "";
                lnqBill.Remark   = "关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成";
                lnqBill.Sanction = outSourcing.Checker;

                ctx.S_ScrapBill.InsertOnSubmit(lnqBill);

                S_ScrapGoods lnqGoods = new S_ScrapGoods();

                lnqGoods.BatchNo  = outSourcing.BatchNo;
                lnqGoods.Bill_ID  = strBillID;
                lnqGoods.GoodsID  = outSourcing.GoodsID;
                lnqGoods.Provider = outSourcing.Provider;
                lnqGoods.Quantity = outSourcing.DeclareWastrelCount;
                lnqGoods.Reason   = "检测报废,关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成";
                lnqGoods.Remark   = "检测报废,关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成";
                lnqGoods.ResponsibilityDepartment = "GYS";
                lnqGoods.ResponsibilityProvider   = outSourcing.Provider;
                lnqGoods.ResponsibilityType       = "返 修 废";
                lnqGoods.UnitPrice    = 0;
                lnqGoods.WastrelType  = 9;
                lnqGoods.WorkingHours = 0;

                ctx.S_ScrapGoods.InsertOnSubmit(lnqGoods);

                m_assignBill.UseBillNo(CE_BillTypeEnum.报废单.ToString(), strBillID);

                return(true);
            }
            catch (Exception ex)
            {
                m_assignBill.CancelBillNo(CE_BillTypeEnum.报废单.ToString(), strBillID);
                error = ex.Message;
                return(false);
            }
        }