/// <summary>
        /// 取消分配的单据号
        /// </summary>
        /// <param name="billTypeName">单据类型名称</param>
        /// <param name="billNo">单据号</param>
        /// <returns>成功则返回true, 失败返回false或抛出异常</returns>
        public bool CancelBillNo(string billTypeName, string billNo)
        {
            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                bool result = CancelBillNo(dataContxt, billTypeName, billNo);

                if (result)
                {
                    dataContxt.SubmitChanges();
                }

                return(result);
            }
            catch (Exception exce)
            {
                Console.WriteLine("CancelBillNo:{0}", exce.Message);
                return(false);
            }
        }
        /// <summary>
        /// 更新单据编号信息
        /// </summary>
        /// <param name="billNoInfo">更新后的信息</param>
        /// <returns>操作成功返回true</returns>
        private bool Update(BASE_AssignBillNo billNoInfo)
        {
            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;
            var result = from r in dataContxt.BASE_AssignBillNo
                         where r.Bill_TypeCode == billNoInfo.Bill_TypeCode && r.Bill_No == billNoInfo.Bill_No
                         select r;

            if (result.Count() == 0)
            {
                return(false);
            }

            BASE_AssignBillNo data = result.Single();

            data.AlreadyUse   = billNoInfo.AlreadyUse;
            data.AssignedDate = ServerModule.ServerTime.Time;
            data.IsAbandoned  = billNoInfo.IsAbandoned;

            dataContxt.SubmitChanges();
            return(true);
        }
Esempio n. 3
0
        void RecordLog(DepotManagementDataContext ctx, ZPX_ProductionParams productionParams)
        {
            ZPX_ProductionParams_Log tempLnqLog = new ZPX_ProductionParams_Log();

            tempLnqLog.DataType      = productionParams.DataType;
            tempLnqLog.RangeOfValues = productionParams.RangeOfValues;
            tempLnqLog.Remark        = productionParams.Remark;
            tempLnqLog.Value1        = productionParams.Value1;
            tempLnqLog.Value2        = productionParams.Value2;
            tempLnqLog.Value3        = productionParams.Value3;
            tempLnqLog.Value4        = productionParams.Value4;
            tempLnqLog.Value5        = productionParams.Value5;
            tempLnqLog.Value6        = productionParams.Value6;

            tempLnqLog.ParamsID           = productionParams.ID;
            tempLnqLog.OperationTime      = ServerTime.Time;
            tempLnqLog.OperationMode      = CE_OperatorMode.修改.ToString();
            tempLnqLog.OperationPersonnel = BasicInfo.LoginID;

            ctx.ZPX_ProductionParams_Log.InsertOnSubmit(tempLnqLog);
        }
        /// <summary>
        /// 获得单条借贷记录
        /// </summary>
        /// <param name="DebtorCode">借方代码</param>
        /// <param name="CreditCode">贷方代码</param>
        /// <param name="goodsID">物品ID</param>
        /// <param name="batchNo">批次号</param>
        /// <param name="provider">供应商</param>
        /// <returns>返回单条LNQ数据集</returns>
        public S_ProductLendRecord GetStockSingleInfo(string DebtorCode, string CreditCode, int goodsID, string batchNo, string provider)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.S_ProductLendRecord
                          where a.CreditCode == CreditCode &&
                          a.DebtorCode == DebtorCode &&
                          a.GoodsID == goodsID &&
                          a.BatchNo == batchNo &&
                          a.Provider == provider
                          select a;

            if (varData.Count() != 1)
            {
                return(null);
            }
            else
            {
                return(varData.Single());
            }
        }
        /// <summary>
        /// 通过图号型号查找物品的序号
        /// </summary>
        /// <param name="goodsCode">图号型号</param>
        /// <returns>成功返回序号,失败返回null</returns>
        public int GetGoodsIDByGoodsCode(string goodsCode)
        {
            int error = 0;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from c in dataContxt.View_F_GoodsPlanCost
                             where c.图号型号 == goodsCode
                             select c.序号;

                return(result.Single());
            }
            catch (Exception err)
            {
                error = Convert.ToInt32(err.ToString());

                return(error);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 添加订单信息
        /// </summary>
        /// <param name="listRole">角色列表</param>
        /// <param name="loginName">登录名</param>
        /// <param name="orderFormInfo">订单信息</param>
        /// <param name="returnOrderFormInfo">返回查询到的订单信息</param>
        /// <param name="error">错误信息, 没有则为null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool AddOrderFormInfo(List <string> listRole, string loginName, B_OrderFormInfo orderFormInfo,
                                     out IQueryable <View_B_OrderFormInfo> returnOrderFormInfo, out string error)
        {
            returnOrderFormInfo = null;
            error = null;

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            try
            {
                dataContxt.B_OrderFormInfo.InsertOnSubmit(orderFormInfo);
                dataContxt.SubmitChanges();

                return(GetAllOrderFormInfo(listRole, loginName, out returnOrderFormInfo, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 获取所有物品信息
        /// </summary>
        /// <param name="returnInfo">返回查询到的信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回操作是否成功</returns>
        public bool GetAllGoodsInfo(out IQueryable <View_F_GoodsPlanCost> returnInfo, out string error)
        {
            returnInfo = null;
            error      = null;

            try
            {
                DepotManagementDataContext   depotMangaeDataContext = CommentParameter.DepotDataContext;
                Table <View_F_GoodsPlanCost> goodsPriceTable        = depotMangaeDataContext.GetTable <View_F_GoodsPlanCost>();

                returnInfo = from c in goodsPriceTable
                             orderby c.图号型号, c.规格
                select c;
                return(true);
            }
            catch (Exception err)
            {
                error = err.ToString();
                return(false);
            }
        }
        /// <summary>
        /// 是否存在过库存记录
        /// </summary>
        /// <param name="billNo">单据号</param>
        public void IsExistProductStock(string billNo)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.ProductsCodes
                          where a.DJH == billNo
                          select a;

            foreach (ProductsCodes item in varData)
            {
                var tempData = from a in ctx.ProductStock
                               where a.ProductCode == item.ProductCode &&
                               a.GoodsID == item.GoodsID
                               select a;

                if (tempData.Count() > 0)
                {
                    throw new Exception("箱号【" + item.ProductCode + "】,已存在过,无法进行【生产入库】");
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 是否为工具
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="goodsID">物品ID</param>
        /// <returns>是 : True, 否 :False</returns>
        public bool IsTools(DepotManagementDataContext ctx, int goodsID)
        {
            object keyValue = BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.工具类别编码];

            if (keyValue != null && keyValue.ToString().Trim().Length > 0)
            {
                var varData = from a in ctx.F_GoodsPlanCost
                              where a.ID == goodsID
                              select a;

                if (varData.Count() == 1)
                {
                    if (varData.Single().GoodsType == keyValue.ToString())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 10
0
        /// <summary>
        /// 获取合同物品信息
        /// </summary>
        /// <param name="bargainNumber">合同号</param>
        /// <param name="returnBargainGoods">返回查询到的信息</param>
        /// <param name="error">错误信息, 没有则为null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool GetBargainGoods(string bargainNumber, out IQueryable <View_B_BargainGoods> returnBargainGoods, out string error)
        {
            error = null;
            returnBargainGoods = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                returnBargainGoods = from c in dataContxt.View_B_BargainGoods
                                     where c.合同号 == bargainNumber
                                     select c;

                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 更新物品信息
        /// </summary>
        /// <param name="goods">物品信息</param>
        /// <param name="storageID">库房ID</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回True,操作失败返回False</returns>
        public bool UpdateGoods(S_HomemadeRejectList goods, string storageID, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from r in dataContxt.S_HomemadeRejectList
                             where r.ID == goods.ID
                             select r;

                if (result.Count() > 0)
                {
                    S_HomemadeRejectList updateGoods = result.Single();

                    updateGoods.Bill_ID         = goods.Bill_ID;
                    updateGoods.GoodsID         = goods.GoodsID;
                    updateGoods.Provider        = goods.Provider;
                    updateGoods.BatchNo         = goods.BatchNo;
                    updateGoods.ProviderBatchNo = goods.ProviderBatchNo;
                    updateGoods.Amount          = goods.Amount;
                    updateGoods.Remark          = goods.Remark;

                    if (!SetPriceInfo(updateGoods, storageID, out error))
                    {
                        return(false);
                    }

                    dataContxt.SubmitChanges();
                }

                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 修改点检项目
        /// </summary>
        /// <param name="inspectionItem">点检项目数据集</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool UpdateItem(ZPX_InspectionItemSet inspectionItem, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                var varData = from a in dataContext.ZPX_InspectionItemSet
                              where a.ID == inspectionItem.ID
                              select a;

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

                    lnqItem.ItemName = inspectionItem.ItemName;
                    lnqItem.Mode     = inspectionItem.Mode;
                    lnqItem.Rate     = inspectionItem.Rate;
                    lnqItem.MaxValue = inspectionItem.MaxValue;
                    lnqItem.MinValue = inspectionItem.MinValue;
                    lnqItem.WorkID   = BasicInfo.LoginID;
                    lnqItem.Date     = ServerTime.Time;

                    dataContext.SubmitChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 添加领料清单信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="order">添加的数据信息</param>
        /// <param name="applicable">适用范围</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>添加成功返回True,添加失败返回False</returns>
        private bool InsertDate(DepotManagementDataContext context, DataTable order, CE_DebitScheduleApplicable applicable, out string error)
        {
            error = null;

            try
            {
                List <BASE_ProductOrder> lisOrder = new List <BASE_ProductOrder>();

                if (order.Rows.Count == 0)
                {
                    return(true);
                }
                else
                {
                    for (int i = 0; i < order.Rows.Count; i++)
                    {
                        BASE_ProductOrder lnqOrder = new BASE_ProductOrder();

                        lnqOrder.Edition           = order.Rows[i]["产品编码"].ToString();
                        lnqOrder.Applicable        = applicable.ToString();
                        lnqOrder.GoodsID           = Convert.ToInt32(order.Rows[i]["物品ID"]);
                        lnqOrder.Redices           = Convert.ToDecimal(order.Rows[i]["基数"].ToString());
                        lnqOrder.Position          = Convert.ToInt32(order.Rows[i]["顺序位置"].ToString());
                        lnqOrder.OnceTheWholeIssue = Convert.ToBoolean(order.Rows[i]["一次性整台份发料"]);

                        lisOrder.Add(lnqOrder);
                    }

                    context.BASE_ProductOrder.InsertAllOnSubmit(lisOrder);
                }

                context.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 添加/修改部门信息表
        /// </summary>
        /// <param name="providerCode">供应商编码</param>
        /// <param name="providerName">供应商名称</param>
        /// <param name="remark">备注</param>
        /// <param name="returnBill">部门信息表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功添加/修改部门信息表</returns>
        public bool AddNewProvider(string providerCode, string providerName, string remark,
                                   out IQueryable <View_B_NewProvider> returnBill, out string error)
        {
            returnBill = null;
            error      = null;

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

            try
            {
                Table <B_NewProvider> billtable = dataContxt.GetTable <B_NewProvider>();
                var billGather = from c in billtable where c.NewProviderCode == providerCode select c;

                int intSameNoteCount = billGather.Count <B_NewProvider>();

                if (intSameNoteCount == 0)
                {
                    B_NewProvider tableProvider = new B_NewProvider();

                    tableProvider.NewProviderCode = providerCode;
                    tableProvider.NewProviderName = providerName;
                    tableProvider.Remark          = remark;

                    dataContxt.B_NewProvider.InsertOnSubmit(tableProvider);
                    dataContxt.SubmitChanges();
                    GetAllNewProvider(out returnBill, out error);
                }
                else
                {
                    error = "该单据已提交,系统不允许重复提交相同编号的供应商!";
                    return(false);
                }

                return(true);
            }
            catch (Exception err)
            {
                return(SetReturnError2(err, out returnBill, out error));
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 删除自制件退货单
        /// </summary>
        /// <param name="billNo">自制件退货单号</param>
        /// <param name="returnBill">返回更新后重新查询的自制件退货单数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功删除退货单号</returns>
        public bool DeleteBill(string billNo, out IQueryResult returnBill, out string error)
        {
            returnBill = null;
            error      = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                Table <S_HomemadeRejectBill> table = dataContxt.GetTable <S_HomemadeRejectBill>();

                var delRow = from c in table
                             where c.Bill_ID == billNo
                             select c;

                if (!ClearDate(dataContxt, billNo, out error))
                {
                    return(false);
                }

                table.DeleteAllOnSubmit(delRow);

                Table <S_HomemadeRejectList> tableList = dataContxt.GetTable <S_HomemadeRejectList>();

                var delList = from d in tableList
                              where d.Bill_ID == billNo
                              select d;

                tableList.DeleteAllOnSubmit(delList);

                dataContxt.SubmitChanges();

                return(GetAllBill(out returnBill, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 添加合同物品信息
        /// </summary>
        /// <param name="bargainGoods">合同物品信息</param>
        /// <param name="returnBargainGoods">返回查询到的合同物品信息</param>
        /// <param name="error">错误信息, 没有则为null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool AddBargainGoods(B_BargainGoods bargainGoods, out IQueryable <View_B_BargainGoods> returnBargainGoods, out string error)
        {
            returnBargainGoods = null;
            error = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                if (bargainGoods.GoodsID == 0)
                {
                    error = "请录入物品";
                    return(false);
                }

                var varBill = from a in dataContxt.B_BargainInfo
                              where a.BargainNumber == bargainGoods.BargainNumber
                              select a;

                if (varBill.Count() != 1)
                {
                    error = "请先添加合同,再添加物品";
                    return(false);
                }

                dataContxt.B_BargainGoods.InsertOnSubmit(bargainGoods);

                if (AutoSubmitToDatabase)
                {
                    dataContxt.SubmitChanges();
                }

                return(GetBargainGoods(bargainGoods.BargainNumber, out returnBargainGoods, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 申请流程
        /// </summary>
        /// <param name="releseProcess">LNQ数据集</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AddInfo(FM_RevisedAbolishedBill raBill, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.FM_RevisedAbolishedBill
                              where a.BillNo == raBill.BillNo
                              select a;

                FM_RevisedAbolishedBill lnqTemp = new FM_RevisedAbolishedBill();

                if (varData.Count() > 1)
                {
                    error = "数据错误";
                    return(false);
                }
                else if (varData.Count() == 1)
                {
                    lnqTemp = varData.Single();
                    AssignmentInfo(raBill, ref lnqTemp);
                }
                else
                {
                    AssignmentInfo(raBill, ref lnqTemp);
                    ctx.FM_RevisedAbolishedBill.InsertOnSubmit(lnqTemp);
                }

                ctx.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 删除维修记录
        /// </summary>
        /// <param name="id">要删除数据的ID</param>
        /// <param name="error">出错时返回的错误信息</param>
        /// <returns>操作是否成功的标志</returns>
        public bool Delete(int id, out string error)
        {
            error = null;

            DepotManagementDataContext context = CommentParameter.DepotDataContext;
            var data = from r in context.ZPX_ConvertedCVTNumber
                       where r.ID == id
                       select r;

            try
            {
                if (data.Count() == 0)
                {
                    error = "没有找到要删除的维修记录";
                    return(false);
                }

                // 删除由本人刚才误操作所生成的电子档案数据
                var ef = from r in context.P_ElectronFile
                         where r.FillInPersonnel == BasicInfo.LoginID &&
                         r.FillInDate.Value.Date == ServerTime.Time.Date
                         select r;

                if (ef.Count() > 0)
                {
                    context.P_ElectronFile.DeleteAllOnSubmit(ef);
                }

                context.ZPX_ConvertedCVTNumber.DeleteAllOnSubmit(data);

                context.SubmitChanges();

                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 领料出库人提交单据(交给主管审批)
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="returnBill">返回更新后重新查询的领料退库单数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功添加领料退库单</returns>
        public bool SubmitNewBill(string billNo, out IQueryResult returnBill, out string error)
        {
            returnBill = null;
            error      = null;

            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                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);
                }

                var varList = from a in ctx.S_MaterialListReturnedInTheDepot where a.Bill_ID == billNo select a;

                foreach (S_MaterialListReturnedInTheDepot item in varList)
                {
                    if (item.Provider == null || item.Provider.Trim().Length == 0)
                    {
                        error = string.Format("有记录供应商为空,供应商不能为空,请重新核对");
                        return(false);
                    }
                }

                result.Single().BillStatus = MaterialReturnedInTheDepotBillStatus.等待主管审核.ToString();
                result.Single().Bill_Time  = ServerModule.ServerTime.Time;
                ctx.SubmitChanges();

                return(GetAllBill(out returnBill, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 赋值账务信息_入
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="lnqOutPut">单据信息</param>
        /// <param name="detail1">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        S_InDepotDetailBill AssignDetailInfo_In(DepotManagementDataContext ctx, Business_WarehouseOutPut_OutPut lnqOutPut,
                                                View_Business_WarehouseOutPut_OutPutDetail detail1)
        {
            IFlowServer           serverFlow  = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>();
            CommonProcessInfo     processInfo = new CommonProcessInfo();
            CE_OutPutBusinessType OutPutType  =
                GlobalObject.GeneralFunction.StringConvertToEnum <CE_OutPutBusinessType>(lnqOutPut.BillType);

            S_InDepotDetailBill inDepotDetail = new S_InDepotDetailBill();

            inDepotDetail.AffrimPersonnel = BasicInfo.LoginName;
            inDepotDetail.BatchNo         = detail1.批次号;
            inDepotDetail.BillTime        = ServerTime.Time;
            inDepotDetail.Department      = UniversalFunction.GetDeptName(lnqOutPut.ApplyingDepartment);
            inDepotDetail.Depot           = UniversalFunction.GetGoodsInfo(detail1.物品ID).物品类别名称;

            inDepotDetail.FactPrice = 0;
            //Math.Round(detail1.单价 * detail1.数量, 2);
            inDepotDetail.FactUnitPrice = 0;
            //detail1.单价;
            inDepotDetail.Price            = inDepotDetail.FactPrice;
            inDepotDetail.UnitPrice        = inDepotDetail.FactUnitPrice;
            inDepotDetail.InvoicePrice     = null;
            inDepotDetail.InvoiceUnitPrice = null;

            processInfo = serverFlow.GetFlowData(detail1.关联业务).First();

            inDepotDetail.FillInDate      = Convert.ToDateTime(processInfo.时间);
            inDepotDetail.FillInPersonnel = processInfo.人员;

            inDepotDetail.InDepotBillID = lnqOutPut.BillNo;
            inDepotDetail.InDepotCount  = -detail1.数量;
            inDepotDetail.GoodsID       = detail1.物品ID;
            inDepotDetail.OperationType = (int)GlobalObject.EnumOperation.OutPutBusinessTypeConvertToSubsidiaryOperationType(OutPutType);
            inDepotDetail.Provider      = detail1.供应商;
            inDepotDetail.Remark        = detail1.备注;
            inDepotDetail.StorageID     = lnqOutPut.StorageID;

            return(inDepotDetail);
        }
Esempio n. 21
0
        ///// <summary>
        ///// 根据单据信息操作账务信息与库存信息
        ///// </summary>
        ///// <param name="dataContext">数据上下文</param>
        ///// <param name="billInfo">单据信息</param>
        //void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_MusterUseBill billInfo)
        //{
        //    IFinancialDetailManagement serverDetail =
        //        ServerModule.ServerModuleFactory.GetServerModule<IFinancialDetailManagement>();

        //    var varData = from a in dataContext.S_MusterUseList
        //                  where a.DJH == billInfo.DJH
        //                  select a;

        //    foreach (S_MusterUseList item in varData)
        //    {
        //        if (!IsCheck(billInfo, item))
        //        {
        //            throw new Exception("库存数量不足");
        //        }

        //        S_FetchGoodsDetailBill detailInfo = AssignDetailInfo(dataContext, billInfo, item);

        //        if (detailInfo == null)
        //        {
        //            throw new Exception("获取账务信息或者库存信息失败");
        //        }

        //        serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, null);
        //    }
        //}

        ///// <summary>
        ///// 获得供应商
        ///// </summary>
        ///// <param name="listInfo">耗用单明细信息</param>
        ///// <returns>返回样品信息</returns>
        //string GetProvider(S_MusterUseList listInfo)
        //{
        //    DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

        //    var varData = from a in dataContext.S_MusterAffirmBill
        //                  where a.GoodsID == listInfo.GoodsID
        //                  && a.BatchNo == listInfo.BatchNo
        //                  select a;

        //    if (varData.Count() == 1)
        //    {
        //        return varData.Single().Provider;
        //    }

        //    var varData1 = from a in dataContext.Business_Sample_ConfirmTheApplication
        //                   where a.Purchase_GoodsID == listInfo.GoodsID
        //                   && a.Purchase_BatchNo == listInfo.BatchNo
        //                   select a;

        //    if (varData1.Count() == 1)
        //    {
        //        return varData1.Single().Purchase_Provider;
        //    }

        //    return "";
        //}

        ///// <summary>
        ///// 赋值账务信息
        ///// </summary>
        ///// <param name="context">数据上下文</param>
        ///// <param name="billInfo">单据信息</param>
        ///// <param name="item">明细信息</param>
        ///// <returns>返回账务信息对象</returns>
        //S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MusterUseBill billInfo, S_MusterUseList item)
        //{

        //    var varMusterStock = from a in context.S_MusterStock
        //                         where a.GoodsID == item.GoodsID
        //                         && a.BatchNo == item.BatchNo
        //                         && a.StrorageID == billInfo.StorageID
        //                         select a;

        //    if (varMusterStock.Count() != 1)
        //    {
        //        throw new Exception( "此仓库" + UniversalFunction.GetGoodsMessage((int)item.GoodsID) + "【批次号】:"
        //            + item.BatchNo + "库存不足");
        //    }
        //    else
        //    {
        //        S_MusterStock lnqMusterStock = varMusterStock.Single();

        //        if (Convert.ToDecimal(lnqMusterStock.Count) < Convert.ToDecimal(item.Count))
        //        {
        //            throw new Exception("批次号为 【" + item.BatchNo + "】的物品 库存不足,请重新确认数量!");
        //        }

        //        lnqMusterStock.Count = Convert.ToDecimal(lnqMusterStock.Count) - Convert.ToDecimal(item.Count);
        //    }

        //    S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

        //    detailBill.ID = Guid.NewGuid();
        //    detailBill.FetchBIllID = billInfo.DJH;
        //    detailBill.BillTime = ServerTime.Time;
        //    detailBill.FetchCount = item.Count;
        //    detailBill.GoodsID = (int)item.GoodsID;
        //    detailBill.BatchNo = item.BatchNo;
        //    detailBill.UnitPrice = 0;
        //    detailBill.Price = detailBill.UnitPrice * (decimal)detailBill.FetchCount;

        //    IMusterAffirmBill serverMuster = ServerModule.ServerModuleFactory.GetServerModule<IMusterAffirmBill>();

        //    detailBill.Provider = GetProvider(item);
        //    detailBill.FillInPersonnel = billInfo.SQR;
        //    detailBill.FinanceSignatory = null;
        //    detailBill.DepartDirector = billInfo.SHR;
        //    detailBill.DepotManager = billInfo.KFR;
        //    detailBill.OperationType = (int)CE_SubsidiaryOperationType.样品耗用;
        //    detailBill.Remark = item.Remark;
        //    detailBill.FillInDate = billInfo.SQRQ;
        //    detailBill.StorageID = billInfo.StorageID;

        //    return detailBill;
        //}

        ///// <summary>
        ///// 获得批次号的样品库库存数
        ///// </summary>
        ///// <param name="goodsID">物品ID</param>
        ///// <param name="batchNo">批次号</param>
        ///// <returns>返回获得的库存数</returns>
        //decimal GetMusterBatchNoStock(int goodsID,string batchNo)
        //{
        //    DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

        //    var varStock = from a in ctx.S_MusterStock
        //                   where a.GoodsID == goodsID
        //                   && a.BatchNo == batchNo
        //                   select a;

        //    if (varStock.Count() == 1)
        //    {

        //        var varData = from a in ctx.Business_Sample_ConfirmTheApplication
        //                      where a.Purchase_BatchNo == batchNo
        //                      && a.Purchase_GoodsID == goodsID
        //                      select a;

        //        if (varData.Count() == 1)
        //        {
        //            if (varData.Single().Purchase_SampleType == "PPAP样件'")
        //            {
        //                if (varData.Single().SQE_SampleDisposeType_DisqualificationCount != null)
        //                {
        //                    return (decimal)varStock.Single().Count -
        //                        (decimal)varData.Single().SQE_SampleDisposeType_DisqualificationCount;
        //                }
        //            }
        //            else
        //            {
        //                if (varData.Single().Review_InspectResult_ReWork_DisqualificationCount != null)
        //                {
        //                    return (decimal)varStock.Single().Count -
        //                        (decimal)varData.Single().Review_InspectResult_ReWork_DisqualificationCount;
        //                }
        //            }
        //        }

        //        return (decimal)varStock.Single().Count;
        //    }

        //    return 0;
        //}

        ///// <summary>
        ///// 检查是否可以出库
        ///// </summary>
        ///// <param name="inMusterUse">单据信息</param>
        ///// <param name="listInfo">明细信息</param>
        ///// <returns>已经过检验返回True,未经过检验返回False</returns>
        //bool IsCheck(S_MusterUseBill inMusterUse, S_MusterUseList listInfo)
        //{
        //    try
        //    {
        //        DepotManagementDataContext ctx = CommentParameter.DepotDataContext;


        //        var varStock = from a in ctx.S_MusterStock
        //                       where a.GoodsID == listInfo.GoodsID
        //                       && a.BatchNo == listInfo.BatchNo
        //                       && a.StrorageID == inMusterUse.StorageID
        //                       select a;

        //        if (varStock.Count() != 1)
        //        {
        //            return false;
        //        }

        //        var varData = from a in ctx.S_MusterAffirmBill
        //                      where a.GoodsID == listInfo.GoodsID
        //                      && a.BatchNo == listInfo.BatchNo
        //                      && a.StorageID == inMusterUse.StorageID
        //                      select a;

        //        if (varData.Count() == 1)
        //        {
        //            if ((decimal)varStock.Single().Count >= (decimal)listInfo.Count)
        //            {
        //                return true;
        //            }
        //        }

        //        var varData1 = from a in ctx.Business_Sample_ConfirmTheApplication
        //                       join b in ctx.Flow_FlowBillData
        //                       on a.BillNo equals b.BillNo
        //                       where a.Purchase_GoodsID == listInfo.GoodsID
        //                       && a.Purchase_BatchNo == listInfo.BatchNo
        //                       && a.Purchase_StorageID == inMusterUse.StorageID
        //                       select new
        //                       {
        //                           Purchase_SampleType = a.Purchase_SampleType,
        //                           FlowID = b.FlowID,
        //                           Review_InspectResult_ReWork_QualificationCount = a.Review_InspectResult_ReWork_QualificationCount,
        //                           Review_InspectResult_ReWork_DisqualificationCount = a.Review_InspectResult_ReWork_DisqualificationCount,
        //                           SQE_SampleDisposeType_QualificationCount = a.SQE_SampleDisposeType_QualificationCount,
        //                           SQE_SampleDisposeType_DisqualificationCount = a.SQE_SampleDisposeType_DisqualificationCount

        //                       };

        //        if (varData1.Count() == 1)
        //        {
        //            if (varData1.Single().Purchase_SampleType == "PPAP样件")
        //            {
        //                if (varData1.Single().FlowID > 47)
        //                {
        //                    if (varData1.Single().SQE_SampleDisposeType_QualificationCount != null)
        //                    {
        //                        if ((decimal)varStock.Single().Count - (decimal)varData1.Single().SQE_SampleDisposeType_DisqualificationCount
        //                            >= (decimal)listInfo.Count)
        //                        {
        //                            return true;
        //                        }
        //                    }
        //                    else
        //                    {
        //                        if ((decimal)varStock.Single().Count >= (decimal)listInfo.Count)
        //                        {
        //                            return true;
        //                        }
        //                    }
        //                }
        //            }
        //            else
        //            {
        //                if (varData1.Single().FlowID > 46)
        //                {
        //                    if (varData1.Single().Review_InspectResult_ReWork_QualificationCount != null)
        //                    {
        //                        if ((decimal)varStock.Single().Count - (decimal)varData1.Single().Review_InspectResult_ReWork_DisqualificationCount
        //                            >= (decimal)listInfo.Count)
        //                        {
        //                            return true;
        //                        }
        //                    }
        //                    else
        //                    {
        //                        if ((decimal)varStock.Single().Count >= (decimal)listInfo.Count)
        //                        {
        //                            return true;
        //                        }
        //                    }
        //                }
        //            }
        //        }

        //        return false;
        //    }
        //    catch (System.Exception ex)
        //    {
        //        throw new Exception(ex.Message);
        //    }
        //}
        #endregion

        /// <summary>
        /// 报废单据
        /// </summary>
        /// <param name="djh">样品耗用单单号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>报废成功返回True,报废失败返回False</returns>
        public bool ScarpBill(string djh, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                var varData = from a in dataContext.S_MusterUseBill
                              where a.DJH == djh
                              select a;

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

                    if (lnqbill.DJZT == "单据已完成")
                    {
                        error = "单据已完成不能删除";
                        return(false);
                    }

                    dataContext.S_MusterUseBill.DeleteOnSubmit(lnqbill);
                }

                dataContext.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 获得单条业务总单信息
        /// </summary>
        /// <param name="billNo">业务号</param>
        /// <returns>返回业务总单信息</returns>
        public Business_InspectionJudge_JudgeReport GetSingleBillInfo(string billNo)
        {
            if (billNo == null)
            {
                return(null);
            }

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.Business_InspectionJudge_JudgeReport
                          where a.BillNo == billNo
                          select a;

            if (varData.Count() == 1)
            {
                return(varData.Single());
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 质检判定
        /// </summary>
        /// <param name="dataID">要判定的数据编号</param>
        /// <param name="duty">判定内容</param>
        /// <returns>操作是否成功的标志</returns>
        public bool Auditing(int dataID, string duty)
        {
            DepotManagementDataContext context = CommentParameter.DepotDataContext;

            var result = from r in context.ZPX_CVTRepairInfo
                         where r.ID == dataID
                         select r;

            if (result.Count() == 0)
            {
                throw new Exception("找不到要审核的记录,无法进行此操作");
            }

            ZPX_CVTRepairInfo updateData = result.Single();

            updateData.Duty   = BasicInfo.LoginName + ServerTime.Time.ToString() + duty;
            updateData.Status = "已完成";

            context.SubmitChanges();

            return(true);
        }
Esempio n. 24
0
        /// <summary>
        /// 保存检验验证记录
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="billNo">单据号</param>
        /// <param name="infoTable">检验验证记录信息集</param>
        /// <param name="type">记录类型:检验,验证</param>
        public void SaveDataTableInfo(DepotManagementDataContext ctx, string billNo, DataTable infoTable, string type)
        {
            var varData = from a in ctx.ZL_UnProductTestingSingleList
                          where a.Bill_ID == billNo && a.Type == type
                          select a;

            ctx.ZL_UnProductTestingSingleList.DeleteAllOnSubmit(varData);

            foreach (DataRow dr in infoTable.Rows)
            {
                ZL_UnProductTestingSingleList lnqList = new ZL_UnProductTestingSingleList();

                lnqList.Bill_ID               = billNo;
                lnqList.InspectionItem        = dr["检验验证项目"].ToString();
                lnqList.TechnicalRequirements = dr["技术要求"].ToString();
                lnqList.TestingMethod         = dr["检验验证方法"].ToString();
                lnqList.TestRecords           = dr["检验验证记录"].ToString();
                lnqList.Type = type;

                ctx.ZL_UnProductTestingSingleList.InsertOnSubmit(lnqList);
            }
        }
        /// <summary>
        /// 添加工位
        /// </summary>
        /// <param name="workbench">工位号</param>
        /// <param name="remark">工位备注</param>
        /// <param name="returnWorkbench">返回工位信息</param>
        /// <param name="error">错误信息</param>
        /// <returns>添加成功返回True,添加失败返回False</returns>
        public bool Add(string workbench, string remark, out IQueryable <View_P_Workbench> returnWorkbench, out string error)
        {
            returnWorkbench = null;
            error           = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var billGather = from c in dataContxt.P_Workbench
                                 where c.Workbench == workbench
                                 select c;

                if (billGather.Count() == 0)
                {
                    P_Workbench tableWorkbench = new P_Workbench();

                    tableWorkbench.Workbench = workbench;
                    tableWorkbench.Remark    = remark;

                    dataContxt.P_Workbench.InsertOnSubmit(tableWorkbench);
                    dataContxt.SubmitChanges();

                    returnWorkbench = Workbenchs;

                    return(true);
                }
                else
                {
                    error = "已存在该工位信息不允许重复添加";
                    return(false);
                }
            }
            catch (Exception err)
            {
                error = err.Message;
                return(false);
            }
        }
        /// <summary>
        /// 添加材料类别编码表记录
        /// </summary>
        /// <param name="depotForPersonnel">要添加的数据集合</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回True,操作失败返回False</returns>
        public bool AddDepotForPersonnel(S_DepotTypeForPersonnel depotForPersonnel, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result_ZL = from c in dataContxt.S_DepotTypeForPersonnel
                                where c.ZlID == depotForPersonnel.ZlID
                                select c;

                var result_Personnel = from c in dataContxt.S_DepotTypeForPersonnel
                                       where c.PersonnelID == depotForPersonnel.PersonnelID
                                       select c;

                if (result_ZL.Count() == 0 && result_Personnel.Count() == 0)
                {
                    dataContxt.S_DepotTypeForPersonnel.InsertOnSubmit(depotForPersonnel);
                    dataContxt.SubmitChanges();
                }
                else if (result_ZL.Count() != 0)
                {
                    error = string.Format("材料类别编码 {0} 已经存在, 不允许重复添加", depotForPersonnel.ZlID);
                    return(false);
                }
                else if (result_Personnel.Count() != 0)
                {
                    error = string.Format("材料管理人 {0} 已经存在, 不允许重复添加", depotForPersonnel.PersonnelName);
                    return(false);
                }
                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 删除材料类别表记录
        /// </summary>
        /// <param name="depotCode">材料类别编码</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回True,操作失败返回False</returns>
        public bool DeleteBill(string depotCode, out string error)
        {
            try
            {
                error = null;

                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                Table <S_Depot> table = dataContxt.GetTable <S_Depot>();

                var delRow = from c in table
                             where c.DepotCode == depotCode
                             select c;

                var CheckStock = from a in dataContxt.View_S_Stock
                                 where a.材料类别编码 == depotCode
                                 select a;

                if (CheckStock.Count() != 0)
                {
                    error = "材料仍存有此类物品,请执行材料调拨后才可删除此类别!";
                    return(false);
                }

                foreach (var ei in delRow)
                {
                    table.DeleteOnSubmit(ei);
                }

                dataContxt.SubmitChanges();

                return(true);
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="djh">单据号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>删除成功返回True,删除失败返回False</returns>
        public bool DeleteBill(string djh, out string error)
        {
            error = null;
            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                var varData = from a in dataContext.S_TechnologyChangeBill
                              where a.DJH == djh
                              select a;

                if (varData.Count() != 1)
                {
                    error = "数据不唯一或者为空";
                    return(false);
                }
                else
                {
                    if (varData.Single().DJZT == "单据已完成")
                    {
                        error = "不能删除已完成的单据";
                        return(false);
                    }

                    S_TechnologyChangeBill lnqbill = varData.Single();
                    //lnqbill.DJZT = "已报废";
                    dataContext.S_TechnologyChangeBill.DeleteOnSubmit(varData.Single());
                }

                dataContext.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Esempio n. 29
0
        /// <summary>
        /// 更新文件路径
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="guid">文件编号集字符串</param>
        /// <param name="address">上传文件存放位置</param>
        public void UpdateFilePath(string billNo, string guid, string address)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.Bus_Quality_8DReport
                          where a.BillNo == billNo
                          select a;

            if (varData.Count() == 1)
            {
                if (address == "D1")
                {
                    varData.Single().D1_DescribePhenomenon_Accessory = guid;
                }
                else if (address == "D5")
                {
                    varData.Single().D5_ReasonAnalysis_Accessory = guid;
                }
            }

            ctx.SubmitChanges();
        }
Esempio n. 30
0
        /// <summary>
        /// 审核单据
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool AuditBill(string billNo, out string error)
        {
            error = null;

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            try
            {
                var varData = from a in ctx.WS_ConsumptionBill
                              where a.BillNo == billNo
                              select a;
                if (varData.Count() != 1)
                {
                    throw new Exception("数据错误,请重新确认");
                }
                else
                {
                    WS_ConsumptionBill tempBill = varData.Single();

                    if (tempBill.BillStatus != ConsumptionBillStatus.等待审核.ToString())
                    {
                        throw new Exception("单据状态错误,请重新确认");
                    }

                    tempBill.BillStatus = ConsumptionBillStatus.等待确认.ToString();
                    tempBill.Audit      = BasicInfo.LoginName;
                    tempBill.AuditDate  = ServerTime.Time;

                    ctx.SubmitChanges();
                }

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