示例#1
0
        ///// <summary>
        ///// 把数据保存到审批记录表中
        ///// </summary>
        ///// <param name="gAppvalRecords">数据列表</param>
        ///// <returns></returns>
        //public SavedResult<long> AddAppvalRecord(List<GAppvalRecordModel> gAppvalRecords)
        //{
        //    SavedResult<long> savedResult = new SavedResult<long>();
        //    if(gAppvalRecords.Count > 0)
        //    {
        //        foreach (var gAppvalRecord in gAppvalRecords)
        //        {
        //            //关联单据不能为空
        //            if (gAppvalRecord.RefbillPhid < 1)
        //            {
        //                throw new Exception("关联单据不能为空!");
        //            }
        //            //关联流程不能为空
        //            if (gAppvalRecord.ProcPhid < 1)
        //            {
        //                throw new Exception("关联流程不能为空!");
        //            }
        //            //关联岗位不能为空
        //            if (gAppvalRecord.PostPhid < 1)
        //            {
        //                throw new Exception("关联岗位不能为空!");
        //            }
        //            //关联审批管理员不能为空
        //            if (gAppvalRecord.OperaPhid < 1)
        //            {
        //                throw new Exception("关联审批管理员不能为空!");
        //            }
        //            //审批状态传递有误
        //            if (gAppvalRecord.FApproval != (byte)ApprovalType.pend)
        //            {
        //                throw new Exception("审批状态传递有误!");
        //            }
        //        }
        //        Dictionary<string, object> dic = new Dictionary<string, object>();
        //        new CreateCriteria(dic)
        //                .Add(ORMRestrictions<long>.Eq("RefbillPhid", gAppvalRecords[0].RefbillPhid));
        //        var result = this.GAppvalRecordRule.Find(dic);
        //        if(result.Count > 0)
        //        {
        //            byte fApproval = gAppvalRecords[0].FApproval;
        //            foreach (var res in result)
        //            {
        //                res.FApproval = fApproval;
        //                res.PersistentState = PersistentState.Modified;
        //            }
        //            savedResult = this.GAppvalRecordRule.Save<long>(result);
        //        }
        //        else
        //        {
        //            foreach(var gAppvalRecord in gAppvalRecords)
        //            {
        //                gAppvalRecord.PersistentState = PersistentState.Added;
        //            }
        //            savedResult = this.GAppvalRecordRule.Save<long>(gAppvalRecords);
        //        }
        //    }
        //    return savedResult;
        //}

        /// <summary>
        /// 更新资金拨付单的审批状态
        /// </summary>
        /// <param name="phid">单据id</param>
        /// <param name="fApproval">审批状态</param>
        /// <returns></returns>
        public SavedResult <long> UpdatePayment(long phid, byte fApproval)
        {
            if (phid == 0)
            {
                return(null);
            }

            PaymentMstModel paymentMst = PaymentMstRule.Find(phid);

            paymentMst.FApproval       = fApproval;
            paymentMst.PersistentState = PersistentState.Modified;

            return(PaymentMstRule.Save <Int64>(paymentMst));
        }
示例#2
0
        /// <summary>
        /// 获取资金拨付支付单信息
        /// </summary>
        /// <param name="phid">支付单主键</param>
        /// <returns></returns>
        public GKPayment4ZjbfModel GetPayment4Zjbf(Int64 phid)
        {
            GKPayment4ZjbfModel ret = null;

            GKPaymentMstModel mst = this.EntRule.Find(phid);

            if (mst != null)
            {
                ret = new GKPayment4ZjbfModel();
                //去业务单查部门名称
                PaymentMstModel paymentMst = PaymentMstRule.Find(mst.RefbillPhid);
                mst.fdepname = paymentMst.FDepname;
                mst.FOrgname = paymentMst.FOrgname;

                Dictionary <string, object> where = new Dictionary <string, object>();
                new CreateCriteria(where).Add(ORMRestrictions <Int64> .Eq("MstPhid", mst.PhId));
                //查询相关明细数据
                var dtlList = this.GKPaymentDtlRule.Find(where, new string[] { "QtKmdm Asc" }); //PVoucherDelService.Find(where, new string[] { "SortCode Asc" }).Data.ToList();QtKmdm

                if (dtlList.Count > 0)
                {
                    long mstPhid = mst.RefbillPhid;
                    Dictionary <string, object> where2 = new Dictionary <string, object>();
                    new CreateCriteria(where2).Add(ORMRestrictions <Int64> .Eq("MstPhid", mstPhid));

                    //资金拨付单对应项目信息
                    var bfXmList = this.PaymentXmRule.Find(where2);

                    //资金拨付单明细表
                    var bfDtlList = this.PaymentDtlRule.Find(where2);


                    var       newCodeDt = this.GetPaymentNewCodeDataTable(mst.RefbillPhid);
                    DataRow[] drs       = null;
                    Dictionary <string, string> dicNewCode = null;
                    Dictionary <string, string> dicNewCodeMstPhid = null;
                    string fNewCode = string.Empty, fNewCodeMstPhid = string.Empty;
                    string old_phid = string.Empty;

                    //给明细表赋值,写入扩展字段信息

                    ret.Mst  = mst;
                    ret.Dtls = new List <GKPaymentDtl4ZjbfModel>();

                    GKPaymentDtl4ZjbfModel        dtl4Zjbf = null;
                    PaymentDtlModel               bfDtl    = null;
                    PaymentXmModel                bfXm     = null;
                    IEnumerable <PaymentDtlModel> enuDtl   = null;
                    IEnumerable <PaymentXmModel>  enuXm    = null;


                    Dictionary <string, object> dicOrg = new Dictionary <string, object>();
                    new CreateCriteria(dicOrg)
                    .Add(ORMRestrictions <long> .NotEq("PhId", 0));
                    IList <OrganizeModel> OrgList = OrganizationRule.Find2(dicOrg);
                    //补充完善明细信息
                    foreach (GKPaymentDtlModel dtl in dtlList)
                    {
                        dtl4Zjbf = CommonUtils.TransReflection <GKPaymentDtlModel, GKPaymentDtl4ZjbfModel>(dtl);

                        if (bfDtlList.Count > 0)
                        {
                            enuDtl = bfDtlList.Where(x => x.PhId == dtl.RefbillDtlPhid && x.BudgetdtlPhid == dtl.RefbillDtlPhid2);
                            if (enuDtl.Count() > 0)
                            {
                                bfDtl = enuDtl.First();
                                if (string.IsNullOrEmpty(dtl.QtKmdm))
                                {
                                    dtl4Zjbf.QtKmdm = bfDtl.QtKmdm; //预算科目
                                    dtl4Zjbf.QtKmmc = bfDtl.QtKmmc; //预算科目名称
                                }

                                dtl4Zjbf.FDepartmentcode = bfDtl.FDepartmentcode;   //补助单位/部门代码
                                OrganizeModel Org = OrgList.ToList().Find(x => x.OCode == bfDtl.FDepartmentcode);
                                dtl4Zjbf.FDepartmentphid = Org.PhId;
                                dtl4Zjbf.FDepartmentname = bfDtl.FDepartmentname;   //补助单位/部门名称
                                if (Org.IfCorp == "N")
                                {
                                    OrganizeModel Org2 = OrgList.ToList().Find(x => x.PhId == Org.ParentOrgId);
                                    dtl4Zjbf.FDepartmentParentcode = Org2.OCode;
                                    dtl4Zjbf.FDepartmentParentphid = Org2.PhId;
                                    dtl4Zjbf.FDepartmentParentname = Org2.OName;
                                }

                                dtl4Zjbf.BudgetdtlName = bfDtl.BudgetdtlName;       //预算明细项目名称

                                //预算项目
                                enuXm = bfXmList.Where(x => x.PhId == bfDtl.PayXmPhid);
                                if (enuXm.Count() > 0)
                                {
                                    bfXm = enuXm.First();
                                    dtl4Zjbf.XmProjcode = bfXm.XmProjcode;
                                    dtl4Zjbf.XmProjname = bfXm.XmProjname;
                                    dtl4Zjbf.FSeq       = bfXm.FSeq;
                                }
                            }
                        }

                        //写重新支付单的单号
                        if (newCodeDt != null && newCodeDt.Rows.Count > 0)
                        {
                            dicNewCode         = new Dictionary <string, string>();
                            dicNewCodeMstPhid  = new Dictionary <string, string>();
                            dtl4Zjbf.FNewCodes = "";

                            //drs = newCodeDt.Select("ng_insert_dt>=#" + dtl.NgInsertDt.ToString("yyyy-MM-dd HH:mm:ss") + "#");
                            drs = newCodeDt.Select(string.Format("phid ={0}", dtl.PhId));
                            while (drs.Length > 0)
                            {
                                foreach (var row in drs)
                                {
                                    fNewCode = row["f_new_code"].ToString();
                                    if (!string.IsNullOrEmpty(fNewCode))
                                    {
                                        if (!dicNewCode.ContainsKey(fNewCode))
                                        {
                                            dicNewCode.Add(fNewCode, fNewCode);
                                        }
                                    }
                                }
                                old_phid = drs[0]["phid"].ToString();
                                if (!string.IsNullOrEmpty(old_phid))
                                {
                                    drs = newCodeDt.Select(string.Format("old_dtl_phid={0}", old_phid));
                                    if (drs.Length > 0)
                                    {
                                        fNewCodeMstPhid = drs[0]["mst_phid"].ToString();
                                        if (!dicNewCodeMstPhid.ContainsKey(fNewCodeMstPhid))
                                        {
                                            dicNewCodeMstPhid.Add(fNewCodeMstPhid, fNewCodeMstPhid);
                                        }
                                    }
                                }
                                else
                                {
                                    drs = newCodeDt.Select("1=2");
                                }
                            }

                            dtl4Zjbf.FNewCodes        = string.Join(",", dicNewCode.Values.ToArray());
                            dtl4Zjbf.FNewCodesMstPhid = string.Join(",", dicNewCodeMstPhid.Values.ToArray());
                        }

                        ret.Dtls.Add(dtl4Zjbf);
                    }
                }
                ret.Dtls = ret.Dtls.OrderBy(t => t.FSeq).ToList();
            }


            return(ret);
        }