/// <summary>
        /// 删除所关联的所有CVT出厂检验记录
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="djh">关联单据号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>删除成功返回True,删除失败返回False</returns>
        public bool DeleteDeliveryInspection(DepotManagementDataContext dataContext, string djh, out string error)
        {
            error = null;

            try
            {
                var varData = from a in dataContext.P_DeliveryInspection
                              where a.AssociatedBillNo == djh
                              select a;

                foreach (var item in varData)
                {
                    var varList = from a in dataContext.P_DeliveryInspectionItems
                                  where a.DJH == item.DJH
                                  select a;

                    dataContext.P_DeliveryInspectionItems.DeleteAllOnSubmit(varList);

                    m_assignBill.CancelBillNo(dataContext, CE_BillTypeEnum.CVT出厂检验记录表.ToString(), item.DJH);

                    dataContext.P_DeliveryInspection.DeleteOnSubmit(item);
                }

                dataContext.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 删除普通入库单
        /// </summary>
        /// <param name="billNo">入库单号</param>
        /// <param name="returnInfo">普通入库单</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>返回是否成功删除普通入库单号</returns>
        public bool DeleteBill(string billNo, out IQueryResult returnInfo, out string error)
        {
            returnInfo = null;
            error      = null;

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

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

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

                table.DeleteAllOnSubmit(delRow);

                m_assignBill.CancelBillNo(dataContxt, "普通入库单", billNo);

                if (!m_serverFrockStandingBook.DeleteFrockOrdinaryInDepotBill(dataContxt, billNo, out error))
                {
                    return(false);
                }

                dataContxt.SubmitChanges();

                return(GetAllBill(out returnInfo, out error));
            }
            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 DeleteBill(string billNo, out IQueryResult returnBill, out string error)
        {
            returnBill = null;
            error      = null;

            try
            {
                IsolationManageBill          serverIsolation = new IsolationManageBill();
                DepotManagementDataContext   dataContxt      = CommentParameter.DepotDataContext;
                Table <S_MaterialRejectBill> table           = dataContxt.GetTable <S_MaterialRejectBill>();

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

                m_assignBill.CancelBillNo(dataContxt, "采购退货单", billNo);

                if (!serverIsolation.ClearBillDate(dataContxt, billNo, out error))
                {
                    return(false);
                }

                table.DeleteAllOnSubmit(delRow);

                dataContxt.SubmitChanges();

                return(GetAllBill(out returnBill, out error));
            }
            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 DeleteBill(string billNo, out IQueryResult returnBill, out string error)
        {
            returnBill = null;
            error      = null;

            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                Table <S_MaterialReturnedInTheDepot> table = ctx.GetTable <S_MaterialReturnedInTheDepot>();
                var delRow = from c in table where c.Bill_ID == billNo select c;

                m_assignBill.CancelBillNo(ctx, "领料退库单", billNo);

                table.DeleteAllOnSubmit(delRow);

                //对于营销的总称领料的删除
                var varData = from a in ctx.ProductsCodes
                              where a.DJH == billNo
                              select a;

                ctx.ProductsCodes.DeleteAllOnSubmit(varData);

                ctx.SubmitChanges();

                return(GetAllBill(out returnBill, out error));
            }
            catch (Exception exce)
            {
                error = exce.Message;
                return(false);
            }
        }
        /// <summary>
        /// 根据普通入库单号删除工装台帐与工装验证报告单
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="billNo">普通入库单号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回True,操作失败返回False</returns>
        public bool DeleteFrockOrdinaryInDepotBill(DepotManagementDataContext ctx, string billNo, out string error)
        {
            error = null;

            try
            {
                var varData = from a in ctx.S_FrockProvingReport
                              where a.ConnectBillNumber == billNo
                              select a;

                foreach (var item in varData)
                {
                    var varStanding = from a in ctx.S_FrockStandingBook
                                      where a.GoodsID == item.GoodsID &&
                                      a.FrockNumber == item.FrockNumber
                                      select a;

                    ctx.S_FrockStandingBook.DeleteAllOnSubmit(varStanding);

                    var varAttached = from a in ctx.S_FrockProvingReportAttached
                                      where a.DJH == item.DJH
                                      select a;

                    ctx.S_FrockProvingReportAttached.DeleteAllOnSubmit(varAttached);

                    ctx.S_FrockProvingReport.DeleteOnSubmit(item);

                    m_assignBill.CancelBillNo(ctx, "工装验证报告单", item.DJH);
                    m_billMessageServer.DestroyMessage(item.DJH);
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 自动生成领料单
        /// </summary>
        /// <param name="billID">售后服务配件申请单单号且为生成后的领料单的关联单据</param>
        /// <param name="storageID">库房ID</param>
        /// <param name="error">失败时返回的错误信息</param>
        /// <returns>True  自动生成成功,False 自动生成失败</returns>
        public bool AutogenerationMaterialRequisition(string billID, string storageID,
                                                      out string error)
        {
            error = null;
            string strMaterialBillID = "";
            string strOutMessage     = "";

            try
            {
                DataTable dtListOfStraogeID = GetListStorageID(billID);

                if (dtListOfStraogeID.Rows.Count == 0)
                {
                    throw new Exception("此物品无【领料清单】相关信息,无法生成领料单");
                }
                else
                {
                    DataTable tempGoodsTable = GetSumRequestCount(billID);

                    for (int k = 0; k < dtListOfStraogeID.Rows.Count; k++)
                    {
                        MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer();

                        DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                        strMaterialBillID = m_Assignbill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString());

                        S_MaterialRequisition lnqMaterialBill = new S_MaterialRequisition();

                        lnqMaterialBill.AssociatedBillNo   = "";
                        lnqMaterialBill.AssociatedBillType = "";
                        lnqMaterialBill.Bill_ID            = strMaterialBillID;
                        lnqMaterialBill.Bill_Time          = ServerTime.Time;
                        lnqMaterialBill.BillStatus         = "新建单据";
                        lnqMaterialBill.Department         = m_serverDepartment.GetDeptInfoFromPersonnelInfo(
                            BasicInfo.LoginName).Rows[0]["DepartmentCode"].ToString();
                        lnqMaterialBill.DepartmentDirector  = "";
                        lnqMaterialBill.DepotManager        = "";
                        lnqMaterialBill.FetchCount          = 0;
                        lnqMaterialBill.FetchType           = "零星领料";
                        lnqMaterialBill.FillInPersonnel     = BasicInfo.LoginName;
                        lnqMaterialBill.FillInPersonnelCode = BasicInfo.LoginID;
                        lnqMaterialBill.ProductType         = "";
                        lnqMaterialBill.PurposeCode         = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.包外装配).Code;
                        lnqMaterialBill.Remark    = "由系统自动生成  售后服务配件制造申请单【" + billID + "】";
                        lnqMaterialBill.StorageID = dtListOfStraogeID.Rows[k][0].ToString();

                        int rowCount = tempGoodsTable.Rows.Count;

                        if (!InsertMaterialRequisitionList(ctx, ref tempGoodsTable, lnqMaterialBill.StorageID,
                                                           strMaterialBillID, out error))
                        {
                            m_Assignbill.CancelBillNo("领料单", strMaterialBillID);
                            return(false);
                        }

                        if (error != null && error.Contains("【图号型号】"))
                        {
                            strOutMessage = "【领料单号】:" + strMaterialBillID + "\r\n" + error;
                        }

                        //tempGoodsTable = GlobalObject.DataSetHelper.SiftDataTable(tempGoodsTable, "RequestCount > 0", out error);

                        //if (rowCount == tempGoodsTable.Rows.Count)
                        //{
                        //    continue;
                        //}

                        if (!serverMaterialBill.AutoCreateBill(ctx, lnqMaterialBill, out error))
                        {
                            throw new Exception(error);
                        }
                        //ctx.S_MaterialRequisition.InsertOnSubmit(lnqMaterialBill);

                        ctx.SubmitChanges();
                    }
                }

                error = strOutMessage;
                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                m_Assignbill.CancelBillNo("领料单", strMaterialBillID);
                return(false);
            }
        }
Пример #7
0
 /// <summary>
 /// 取消分配了又没有用到的单据
 /// </summary>
 /// <param name="billNo">要取消的单据号</param>
 public void CancelBill(string billNo)
 {
     m_assignBill.CancelBillNo(m_billType.ToString(), billNo);
 }
Пример #8
0
        /// <summary>
        /// 更新单据状态
        /// </summary>
        /// <param name="outSourcing">Linq操作数据集</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>更新成功返回True,更新失败返回False</returns>
        public bool UpdateBill(S_CheckOutInDepotForOutsourcingBill outSourcing, out string error)
        {
            error = null;

            string mrBillNo = null;

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            ctx.Connection.Open();
            ctx.Transaction = ctx.Connection.BeginTransaction();
            try
            {
                var varData = from a in ctx.S_CheckOutInDepotForOutsourcingBill
                              where a.Bill_ID == outSourcing.Bill_ID
                              select a;

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

                    if (lnqOutsourcing.BillStatus != outSourcing.BillStatus)
                    {
                        error = "单据状态错误,请重新刷新单据确认单据状态";
                        throw new Exception(error);
                    }

                    switch (lnqOutsourcing.BillStatus)
                    {
                    case "等待财务批准":
                        lnqOutsourcing.BillStatus       = "等待仓管确认到货";
                        lnqOutsourcing.UnitPrice        = outSourcing.UnitPrice;
                        lnqOutsourcing.Price            = outSourcing.Price;
                        lnqOutsourcing.RawMaterialPrice = outSourcing.RawMaterialPrice;
                        lnqOutsourcing.FinancePersonnel = BasicInfo.LoginName;
                        lnqOutsourcing.FinanceTime      = ServerTime.Time;
                        break;

                    case "等待仓管确认到货":
                        lnqOutsourcing.BillStatus = outSourcing.QualityInfo;
                        lnqOutsourcing.DepotManagerAffirmCount = outSourcing.DepotManagerAffirmCount;
                        lnqOutsourcing.Price           = outSourcing.Price;
                        lnqOutsourcing.ArrivePersonnel = BasicInfo.LoginName;
                        lnqOutsourcing.ArriveTime      = ServerTime.Time;
                        break;

                    case "等待质检机检验":
                        lnqOutsourcing.BillStatus          = "等待质量主管审核";
                        lnqOutsourcing.CheckoutReport_ID   = outSourcing.CheckoutReport_ID;
                        lnqOutsourcing.Checker             = outSourcing.Checker;
                        lnqOutsourcing.EligibleCount       = outSourcing.EligibleCount;
                        lnqOutsourcing.ConcessionCount     = outSourcing.ConcessionCount;
                        lnqOutsourcing.ReimbursementCount  = outSourcing.ReimbursementCount;
                        lnqOutsourcing.DeclareWastrelCount = outSourcing.DeclareWastrelCount;
                        lnqOutsourcing.QualityInfo         = outSourcing.QualityInfo;
                        lnqOutsourcing.PeremptorilyEmit    = outSourcing.PeremptorilyEmit;
                        lnqOutsourcing.QualityPersonnel    = BasicInfo.LoginName;
                        lnqOutsourcing.QualityTime         = ServerTime.Time;
                        break;

                    case "等待质检电检验":
                        lnqOutsourcing.BillStatus          = "等待质量主管审核";
                        lnqOutsourcing.CheckoutReport_ID   = outSourcing.CheckoutReport_ID;
                        lnqOutsourcing.Checker             = outSourcing.Checker;
                        lnqOutsourcing.EligibleCount       = outSourcing.EligibleCount;
                        lnqOutsourcing.ConcessionCount     = outSourcing.ConcessionCount;
                        lnqOutsourcing.ReimbursementCount  = outSourcing.ReimbursementCount;
                        lnqOutsourcing.DeclareWastrelCount = outSourcing.DeclareWastrelCount;
                        lnqOutsourcing.QualityInfo         = outSourcing.QualityInfo;
                        lnqOutsourcing.PeremptorilyEmit    = outSourcing.PeremptorilyEmit;
                        lnqOutsourcing.QualityPersonnel    = BasicInfo.LoginName;
                        lnqOutsourcing.QualityTime         = ServerTime.Time;
                        break;

                    case "等待质量主管审核":
                        lnqOutsourcing.BillStatus          = "等待入库";
                        lnqOutsourcing.IsOnlyForRepairFlag = outSourcing.IsOnlyForRepairFlag;
                        lnqOutsourcing.QASupervisor        = BasicInfo.LoginName;
                        lnqOutsourcing.QASupervisorTime    = ServerTime.Time;
                        break;

                    case "等待入库":
                        lnqOutsourcing.BillStatus       = "已入库";
                        lnqOutsourcing.Price            = outSourcing.Price;
                        lnqOutsourcing.InDepotCount     = outSourcing.InDepotCount;
                        lnqOutsourcing.ShelfArea        = outSourcing.ShelfArea;
                        lnqOutsourcing.ColumnNumber     = outSourcing.ColumnNumber;
                        lnqOutsourcing.LayerNumber      = outSourcing.LayerNumber;
                        lnqOutsourcing.ManagerPersonnel = BasicInfo.LoginName;
                        lnqOutsourcing.ManagerTime      = ServerTime.Time;

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

                        //若勾选了“包含原材料费”并且报废数大于0,则插入报废单
                        if (outSourcing.IsExigenceCheck && outSourcing.DeclareWastrelCount > 0)
                        {
                            if (!AddScrapBill(ctx, lnqOutsourcing, out error))
                            {
                                throw new Exception(error);
                            }
                        }

                        ctx.SubmitChanges();

                        if ((int)outSourcing.DeclareWastrelCount > 0 && outSourcing.InDepotCount > 0)
                        {
                            if (!InsertIntoMaterialRequisition(ctx, outSourcing, out mrBillNo, out error))
                            {
                                m_assignBill.CancelBillNo(CE_BillTypeEnum.领料单.ToString(), mrBillNo);
                                ReturnBillInDepot(lnqOutsourcing.Bill_ID, mrBillNo, out error);
                                throw new Exception(error);
                            }
                        }

                        break;

                    default:
                        break;
                    }

                    ctx.SubmitChanges();
                }

                ctx.Transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                error = ex.Message;
                return(false);
            }
        }