示例#1
0
        /// <summary>
        /// 处理调整后明细,加入新条目。
        /// </summary>
        /// <param name="stage"></param>
        /// <param name="beforeAdjustDetail"></param>
        /// <param name="afterString"></param>
        /// <param name="Database"></param>
        private void processAfterAdjustDetail(Ipms.Server.Business.Adjusts.Adjust adjust, int stage, BeforeAdjustDetail beforeAdjustDetail, string afterString, Server.DataAccess.Database Database)
        {
            var afterItems = afterString.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var afterItem in afterItems)
            {
                var afterDetails = afterItem.Split(new string[] { "," }, StringSplitOptions.None);
                if (afterDetails.Count() != 2)
                    throw new Exception("调整后条目参数不正确!");
                else
                {
                    //设备
                    var device = Database.ApplyDevices.SingleOrDefault(c => c.ID.ToString() == afterDetails[0].Trim());
                    //设备数目
                    var amount = Convert.ToInt32(afterDetails[1].Trim());
                    //新建调整后条目
                    var afterAdjustDetail = new AfterAdjustDetail();
                    afterAdjustDetail.Adjust = adjust;
                    //新建申购条目
                    MemberApplyItem memberApplyItem = new MemberApplyItem();
                    memberApplyItem.IsAfterAdjust = true;
                    memberApplyItem.IsBeforeAdjust = false;
                    memberApplyItem.MemberApply = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.MemberApply;
                    memberApplyItem.ApplyDevice = device;
                    memberApplyItem.LogicDevice = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.LogicDevice;
                    memberApplyItem.CurrentState = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.CurrentState;
                    memberApplyItem.Quantity = amount;
                    memberApplyItem.Rank = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.Rank;
                    memberApplyItem.Applicant = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.Applicant;
                    memberApplyItem.ApplicantName = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.ApplicantName;
                    memberApplyItem.PhoneNumber = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.PhoneNumber;
                    memberApplyItem.Email = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.Email;
                    memberApplyItem.ModifyTime = System.DateTime.Now;
                    // memberApplyItem.ModifyBy = User;
                    memberApplyItem.Link_url = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.Link_url;
                    memberApplyItem.IconCls = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.IconCls;
                    MemberApplyItemStatic newstatic = new MemberApplyItemStatic();
                    newstatic.Save(Database);
                    memberApplyItem.MemberApplyItemStatic = newstatic;
                    memberApplyItem.Save(Database);

                    //新建建设计划条目
                    ConstructPlanItem constructPlanItem = new ConstructPlanItem();
                    constructPlanItem.MemberApplyItem = memberApplyItem;
                    var DeviceNumberString = "TZ" + beforeAdjustDetail.ConstructPlanItem.DeviceNumber + adjust.Count.ToString();
                    adjust.Count++;
                    adjust.Save(Database);
                    while (Database.ConstructPlanItems.SingleOrDefault(c => c.DeviceNumber == DeviceNumberString) != null)
                    {
                        DeviceNumberString = DeviceNumberString.Substring(0, DeviceNumberString.Length - 2) + (Convert.ToInt16(DeviceNumberString.Substring(DeviceNumberString.Length - 2, 2)) + 1).ToString("00");
                    }

                    constructPlanItem.DeviceNumber = DeviceNumberString;
                    constructPlanItem.ConstructPlanPackage = beforeAdjustDetail.ConstructPlanItem.ConstructPlanPackage;
                    //预算金额默认为申购单价乘以数量,规则待定
                    constructPlanItem.BudgetAmount = beforeAdjustDetail.ConstructPlanItem.MemberApplyItem.ApplyDevice.UnitPrice * amount;
                    constructPlanItem.IsBeforeAdjust = false;
                    constructPlanItem.IsAfterAdjust = true;
                    constructPlanItem.Save(Database);

                    afterAdjustDetail.ConstructPlanItem = constructPlanItem;

                    //建设任务之后的阶段时,新建建设任务
                    if (stage > 0)
                    {
                        ConstructTaskItem constructTaskItem = new ConstructTaskItem();
                        constructTaskItem.Quantity = amount;
                        constructTaskItem.ConstructTask = beforeAdjustDetail.ConstructTaskItem.ConstructTask;
                        constructTaskItem.ConstructTask.IsSend = false;
                        constructTaskItem.ConstructPlanItem = constructPlanItem;
                        constructTaskItem.IsPurchasePlanItem = false;
                        constructTaskItem.IsBeforeAdjust = false;
                        constructTaskItem.IsAfterAdjust = true;
                        constructTaskItem.Save(Database);
                        afterAdjustDetail.ConstructTaskItem = constructTaskItem;

                        ////采购计划之后的阶段时,新建采购计划
                        //if (stage > 1)
                        //{
                        //    var purchasePlanItem = new PurchasePlanItem();
                        //    purchasePlanItem.PurchasePlanPackage = beforeAdjustDetail.PurchasePlanItem.PurchasePlanPackage;
                        //    purchasePlanItem.ConstructTaskItem = constructTaskItem;
                        //    //成员是否确认,默认未确认。可修改
                        //    purchasePlanItem.IsAffirm = false;
                        //    purchasePlanItem.IsBeforeAdjust = false;
                        //    purchasePlanItem.IsAfterAdjust = true;
                        //    purchasePlanItem.Save(Database);
                        //    afterAdjustDetail.PurchasePlanItem = purchasePlanItem;
                        //    //采购计划之后的阶段时,新建采购计划
                        //    if (stage > 2)
                        //    {
                        //        //流标的条目下达采购指令
                        //        var purchaseOrderItem = new PurchaseOrderItem();
                        //        purchaseOrderItem.PurchasePlanItem = purchasePlanItem;
                        //        purchaseOrderItem.IsAfterAdjust = true;
                        //        purchaseOrderItem.PurchaseOrderPackage = Database.PurchaseOrderPackages.SingleOrDefault(c => c.PurchasePlanPackage == beforeAdjustDetail.PurchasePlanItem.PurchasePlanPackage);
                        //        purchaseOrderItem.Save(Database);
                        //    }
                        //}

                    }
                    afterAdjustDetail.Save(Database);
                }
            }
        }
示例#2
0
 public void Save()
 {
     var expertApplyItem = Request.GetExpertApplyItem(User, Database);
     using (TransactionScope ts = new TransactionScope())
     {
         if (expertApplyItem.MemberApplyItemStatic == null)
         {
             MemberApplyItemStatic newstatic=new MemberApplyItemStatic();
             newstatic.Save(Database);
             expertApplyItem.MemberApplyItemStatic = newstatic;
         }
         expertApplyItem.Save(Database);
         if (!Request.GetBoolean("IsCommit").Value)
         {
             expertApplyItem.ActiveStateMachine(expertApplyItem.ID, Database, User, StateMachineAction.Edit);
             var itemInfo = string.Format("成员:{0},向项目:{1},项目ID:{2},保存成员申购条目ID:{3},申购数量:{4}", User.Name, expertApplyItem.MemberApply.Project.ProjectName, expertApplyItem.MemberApply.Project.ID, expertApplyItem.ID, expertApplyItem.Quantity);
             BusinessLog.Write(User, UserIP, itemInfo, this.GetType().FullName, "Save", Database);
         }
         else
         {
             expertApplyItem.ActiveStateMachine(expertApplyItem.ID, Database, User, StateMachineAction.MemberCommit);
             var itemInfo = string.Format("成员:{0},向项目:{1},项目ID:{2},提交成员申购条目ID:{3},申购数量:{4}", User.Name, expertApplyItem.MemberApply.Project.ProjectName, expertApplyItem.MemberApply.Project.ID, expertApplyItem.ID, expertApplyItem.Quantity);
             BusinessLog.Write(User, UserIP, expertApplyItem.MemberApply.Project.ProjectName + User.Name + "提交成员申购条目" + expertApplyItem.ApplyDevice.DeviceName, this.GetType().FullName, "Save", Database);
         }
         ts.Complete();
     }
     if (expertApplyItem.CurrentState == MemberApplyState.WaitingManagerCensor && User != expertApplyItem.MemberApply.Project.Manager)
     {
         //var content = String.Format(@"项目:{0},项目成员{1},于{2},{3}。{4}。", expertApplyItem.MemberApply.Project.ProjectName, expertApplyItem.MemberApply.Member.Name, DateTime.Now, "提交了设备申购", "请及时查看并审核");
         //var content = String.Format("yes,PurchaseOrderPackage,");
         if (Database.MemberApplyItems.Where(ma => ma.MemberApplyID == expertApplyItem.MemberApplyID && expertApplyItem.CurrentState == MemberApplyState.WaitingManagerCensor).Count() == 1)
             Message.SendPackageMessage(expertApplyItem.MemberApply.Member.Name + "--" + expertApplyItem.ApplyDevice.DeviceName + "--提交设备申购", "yes,ExpertApply," + expertApplyItem.MemberApplyID, User, expertApplyItem.MemberApply.Project.Manager, Database, MessageType.System);
     }
 }