Ejemplo n.º 1
0
        /// <summary>
        /// 操作流程以外的业务
        /// </summary>
        /// <param name="billNo">单据号</param>
        public void OperatarUnFlowBusiness(string billNo)
        {
            IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>();

            string billStatus = serviceFlow.GetNextBillStatus(billNo);

            if (billStatus == null)
            {
                throw new Exception("单据状态为空,请重新确认");
            }

            if (billStatus != CE_CommonBillStatus.单据完成.ToString())
            {
                return;
            }

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

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

            try
            {
                dataContxt.ExecuteCommand("exec BASE_PBOM_SaveSysVersion {0}", billNo);
                dataContxt.Transaction.Commit();
            }
            catch (Exception ex)
            {
                dataContxt.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 操作流程以外的业务
        /// </summary>
        /// <param name="billNo">单据号</param>
        public void OperatarUnFlowBusiness(string billNo)
        {
            IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>();

            string billStatus = serviceFlow.GetNextBillStatus(billNo);

            if (billStatus == null)
            {
                throw new Exception("单据状态为空,请重新确认");
            }

            if (billStatus != CE_CommonBillStatus.单据完成.ToString())
            {
                return;
            }

            DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

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

            try
            {
                List <View_Business_Base_BomChange_Struct>       lstStruct  = GetListStructInfo(billNo);
                List <View_Business_Base_BomChange_PartsLibrary> lstLibrary = GetListLibraryInfo(billNo);

                List <Flow_FlowData> tempList = serviceFlow.GetBusinessOperationInfo(billNo, CE_CommonBillStatus.新建单据.ToString());

                if (tempList == null)
                {
                    throw new Exception("获取操作人员失败");
                }

                JudgeAssembly(dataContxt, lstStruct);
                string personnel = tempList[0].OperationPersonnel;

                #region 零件库变更

                foreach (var item2 in lstLibrary)
                {
                    CE_OperatorMode operationMode =
                        GlobalObject.GeneralFunction.StringConvertToEnum <CE_OperatorMode>(item2.操作类型);

                    switch (operationMode)
                    {
                    case CE_OperatorMode.添加:

                        var varTemp4 = from a in dataContxt.BASE_BomPartsLibrary
                                       where a.GoodsID == item2.物品ID
                                       select a;

                        if (varTemp4 != null && varTemp4.Count() == 1)
                        {
                            BASE_BomPartsLibrary library1 = varTemp4.Single();

                            library1.CreateDate      = ServerTime.Time;
                            library1.CreatePersonnel = personnel;
                            library1.Material        = item2.材质;
                            library1.PartType        = item2.零件类型;
                            library1.PivotalPart     = item2.关键件;
                            library1.Remark          = item2.备注;
                            library1.Version         = item2.版次号;
                        }
                        else if (varTemp4.Count() == 0)
                        {
                            BASE_BomPartsLibrary library = new BASE_BomPartsLibrary();

                            library.CreateDate      = ServerTime.Time;
                            library.CreatePersonnel = personnel;
                            library.GoodsID         = item2.物品ID;
                            library.Material        = item2.材质;
                            library.PartType        = item2.零件类型;
                            library.PivotalPart     = item2.关键件;
                            library.Remark          = item2.备注;
                            library.Version         = item2.版次号;

                            dataContxt.BASE_BomPartsLibrary.InsertOnSubmit(library);
                        }

                        break;

                    case CE_OperatorMode.修改:

                        var varTemp2 = from a in dataContxt.BASE_BomPartsLibrary
                                       where a.GoodsID == item2.物品ID
                                       select a;

                        if (varTemp2 != null && varTemp2.Count() == 1)
                        {
                            BASE_BomPartsLibrary library1 = varTemp2.Single();

                            library1.CreateDate      = ServerTime.Time;
                            library1.CreatePersonnel = personnel;
                            library1.Material        = item2.材质;
                            library1.PartType        = item2.零件类型;
                            library1.PivotalPart     = item2.关键件;
                            library1.Remark          = item2.备注;
                            library1.Version         = item2.版次号;
                        }

                        break;

                    case CE_OperatorMode.除:

                        var varTemp3 = from a in dataContxt.BASE_BomPartsLibrary
                                       where a.GoodsID == item2.物品ID
                                       select a;

                        dataContxt.BASE_BomPartsLibrary.DeleteAllOnSubmit(varTemp3);

                        break;

                    default:
                        break;
                    }
                }

                dataContxt.SubmitChanges();

                #endregion

                #region 结构变更
                var varData = (from a in lstStruct
                               select new { a.父级图号, a.父级物品ID }).Distinct();

                foreach (var item in varData)
                {
                    var varTemp = from a in dataContxt.BASE_BomStruct
                                  where a.ParentID == item.父级物品ID
                                  select a;

                    decimal sysVersion = varTemp.Count() == 0 ? 0 : varTemp.Select(r => r.SysVersion).Distinct().ToList()[0];

                    dataContxt.BASE_BomStruct.DeleteAllOnSubmit(varTemp);
                    dataContxt.SubmitChanges();

                    var varTemp1 = from a in lstStruct
                                   where a.父级物品ID == item.父级物品ID
                                   select a;

                    foreach (var item1 in varTemp1)
                    {
                        if (item1.物品ID == null)
                        {
                            break;
                        }

                        BASE_BomStruct tempStruct = new BASE_BomStruct();

                        tempStruct.CreateDate      = ServerTime.Time;
                        tempStruct.CreatePersonnel = personnel;
                        tempStruct.GoodsID         = (int)item1.物品ID;
                        tempStruct.ParentID        = item1.父级物品ID;
                        tempStruct.Usage           = (decimal)item1.基数;
                        tempStruct.SysVersion      = sysVersion + (decimal)0.01;

                        dataContxt.BASE_BomStruct.InsertOnSubmit(tempStruct);
                    }
                }

                dataContxt.SubmitChanges();
                #endregion

                dataContxt.ExecuteCommand("exec BASE_DBOM_SaveSysVersion {0}", billNo);

                dataContxt.Transaction.Commit();
            }
            catch (Exception ex)
            {
                dataContxt.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }