Beispiel #1
0
        /// <summary>
        /// 赋值库存信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回库存信息对象</returns>
        public S_Stock AssignStockInfo(DepotManagementDataContext context, S_MaterialRequisition bill,
                                       S_MaterialRequisitionGoods item)
        {
            F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfo(context, item.GoodsID);

            if (item.RealCount == 0)
            {
                throw new Exception(string.Format("图号:{0}, 名称:{1}, 规格:{2}, 供应商:{3}, 批次号:{4} 的物品实领数为0,请重新输入!",
                                                  basicGoods.GoodsCode, basicGoods.GoodsName, basicGoods.Spec, item.ProviderCode, item.BatchNo));
            }

            S_Stock stockInfo = new S_Stock();

            stockInfo.GoodsID = item.GoodsID;

            if (basicGoods != null)
            {
                stockInfo.GoodsCode = basicGoods.GoodsCode;
                stockInfo.GoodsName = basicGoods.GoodsName;
                stockInfo.Spec      = basicGoods.Spec;
            }

            stockInfo.ExistCount = item.RealCount;
            stockInfo.Provider   = item.ProviderCode;
            stockInfo.BatchNo    = item.BatchNo;
            stockInfo.StorageID  = bill.StorageID;

            if (item.Remark != null && item.Remark.Contains("无线领料"))
            {
                item.Remark = item.Remark.Replace(",无线领料", "");
                item.Remark = item.Remark.Replace("无线领料", "");  // 防止用户把前面的逗号删除
            }

            return(stockInfo);
        }
Beispiel #2
0
        /// <summary>
        /// 生成领料单明细
        /// </summary>
        /// <param name="dataContxt">LINQ数据上下文</param>
        /// <param name="antirust">防锈物品信息</param>
        /// <param name="billID">单据号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回True,操作失败返回False</returns>
        public bool CreateMaterialRequisitionGoods(DepotManagementDataContext dataContxt,
                                                   KF_GoodsAntirust antirust, string billID, out string error)
        {
            error = null;

            try
            {
                S_MaterialRequisitionGoods lnqMaterGoods = new S_MaterialRequisitionGoods();

                lnqMaterGoods.BasicCount   = 0;
                lnqMaterGoods.BatchNo      = antirust.BatchNo;
                lnqMaterGoods.Bill_ID      = billID;
                lnqMaterGoods.GoodsID      = (int)antirust.GoodsID;
                lnqMaterGoods.ProviderCode = antirust.Provider;
                lnqMaterGoods.RealCount    = Convert.ToDecimal(antirust.AntirustUnqualifiedCount);
                lnqMaterGoods.Remark       = "由防锈报废自动生成";
                lnqMaterGoods.RequestCount = Convert.ToDecimal(antirust.AntirustUnqualifiedCount);
                lnqMaterGoods.ShowPosition = 1;

                MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer();

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

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 接收事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="re">事件参数</param>
        public Socket_FetchMaterial ReceiveSaveBarCodeInfo(Socket_FetchMaterial fetchMaterialInfo)
        {
            string error;

            S_MaterialRequisitionGoods goods = new S_MaterialRequisitionGoods();

            View_F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfo(
                fetchMaterialInfo.GoodsCode, fetchMaterialInfo.GoodsName, fetchMaterialInfo.Spec, out error);

            goods.Bill_ID      = fetchMaterialInfo.BillID;
            goods.GoodsID      = basicGoods.序号;
            goods.ProviderCode = fetchMaterialInfo.Provider;
            goods.BatchNo      = fetchMaterialInfo.BatchNo;
            goods.RealCount    = fetchMaterialInfo.FactCount;

            if (!m_requestMaterialServer.UpdateyGoodsFromWireless(goods, out error))
            {
                fetchMaterialInfo.FetchState = Socket_FetchMaterial.FetchStateEnum.更新领料清单失败;
            }
            else
            {
                fetchMaterialInfo.FetchState = Socket_FetchMaterial.FetchStateEnum.操作成功;
            }

            return(fetchMaterialInfo);
        }
Beispiel #4
0
        /// <summary>
        /// 由无线接收信息更新实际领取物品的信息
        /// </summary>
        /// <param name="goods">物品信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回操作是否成功的标志</returns>
        public bool UpdateyGoodsFromWireless(S_MaterialRequisitionGoods goods, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var result = from r in ctx.S_MaterialRequisitionGoods
                             where r.Bill_ID == goods.Bill_ID && r.GoodsID == goods.GoodsID
                             select r;

                if (result.Count() > 0)
                {
                    var findGoods = from r in result
                                    where r.ProviderCode == goods.ProviderCode && r.BatchNo.Contains(goods.BatchNo)
                                    select r;

                    if (findGoods.Count() > 0)
                    {
                        S_MaterialRequisitionGoods info = findGoods.Single();

                        info.RealCount = goods.RealCount;

                        if (!info.Remark.Contains("无线领料"))
                        {
                            info.Remark = string.Format("{0},无线领料", findGoods.Single().Remark);
                        }
                    }
                    else
                    {
                        if (!result.Single().Remark.Contains("无线领料"))
                        {
                            goods.Remark = string.Format("{0},无线领料", result.Single().Remark);
                        }
                        else
                        {
                            goods.Remark = result.Single().Remark;
                        }

                        ctx.S_MaterialRequisitionGoods.InsertOnSubmit(goods);
                    }

                    ctx.SubmitChanges();
                    return(true);
                }
                else
                {
                    error = "领料单中不存在此物品";
                    return(false);
                }
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 更新物品信息
 /// </summary>
 /// <param name="goods">物品信息</param>
 /// <param name="error">出错时返回错误信息,无错时返回null</param>
 /// <returns>返回操作是否成功的标志</returns>
 public bool UpdateGoods(S_MaterialRequisitionGoods goods, out string error)
 {
     try
     {
         error = null;
         DepotManagementDataContext ctx = CommentParameter.DepotDataContext;
         OperationDetailInfo(ctx, goods.Bill_ID, goods, CE_OperatorMode.修改);
         ctx.SubmitChanges();
         return(true);
     }
     catch (Exception exce)
     {
         error = exce.Message;
         return(false);
     }
 }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (customDataGridView1.Rows.Count == 0)
            {
                MessageDialog.ShowPromptMessage("请在条码录入框内扫入需要领用的物料条码");
                return;
            }

            try
            {
                List <string> lstType = serviceRequistion.GetBoardIssueInfo(null).Select(k => k.IssueType).Distinct().ToList();

                foreach (string issueType in lstType)
                {
                    List <S_MaterialRequisition_BoardIssue> listIssue    = serviceRequistion.GetBoardIssueInfo(issueType);
                    List <S_MaterialRequisitionGoods>       lstGoodsInfo = new List <S_MaterialRequisitionGoods>();

                    foreach (S_MaterialRequisition_BoardIssue boardIssue in listIssue)
                    {
                        S_MaterialRequisitionGoods goodsInfo = new S_MaterialRequisitionGoods();

                        goodsInfo.GoodsID      = Convert.ToInt32(boardIssue.BarCode.Substring(0, 6));
                        goodsInfo.RequestCount = Convert.ToDecimal(boardIssue.BarCode.Substring(6, 5));
                        goodsInfo.Remark       = boardIssue.Remark;

                        lstGoodsInfo.Add(goodsInfo);
                    }

                    serviceRequistion.AutoCreateBoardPicking(lstGoodsInfo, issueType, UniversalFunction.GetStorageID(cmbStorageID.Text));
                    serviceRequistion.DeleteBoardIssue(issueType);
                }

                MessageDialog.ShowPromptMessage("生成完成");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return;
            }
        }
Beispiel #7
0
        /// <summary>
        /// 插入领料明细
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="listInfo">明细LINQ数据集</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AutoCreateGoods(DepotManagementDataContext ctx, S_MaterialRequisitionGoods listInfo, out string error)
        {
            error = null;

            try
            {
                if (BillIsFinish(ctx, listInfo.Bill_ID))
                {
                    throw new Exception("单据已完成,无法进行操作");
                }

                ctx.S_MaterialRequisitionGoods.InsertOnSubmit(listInfo);

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Beispiel #8
0
        public void InsertInfoExcel(string billNo, DataTable infoTable)
        {
            IMaterialRequisitionServer billServer    = ServerModuleFactory.GetServerModule <IMaterialRequisitionServer>();
            BillNumberControl          billNoControl = new BillNumberControl("领料单", billServer);
            DepotManagementDataContext ctx           = CommentParameter.DepotDataContext;

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

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

            try
            {
                List <string> lstStorage = new List <string>();

                if (infoTable.Columns.Contains("库房"))
                {
                    lstStorage = DataSetHelper.ColumnsToList_Distinct(infoTable, "库房");

                    foreach (string storage in lstStorage)
                    {
                        string temp = UniversalFunction.GetStorageID(storage);

                        if (temp.Trim().Length == 0)
                        {
                            throw new Exception("【库房名称】:" + storage + "有误, 无法匹配到库房ID");
                        }
                    }
                }

                if (!infoTable.Columns.Contains("物品ID"))
                {
                    infoTable.Columns.Add("物品ID");

                    foreach (DataRow dr in infoTable.Rows)
                    {
                        int goodsID = UniversalFunction.GetGoodsID(dr["图号型号"] == null ? "" : dr["图号型号"].ToString(),
                                                                   dr["物品名称"] == null ? "" : dr["物品名称"].ToString(),
                                                                   dr["规格"] == null ? "" : dr["规格"].ToString());

                        if (goodsID == 0)
                        {
                            throw new Exception(string.Format("【图号型号】:{0} 【物品名称】:{1} 【规格】:{2}有误," +
                                                              " 无法匹配到物品ID", dr["图号型号"], dr["物品名称"], dr["规格"]));
                        }

                        dr["物品ID"] = goodsID;
                    }
                }

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

                if (varData.Count() != 1)
                {
                    throw new Exception("无法获取【单据号】: " + billNo + " 的基本信息");
                }

                S_MaterialRequisition requisition = varData.Single();

                if (BillIsFinish(ctx, requisition.Bill_ID))
                {
                    throw new Exception("单据已完成,无法进行操作");
                }

                if (lstStorage.Count == 0)
                {
                    lstStorage.Add(UniversalFunction.GetStorageName(requisition.StorageID));
                }

                foreach (string storage in lstStorage)
                {
                    DataTable tempTable = infoTable;

                    if (lstStorage.Count > 1)
                    {
                        tempTable = DataSetHelper.SiftDataTable(infoTable, "库房 = '" + storage + "'");
                    }

                    string tempBillNo = "";
                    string storageID  = UniversalFunction.GetStorageID(storage);

                    if (requisition.StorageID != storageID)
                    {
                        S_MaterialRequisition tempRequisition = new S_MaterialRequisition();

                        tempBillNo = billNoControl.GetNewBillNo(ctx);

                        tempRequisition.Bill_ID             = tempBillNo;
                        tempRequisition.AssociatedBillNo    = requisition.AssociatedBillNo;
                        tempRequisition.AssociatedBillType  = requisition.AssociatedBillType;
                        tempRequisition.AuthorizeDate       = requisition.AuthorizeDate;
                        tempRequisition.AuthorizePersonnel  = requisition.AuthorizePersonnel;
                        tempRequisition.Bill_Time           = requisition.Bill_Time;
                        tempRequisition.BillStatus          = requisition.BillStatus;
                        tempRequisition.Department          = requisition.Department;
                        tempRequisition.DepartmentDirector  = requisition.DepartmentDirector;
                        tempRequisition.DepotManager        = requisition.DepotManager;
                        tempRequisition.FetchCount          = requisition.FetchCount;
                        tempRequisition.FetchType           = requisition.FetchType;
                        tempRequisition.FillInPersonnel     = requisition.FillInPersonnel;
                        tempRequisition.FillInPersonnelCode = requisition.FillInPersonnelCode;
                        tempRequisition.OutDepotDate        = requisition.OutDepotDate;
                        tempRequisition.ProductType         = requisition.ProductType;
                        tempRequisition.PurposeCode         = requisition.PurposeCode;
                        tempRequisition.Remark                = requisition.Remark;
                        tempRequisition.StorageID             = storageID;
                        tempRequisition.TechnologistDate      = requisition.TechnologistDate;
                        tempRequisition.TechnologistPersonnel = requisition.TechnologistPersonnel;

                        ctx.S_MaterialRequisition.InsertOnSubmit(tempRequisition);
                        ctx.SubmitChanges();
                    }
                    else
                    {
                        tempBillNo = billNo;
                    }

                    foreach (DataRow dr in tempTable.Rows)
                    {
                        S_MaterialRequisitionGoods goodsInfo = new S_MaterialRequisitionGoods();

                        goodsInfo.RequestCount = dr["数量"] == null ? 0 : Convert.ToDecimal(dr["数量"]);
                        goodsInfo.BatchNo      = dr["批次号"] == null ? "" : dr["批次号"].ToString();

                        if (dr["物品ID"] == null || Convert.ToInt32(dr["物品ID"]) == 0)
                        {
                            throw new Exception("【物品ID】无效");
                        }

                        goodsInfo.GoodsID = Convert.ToInt32(dr["物品ID"]);
                        goodsInfo.Bill_ID = tempBillNo;

                        StoreQueryCondition condition = new StoreQueryCondition();

                        condition.BatchNo   = goodsInfo.BatchNo;
                        condition.GoodsID   = goodsInfo.GoodsID;
                        condition.StorageID = storageID;

                        S_Stock stockInfo = storeService.GetStockInfo(condition);

                        if (stockInfo == null)
                        {
                            throw new Exception(string.Format("【物品ID】:{0} 【批次号】:{1} 【库房】:{2} 未找到匹配的库存记录",
                                                              goodsInfo.GoodsID, goodsInfo.BatchNo, storage));
                        }

                        goodsInfo.ProviderCode = stockInfo.Provider;
                        goodsInfo.BasicCount   = 0;
                        goodsInfo.Remark       = "由Excel导入";
                        goodsInfo.RepairStatus = null;
                        goodsInfo.RealCount    = goodsInfo.RequestCount;
                        goodsInfo.ShowPosition = 1;

                        ctx.S_MaterialRequisitionGoods.InsertOnSubmit(goodsInfo);
                        ctx.SubmitChanges();
                    }
                }

                ctx.SubmitChanges();
                ctx.Transaction.Commit();
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }
Beispiel #9
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        public S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialRequisition bill,
                                                       S_MaterialRequisitionGoods item)
        {
            IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
            BASE_BillType   billType = server.GetBillTypeFromName("领料单");

            if (billType == null)
            {
                throw new Exception("获取不到单据类型信息");
            }

            View_Department           department       = UniversalFunction.GetDeptInfo(context, bill.Department);
            IStoreServer              storeServer      = ServerModuleFactory.GetServerModule <IStoreServer>();
            IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>();
            F_GoodsPlanCost           basicGoods       = m_basicGoodsServer.GetGoodsInfo(context, item.GoodsID);

            if (basicGoods == null)
            {
                throw new Exception(string.Format("物品ID [{0}] 的物品在基础物品表中没有查到,请与系统管理员联系!", item.GoodsID));
            }

            StoreQueryCondition condition = new StoreQueryCondition();

            condition.GoodsID   = item.GoodsID;
            condition.Provider  = item.ProviderCode;
            condition.BatchNo   = item.BatchNo;
            condition.StorageID = bill.StorageID;

            S_Stock stock = storeServer.GetStockInfoOverLoad(context, condition);

            if (stock == null && GlobalObject.GeneralFunction.IsNullOrEmpty(basicGoods.GoodsType))
            {
                throw new Exception(string.Format("图号:{0}, 名称:{1}, 规格:{2}, 供应商:{3}, 批次号:{4} 的物品在库存中没有查到相关物品,请仓管员核实!",
                                                  basicGoods.GoodsCode, basicGoods.GoodsName, basicGoods.Spec, item.ProviderCode, item.BatchNo));
            }

            //S_FetchGoodsDetailBill用于存放每次领料、领料退库的明细信息
            decimal dcRealCount = item.RealCount;
            decimal dcSumCount  = 0;

            var varData = from a in context.View_S_MaterialRequisitionProductReturnList
                          where a.单据号 == item.Bill_ID &&
                          a.还账物品ID == item.GoodsID &&
                          a.还账物品批次号 == item.BatchNo &&
                          a.还账物品供应商 == item.ProviderCode
                          select a;

            if (varData.Count() > 0)
            {
                dcSumCount = varData.Sum(a => a.还账数量);

                if (dcRealCount < dcSumCount)
                {
                    throw new Exception("实际领用数量不能大于还货数量,请重新核对");
                }
            }

            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            detailBill.ID                 = Guid.NewGuid();
            detailBill.FetchBIllID        = bill.Bill_ID;
            detailBill.BillTime           = (DateTime)bill.OutDepotDate;
            detailBill.AssociatedBillType = bill.AssociatedBillType;
            detailBill.AssociatedBillNo   = bill.AssociatedBillNo;
            detailBill.Department         = department.部门名称;
            detailBill.FetchCount         = item.RealCount;
            detailBill.GoodsID            = item.GoodsID;
            detailBill.StorageID          = bill.StorageID;
            detailBill.Price              = dcSumCount;
            detailBill.UnitPrice          = stock == null ? 0 : stock.UnitPrice;
            detailBill.OperationType      = (int)CE_SubsidiaryOperationType.领料;
            detailBill.Provider           = item.ProviderCode;

            if (stock != null)
            {
                detailBill.ProviderBatchNo = stock.ProviderBatchNo;
            }
            else
            {
                detailBill.ProviderBatchNo = "";
            }

            detailBill.BatchNo = item.BatchNo;

            detailBill.FillInPersonnel  = bill.FillInPersonnel;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = bill.DepartmentDirector;
            detailBill.DepotManager     = bill.DepotManager;
            detailBill.Remark           = (bill.Remark == null ? "" : bill.Remark.Trim()) + (item.Remark == null ? "" : item.Remark.Trim());
            detailBill.FillInDate       = bill.Bill_Time;

            IMaterialRequisitionPurposeServer purposeServer =
                ServerModuleFactory.GetServerModule <IMaterialRequisitionPurposeServer>();

            detailBill.Using = purposeServer.GetBillPurpose(context, bill.PurposeCode).Purpose;

            return(detailBill);
        }
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);
            }
        }
Beispiel #11
0
        /// <summary>
        /// 有检测废的物品直接生成领料单
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="billInfo">单据信息</param>
        void InsertIntoMaterialRequisition(DepotManagementDataContext ctx, Business_QualityManagement_Isolation billInfo)
        {
            string error  = null;
            string billNo = null;

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

            try
            {
                billNo = _assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

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

                S_MaterialRequisition lnqMaterial = null;

                List <string> listPersonnel = UniversalFunction.GetStorageOrStationPrincipal(billInfo.StorageID);

                if (listPersonnel.Contains("0008"))
                {
                    listPersonnel.Remove("0008");
                }

                if (listPersonnel.Contains("0417"))
                {
                    listPersonnel.Remove("0417");
                }

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

                    lnqMaterial.Bill_ID             = billNo;
                    lnqMaterial.Bill_Time           = ServerModule.ServerTime.Time;
                    lnqMaterial.AssociatedBillNo    = billInfo.BillNo;
                    lnqMaterial.AssociatedBillType  = "不合格品隔离处置单";
                    lnqMaterial.BillStatus          = "已出库";
                    lnqMaterial.Department          = "ZK03";
                    lnqMaterial.DepartmentDirector  = "";
                    lnqMaterial.DepotManager        = UniversalFunction.GetPersonnelInfo(listPersonnel[0]).姓名;
                    lnqMaterial.FetchCount          = 0;
                    lnqMaterial.FetchType           = "零星领料";
                    lnqMaterial.FillInPersonnel     = UniversalFunction.GetPersonnelInfo(BasicInfo.LoginID).姓名;
                    lnqMaterial.FillInPersonnelCode = BasicInfo.LoginID;
                    lnqMaterial.ProductType         = "";
                    lnqMaterial.PurposeCode         = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.破坏性检测).Code;
                    lnqMaterial.Remark       = "因入库零件进行了破坏性检测,由系统自动生成的破坏件领料单,对应单据号:" + billInfo.BillNo;
                    lnqMaterial.StorageID    = billInfo.StorageID;
                    lnqMaterial.OutDepotDate = ServerTime.Time;

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

                    S_MaterialRequisitionGoods lnqMaterialGoods = new S_MaterialRequisitionGoods();

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

                    ServerModule.IMaterialRequisitionGoodsServer serverMaterialGoods =
                        ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionGoodsServer>();

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

                    ctx.SubmitChanges();

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

                    ctx.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                serverMaterialBill.DeleteBill(billNo, out error);
                throw new Exception(ex.Message);
            }
        }
Beispiel #12
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);
            }
        }
        /// <summary>
        /// 批量生成明细
        /// </summary>
        /// <param name="selectType">单据类型 (“领料”,“领料退库”)</param>
        /// <param name="billID">单据号</param>
        /// <param name="billIDGather">数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回True,操作失败返回False</returns>
        public bool BatchCreateList(string selectType, string billID, string billIDGather, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                if (BillIsFinish(dataContext, billID))
                {
                    throw new Exception("单据已完成,无法进行操作");
                }

                Hashtable paramTable = new Hashtable();

                paramTable.Add("@SelectType", selectType);
                paramTable.Add("@BillID", billIDGather);

                string strErr = "";

                DataTable dtBatchCreate =
                    GlobalObject.DatabaseServer.QueryInfoPro("KFYW_BatchCreateListFrom_RequisitionOrReturnedInTheDepot",
                                                             paramTable, out strErr);

                if (dtBatchCreate == null)
                {
                    error = strErr;
                    return(false);
                }

                if (selectType == "领料")
                {
                    var varReturn = from a in dataContext.S_MaterialListReturnedInTheDepot
                                    where a.Bill_ID == billID
                                    select a;

                    dataContext.S_MaterialListReturnedInTheDepot.DeleteAllOnSubmit(varReturn);

                    for (int i = 0; i < dtBatchCreate.Rows.Count; i++)
                    {
                        S_MaterialListReturnedInTheDepot lnqReturn = new S_MaterialListReturnedInTheDepot();

                        lnqReturn.BatchNo         = dtBatchCreate.Rows[i]["BatchNo"].ToString();
                        lnqReturn.Bill_ID         = billID;
                        lnqReturn.ColumnNumber    = dtBatchCreate.Rows[i]["ColumnNumber"].ToString();
                        lnqReturn.Depot           = dtBatchCreate.Rows[i]["Depot"].ToString();
                        lnqReturn.GoodsID         = Convert.ToInt32(dtBatchCreate.Rows[i]["GoodsID"].ToString());
                        lnqReturn.LayerNumber     = dtBatchCreate.Rows[i]["LayerNumber"].ToString();
                        lnqReturn.Provider        = dtBatchCreate.Rows[i]["Provider"].ToString();
                        lnqReturn.ProviderBatchNo = dtBatchCreate.Rows[i]["ProviderBatchNo"].ToString();
                        lnqReturn.Remark          = "由领料单" + billIDGather + "批量自动生成";
                        lnqReturn.ReturnedAmount  = Convert.ToDecimal(dtBatchCreate.Rows[i]["ReturnedAmount"].ToString());
                        lnqReturn.ShelfArea       = dtBatchCreate.Rows[i]["ShelfArea"].ToString();

                        dataContext.S_MaterialListReturnedInTheDepot.InsertOnSubmit(lnqReturn);
                    }
                }
                else
                {
                    var varRequisition = from a in dataContext.S_MaterialRequisitionGoods
                                         where a.Bill_ID == billID
                                         select a;

                    dataContext.S_MaterialRequisitionGoods.DeleteAllOnSubmit(varRequisition);

                    for (int i = 0; i < dtBatchCreate.Rows.Count; i++)
                    {
                        S_MaterialRequisitionGoods lnqRequisition = new S_MaterialRequisitionGoods();

                        lnqRequisition.BasicCount   = Convert.ToDecimal(dtBatchCreate.Rows[i]["BasicCount"].ToString());
                        lnqRequisition.BatchNo      = dtBatchCreate.Rows[i]["BatchNo"].ToString();
                        lnqRequisition.Bill_ID      = billID;
                        lnqRequisition.GoodsID      = Convert.ToInt32(dtBatchCreate.Rows[i]["GoodsID"].ToString());
                        lnqRequisition.ProviderCode = dtBatchCreate.Rows[i]["ProviderCode"].ToString();
                        lnqRequisition.RealCount    = Convert.ToDecimal(dtBatchCreate.Rows[i]["RealCount"].ToString());
                        lnqRequisition.Remark       = "由退库单" + billIDGather + "批量自动生成";
                        lnqRequisition.RequestCount = Convert.ToDecimal(dtBatchCreate.Rows[i]["RequestCount"].ToString());
                        lnqRequisition.ShowPosition = i + 1;

                        MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer();

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

                dataContext.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Beispiel #14
0
        void CreateMaterialRequisition(DepotManagementDataContext ctx, Business_WarehouseOutPut_WholeMachineRequisition billInfo,
                                       List <Business_WarehouseOutPut_WholeMachineRequisitionDetail> listDetail,
                                       List <Business_WarehouseOutPut_WholeMachineRequisition_StorageID> listStorage, out List <string> listBillNo)
        {
            listBillNo = null;
            ServerModule.IMaterialRequisitionGoodsServer serviceGoods = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionGoodsServer>();
            ServerModule.IMaterialRequisitionServer      serviceBill  = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionServer>();
            ServerModule.IStoreServer serviceStore = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IStoreServer>();
            IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>();

            ServerModule.IMaterialRequisitionPurposeServer servicePurpose = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionPurposeServer>();

            BillNumberControl billControl = new BillNumberControl(CE_BillTypeEnum.领料单, serviceBill);

            List <CommonProcessInfo> listProcessInfo = serviceFlow.GetFlowData(billInfo.BillNo);

            try
            {
                List <GoodsInfo> listGoodsInfo = new List <GoodsInfo>();

                foreach (Business_WarehouseOutPut_WholeMachineRequisitionDetail detail in listDetail)
                {
                    decimal requstCount = detail.GoodsCount;

                    foreach (Business_WarehouseOutPut_WholeMachineRequisition_StorageID storage in listStorage)
                    {
                        if (requstCount == 0)
                        {
                            break;
                        }

                        List <View_S_Stock> lstStock = serviceStore.GetGoodsStoreOnlyForAssembly(detail.GoodsID, storage.StorageID).ToList();

                        foreach (View_S_Stock stock in lstStock)
                        {
                            if (requstCount == 0)
                            {
                                break;
                            }

                            if (stock.库存数量 <= requstCount)
                            {
                                GoodsInfo goodsInfo = new GoodsInfo();

                                goodsInfo.GoodsID    = detail.GoodsID;
                                goodsInfo.BatchNo    = stock.批次号;
                                goodsInfo.Provider   = stock.供货单位;
                                goodsInfo.GoodsCount = stock.库存数量;

                                goodsInfo.ListInfo = new List <string>();

                                goodsInfo.ListInfo.Add(listGoodsInfo.Count.ToString());
                                goodsInfo.ListInfo.Add(storage.StorageID);
                                goodsInfo.ListInfo.Add(stock.库存数量.ToString());

                                listGoodsInfo.Add(goodsInfo);

                                requstCount = requstCount - stock.库存数量;
                            }
                            else
                            {
                                GoodsInfo goodsInfo = new GoodsInfo();

                                goodsInfo.GoodsID    = detail.GoodsID;
                                goodsInfo.BatchNo    = stock.批次号;
                                goodsInfo.Provider   = stock.供货单位;
                                goodsInfo.GoodsCount = requstCount;

                                goodsInfo.ListInfo = new List <string>();

                                goodsInfo.ListInfo.Add(listGoodsInfo.Count.ToString());
                                goodsInfo.ListInfo.Add(storage.StorageID);
                                goodsInfo.ListInfo.Add(detail.GoodsCount.ToString());

                                listGoodsInfo.Add(goodsInfo);

                                requstCount = 0;
                            }
                        }
                    }
                }

                if (listGoodsInfo != null && listGoodsInfo.Count > 0)
                {
                    listBillNo = new List <string>();
                    CommonProcessInfo firstProcess  = new CommonProcessInfo();
                    CommonProcessInfo SecondProcess = new CommonProcessInfo();
                    CommonProcessInfo ThridProcess  = new CommonProcessInfo();

                    var varTemp = from a in listProcessInfo where a.操作节点 == "新建" orderby a.时间 descending select a;

                    if (varTemp.Count() != 0)
                    {
                        firstProcess = varTemp.First();
                    }
                    else
                    {
                        throw new Exception("此单据无【新建】流程");
                    }

                    varTemp = from a in listProcessInfo where a.操作节点 == "审核" orderby a.时间 descending select a;

                    if (varTemp.Count() != 0)
                    {
                        SecondProcess = varTemp.First();
                    }
                    else
                    {
                        throw new Exception("此单据无【审核】流程");
                    }

                    varTemp = from a in listProcessInfo where a.操作节点 == "确认" orderby a.时间 descending select a;

                    if (varTemp.Count() != 0)
                    {
                        ThridProcess = varTemp.First();
                    }

                    foreach (Business_WarehouseOutPut_WholeMachineRequisition_StorageID storage in listStorage)
                    {
                        List <GoodsInfo> listGoodsInfoTemp = (from a in listGoodsInfo
                                                              where a.ListInfo[1].ToString() == storage.StorageID
                                                              orderby Convert.ToInt32(a.ListInfo[0])
                                                              select a).ToList();

                        if (listGoodsInfoTemp.Count > 0)
                        {
                            string error = "";

                            S_MaterialRequisition bill = new S_MaterialRequisition();

                            bill.AssociatedBillNo   = billInfo.BillNo;
                            bill.AssociatedBillType = CE_BillTypeEnum.整台份请领单.ToString();
                            bill.Bill_ID            = billControl.GetNewBillNo(ctx);
                            bill.Bill_Time          = ServerTime.Time;
                            bill.BillStatus         = "等待出库";

                            View_HR_Personnel personnelInfo = UniversalFunction.GetPersonnelInfo(firstProcess.工号);

                            bill.Department          = personnelInfo.部门编码;
                            bill.DepartmentDirector  = SecondProcess.人员;
                            bill.DepotManager        = ThridProcess == new CommonProcessInfo() ? BasicInfo.LoginName : ThridProcess.人员;
                            bill.FetchCount          = (int)billInfo.MachineCount;
                            bill.FetchType           = FetchGoodsType.整台领料.ToString();
                            bill.FillInPersonnel     = firstProcess.人员;
                            bill.FillInPersonnelCode = personnelInfo.工号;
                            bill.ProductType         = billInfo.ProductType;
                            bill.PurposeCode         = servicePurpose.GetBillPurpose(ctx, billInfo.BillTypeDetail).Code;
                            bill.Remark    = billInfo.Remark;
                            bill.StorageID = storage.StorageID;

                            if (!serviceBill.AutoCreateBill(ctx, bill, out error))
                            {
                                throw new Exception(error);
                            }

                            listBillNo.Add(bill.Bill_ID);

                            for (int i = 0; i < listGoodsInfoTemp.Count; i++)
                            {
                                S_MaterialRequisitionGoods goodsInfo = new S_MaterialRequisitionGoods();

                                goodsInfo.BasicCount   = Convert.ToDecimal(listGoodsInfoTemp[i].ListInfo[2]);
                                goodsInfo.BatchNo      = listGoodsInfoTemp[i].BatchNo;
                                goodsInfo.Bill_ID      = bill.Bill_ID;
                                goodsInfo.GoodsID      = listGoodsInfoTemp[i].GoodsID;
                                goodsInfo.ProviderCode = listGoodsInfoTemp[i].Provider;
                                goodsInfo.RealCount    = listGoodsInfoTemp[i].GoodsCount;
                                goodsInfo.Remark       = GetWorkBench_WashFlag(billInfo.ProductType, goodsInfo.GoodsID);
                                goodsInfo.RequestCount = listGoodsInfoTemp[i].GoodsCount;

                                IProductOrder serviceProductOrder = ServerModuleFactory.GetServerModule <IProductOrder>();
                                goodsInfo.ShowPosition = 0;
                                //serviceProductOrder.GetPosition(ctx, billInfo.ProductType, goodsInfo.GoodsID);

                                if (!serviceGoods.AutoCreateGoods(ctx, goodsInfo, out error))
                                {
                                    throw new Exception(error);
                                }
                            }
                        }

                        ctx.SubmitChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <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);
            }
        }
Beispiel #16
0
        /// <summary>
        /// 明细操作
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="billNo">单据号</param>
        /// <param name="detailInfo">明细信息</param>
        /// <param name="mode">操作类型</param>
        void OperationDetailInfo(DepotManagementDataContext ctx, string billNo, S_MaterialRequisitionGoods detailInfo, CE_OperatorMode mode)
        {
            try
            {
                var varBill = from a in ctx.S_MaterialRequisition
                              where a.Bill_ID == billNo
                              select a;

                if (varBill.Count() != 1)
                {
                    throw new Exception("【单据号】:" + billNo + " 不存在或者不唯一");
                }

                if (varBill.Single().BillStatus == MaterialRequisitionBillStatus.已出库.ToString())
                {
                    throw new Exception("【单据号】:" + billNo + " 已出库 无法进行操作");
                }

                if (mode == CE_OperatorMode.添加 || mode == CE_OperatorMode.除 || mode == CE_OperatorMode.修改)
                {
                    if (detailInfo == null)
                    {
                        throw new Exception("需要操作的记录为空,无法操作【" + mode.ToString() + "】");
                    }

                    var varData = from a in ctx.S_MaterialRequisitionGoods
                                  where a.ID == detailInfo.ID
                                  select a;

                    switch (mode)
                    {
                    case CE_OperatorMode.添加:

                        if (varData.Count() == 1)
                        {
                            S_MaterialRequisitionGoods tempInfo = varData.Single();

                            tempInfo.Bill_ID      = billNo;
                            tempInfo.GoodsID      = detailInfo.GoodsID;
                            tempInfo.BatchNo      = detailInfo.BatchNo;
                            tempInfo.BasicCount   = detailInfo.BasicCount;
                            tempInfo.ProviderCode = detailInfo.ProviderCode;
                            tempInfo.RealCount    = detailInfo.RealCount;
                            tempInfo.Remark       = detailInfo.Remark;
                            tempInfo.RepairStatus = detailInfo.RepairStatus;
                            tempInfo.RequestCount = detailInfo.RequestCount;
                            tempInfo.ShowPosition = detailInfo.ShowPosition;
                        }
                        else if (varData.Count() == 0)
                        {
                            detailInfo.Bill_ID = billNo;
                            ctx.S_MaterialRequisitionGoods.InsertOnSubmit(detailInfo);
                        }
                        else
                        {
                            throw new Exception(UniversalFunction.GetGoodsMessage(ctx, detailInfo.GoodsID) + "【批次号】:"
                                                + detailInfo.BatchNo + "【供应商】:" + detailInfo.ProviderCode + " 数据不唯一");
                        }

                        break;

                    case CE_OperatorMode.修改:

                        if (varData.Count() == 1)
                        {
                            S_MaterialRequisitionGoods tempInfo = varData.Single();

                            tempInfo.Bill_ID      = billNo;
                            tempInfo.GoodsID      = detailInfo.GoodsID;
                            tempInfo.BatchNo      = detailInfo.BatchNo;
                            tempInfo.BasicCount   = detailInfo.BasicCount;
                            tempInfo.ProviderCode = detailInfo.ProviderCode;
                            tempInfo.RealCount    = detailInfo.RealCount;
                            tempInfo.Remark       = detailInfo.Remark;
                            tempInfo.RepairStatus = detailInfo.RepairStatus;
                            tempInfo.RequestCount = detailInfo.RequestCount;
                            tempInfo.ShowPosition = detailInfo.ShowPosition;
                        }
                        else
                        {
                            throw new Exception(UniversalFunction.GetGoodsMessage(ctx, detailInfo.GoodsID) + "【批次号】:"
                                                + detailInfo.BatchNo + "【供应商】:" + detailInfo.ProviderCode + " 数据不唯一或者为空");
                        }

                        break;

                    case CE_OperatorMode.除:
                        ctx.S_MaterialRequisitionGoods.DeleteAllOnSubmit(varData);
                        break;

                    default:
                        break;
                    }
                }
                else if (mode == CE_OperatorMode.批量删除)
                {
                    if (billNo == null)
                    {
                        throw new Exception("单据号为空,无法操作【" + mode.ToString() + "】");
                    }

                    var varAllDelete = from a in ctx.S_MaterialRequisitionGoods
                                       where a.Bill_ID == billNo
                                       select a;
                    ctx.S_MaterialRequisitionGoods.DeleteAllOnSubmit(varAllDelete);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #17
0
        /// <summary>
        /// 批量添加物品
        /// </summary>
        /// <param name="lstGoods">要添加的物品信息列表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回操作是否成功的标志</returns>
        public bool AddGoods(List <View_S_MaterialRequisitionGoods> lstGoods, out string error)
        {
            try
            {
                error = null;
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;
                for (int i = 0; i < lstGoods.Count; i++)
                {
                    List <View_S_MaterialRequisitionGoods> sameGoods = lstGoods.FindAll(
                        p => p.图号型号 == lstGoods[i].图号型号 && p.物品名称 == lstGoods[i].物品名称 &&
                        p.规格 == lstGoods[i].规格 && p.供应商编码 == lstGoods[i].供应商编码 &&
                        p.批次号 == lstGoods[i].批次号);

                    if (sameGoods.Count > 1)
                    {
                        decimal amount = 0;

                        foreach (var item in sameGoods)
                        {
                            amount += item.请领数;
                        }

                        lstGoods[i].请领数 = amount;

                        for (int j = i + 1; j < lstGoods.Count; j++)
                        {
                            if (lstGoods[i].图号型号 == lstGoods[j].图号型号 && lstGoods[i].物品名称
                                == lstGoods[j].物品名称 && lstGoods[i].规格 == lstGoods[j].规格 &&
                                lstGoods[i].供应商编码 == lstGoods[j].供应商编码 && lstGoods[i].批次号 == lstGoods[j].批次号)
                            {
                                lstGoods.RemoveAt(j--);
                            }
                        }
                    }
                }

                foreach (var item in lstGoods)
                {
                    S_MaterialRequisitionGoods mrg = new S_MaterialRequisitionGoods();

                    mrg.BasicCount   = item.基数;
                    mrg.BatchNo      = item.批次号;
                    mrg.Bill_ID      = item.领料单号;
                    mrg.GoodsID      = item.物品ID;
                    mrg.ProviderCode = item.供应商编码;
                    mrg.RealCount    = item.实领数;
                    mrg.RequestCount = item.请领数;
                    mrg.Remark       = item.备注;
                    mrg.ShowPosition = item.显示位置;

                    OperationDetailInfo(ctx, mrg.Bill_ID, mrg, CE_OperatorMode.添加);
                }

                ctx.SubmitChanges();
                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 插入领料单明细信息
        /// </summary>
        /// <param name="ctx">LINQ数据上下文</param>
        /// <param name="goodsTable">售后服务配件申请单分解的零件清单</param>
        /// <param name="storageID">库房ID</param>
        /// <param name="materialBillID">领料单单号</param>
        /// <param name="error">失败时返回的错误信息</param>
        /// <returns>返回TRUE表示成功,返回FALSE表示插入失败</returns>
        private bool InsertMaterialRequisitionList(DepotManagementDataContext ctx, ref DataTable goodsTable,
                                                   string storageID, string materialBillID, out string error)
        {
            error = null;
            string strOutMessage = "";

            try
            {
                for (int i = 0; i < goodsTable.Rows.Count; i++)
                {
                    List <View_S_Stock> lstStock = m_storeServer.GetGoodsStoreOnlyForSBW(goodsTable.Rows[i]["GoodsCode"].ToString(),
                                                                                         goodsTable.Rows[i]["GoodsName"].ToString(),
                                                                                         goodsTable.Rows[i]["Spec"].ToString(), storageID).ToList();

                    if (lstStock.Count > 0)
                    {
                        foreach (View_S_Stock item in lstStock)
                        {
                            S_MaterialRequisitionGoods lnqMaterialList = new S_MaterialRequisitionGoods();

                            lnqMaterialList.BasicCount   = 0;
                            lnqMaterialList.BatchNo      = item.批次号;
                            lnqMaterialList.Bill_ID      = materialBillID;
                            lnqMaterialList.GoodsID      = item.物品ID;
                            lnqMaterialList.ProviderCode = item.供货单位;

                            if (Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]) > item.库存数量)
                            {
                                lnqMaterialList.RequestCount = Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]);
                                lnqMaterialList.RealCount    = item.库存数量;
                            }
                            else
                            {
                                lnqMaterialList.RequestCount = Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]);
                                lnqMaterialList.RealCount    = Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]);
                            }

                            lnqMaterialList.Remark       = "";
                            lnqMaterialList.ShowPosition = 1;

                            MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer();

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

                            goodsTable.Rows[i]["RequestCount"] =
                                Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]) - lnqMaterialList.RealCount;

                            if (Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]) == 0)
                            {
                                break;
                            }
                        }
                    }

                    if (Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]) > 0)
                    {
                        strOutMessage = strOutMessage + "【图号型号】:" + goodsTable.Rows[i]["GoodsCode"].ToString()
                                        + " 【物品名称】:" + goodsTable.Rows[i]["GoodsName"].ToString()
                                        + " 【规格】:" + goodsTable.Rows[i]["Spec"].ToString()
                                        + " 【数量】:" + goodsTable.Rows[i]["RequestCount"].ToString() + "\r\n";
                    }
                }

                error = strOutMessage;
                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 插入领料单
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="threePacketsOfTheRepairBill">三包外返修处置单主表信息</param>
        /// <param name="dtListOfStorageID">库房信息</param>
        /// <param name="threePacketsOfTheRepairList">三包外返修处置单明细信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        bool InsertMaterialRequisition(DepotManagementDataContext dataContext, YX_ThreePacketsOfTheRepairBill threePacketsOfTheRepairBill,
                                       DataTable dtListOfStorageID, DataTable threePacketsOfTheRepairList, out string error)
        {
            error = null;

            try
            {
                if (dtListOfStorageID == null || dtListOfStorageID.Rows.Count == 0)
                {
                    return(true);
                }
                else
                {
                    for (int k = 0; k < dtListOfStorageID.Rows.Count; k++)
                    {
                        //领表主表信息
                        MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer();

                        string strBillID = m_serverAssignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

                        S_MaterialRequisition lnqMaterial = new S_MaterialRequisition();

                        lnqMaterial.Bill_ID             = strBillID;
                        lnqMaterial.Bill_Time           = ServerModule.ServerTime.Time;
                        lnqMaterial.AssociatedBillNo    = threePacketsOfTheRepairBill.Bill_ID;
                        lnqMaterial.AssociatedBillType  = "三包外返修处置单";
                        lnqMaterial.BillStatus          = "已出库";
                        lnqMaterial.Department          = m_serverDepartment.GetDeptInfoFromPersonnelInfo(threePacketsOfTheRepairBill.WorkShopPersonnel).Rows[0]["DepartmentCode"].ToString();
                        lnqMaterial.DepartmentDirector  = threePacketsOfTheRepairBill.WorkshopManagerPersonnel;
                        lnqMaterial.DepotManager        = threePacketsOfTheRepairBill.StockPersonnel;
                        lnqMaterial.FetchCount          = 0;
                        lnqMaterial.FetchType           = "零星领料";
                        lnqMaterial.FillInPersonnel     = threePacketsOfTheRepairBill.WorkShopPersonnel;
                        lnqMaterial.FillInPersonnelCode = UniversalFunction.GetPersonnelCode(threePacketsOfTheRepairBill.WorkShopPersonnel);
                        lnqMaterial.ProductType         = "";
                        lnqMaterial.PurposeCode         = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.包外维修).Code;
                        lnqMaterial.Remark       = "由三包外返修处置单自动生成,对应的三包外返修处置单号为" + threePacketsOfTheRepairBill.Bill_ID;
                        lnqMaterial.StorageID    = dtListOfStorageID.Rows[k][0].ToString();
                        lnqMaterial.OutDepotDate = ServerTime.Time;

                        if (!serverMaterialBill.AutoCreateBill(dataContext, lnqMaterial, out error))
                        {
                            return(false);
                        }

                        for (int i = 0; i < threePacketsOfTheRepairList.Rows.Count; i++)
                        {
                            if (!Convert.ToBoolean(threePacketsOfTheRepairList.Rows[i]["是否为客户责任"]) &&
                                threePacketsOfTheRepairList.Rows[i][13].ToString().Trim() == dtListOfStorageID.Rows[k][0].ToString().Trim())
                            {
                                var varStock = from a in dataContext.S_Stock
                                               where a.StorageID == dtListOfStorageID.Rows[k][0].ToString() &&
                                               a.GoodsID == Convert.ToInt32(threePacketsOfTheRepairList.Rows[i]["物品ID"]) &&
                                               a.BatchNo == threePacketsOfTheRepairList.Rows[i]["批次号"].ToString() &&
                                               a.Provider == threePacketsOfTheRepairList.Rows[i][14].ToString()
                                               select a;

                                if (varStock.Count() != 1)
                                {
                                    error = "库存信息不唯一或者为空";
                                    return(false);
                                }
                                else
                                {
                                    if (varStock.Single().GoodsStatus == 3)
                                    {
                                        error = "【" + varStock.Single().GoodsCode + "】 【" + varStock.Single().GoodsName + "】 【"
                                                + varStock.Single().Spec + "】【"
                                                + threePacketsOfTheRepairList.Rows[i]["批次号"].ToString()
                                                + "】物品库存状态为“隔离”不允许出库";

                                        return(false);
                                    }
                                }


                                S_MaterialRequisitionGoods lnqMaterialGoods = new S_MaterialRequisitionGoods();

                                lnqMaterialGoods.Bill_ID      = strBillID;
                                lnqMaterialGoods.BasicCount   = 0;
                                lnqMaterialGoods.BatchNo      = threePacketsOfTheRepairList.Rows[i]["批次号"].ToString();
                                lnqMaterialGoods.GoodsID      = Convert.ToInt32(threePacketsOfTheRepairList.Rows[i]["物品ID"]);
                                lnqMaterialGoods.ProviderCode = threePacketsOfTheRepairList.Rows[i][14].ToString();
                                lnqMaterialGoods.RealCount    = Convert.ToDecimal(threePacketsOfTheRepairList.Rows[i]["领用数量"]);
                                lnqMaterialGoods.Remark       = threePacketsOfTheRepairList.Rows[i]["备注"].ToString();
                                lnqMaterialGoods.RequestCount = Convert.ToDecimal(threePacketsOfTheRepairList.Rows[i]["领用数量"]);
                                lnqMaterialGoods.ShowPosition = 1;

                                MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer();

                                if (!serverMaterialGoods.AutoCreateGoods(dataContext, lnqMaterialGoods, out error))
                                {
                                    return(false);
                                }
                            }
                        }

                        dataContext.SubmitChanges();

                        new MaterialRequisitionServer().OpertaionDetailAndStock(dataContext, lnqMaterial);

                        dataContext.SubmitChanges();
                    }
                }

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