Example #1
0
        public override bool DoSave()
        {
            //if (!this.ControlManager.CheckControlValue())
            //{
            //    return false;
            //}
            this.ValidateChildren();

            if (!this.ControlManager.SaveCurrent())
                return false;

            凭证 pz = this.ControlManager.DisplayManager.CurrentItem as 凭证;
            pz.操作人 = "会计";
            using (var rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<Hd.Model.凭证>() as Feng.NH.INHibernateRepository)
            {
                try
                {
                    rep.BeginTransaction();

                    decimal sum = 0;

                    pz.凭证费用明细 = new List<凭证费用明细>();
                    foreach (Xceed.Grid.DataRow row in grdFymx.DataRows)
                    {
                        decimal je = Feng.Utils.ConvertHelper.ToDecimal(row.Cells["金额"].Value).Value;
                        sum += je;

                        凭证费用明细 pzfymx = new 凭证费用明细();
                        pzfymx.备注 = (string)row.Cells["备注"].Value;
                        pzfymx.金额 =je;
                        pzfymx.凭证 = pz;
                        pzfymx.凭证费用类别编号 = (int?)row.Cells["凭证费用类别"].Value;
                        pzfymx.收付标志 = Hd.Model.收付标志.付;
                        pzfymx.相关人编号 = (string)付款对象.SelectedDataValue;
                        pzfymx.业务类型编号 = (int?)row.Cells["业务分类"].Value;
                        pzfymx.费用项编号 = (string)row.Cells["费用项"].Value;
                        pzfymx.费用 = new List<费用>();
                        pzfymx.结算期限 = (DateTime?)row.Cells["结算期限"].Value;

                        凭证用途分类 ytfl = (凭证用途分类)用途分类.SelectedDataValue;

                        if (ytfl == 凭证用途分类.业务应付)          // 业务应付
                        {
                            pzfymx.业务类型编号 = (int?)业务分类.SelectedDataValue;
                        }
                        else if (ytfl == 凭证用途分类.其他应付)
                        {
                            pzfymx.业务类型编号 = 111;
                            pzfymx.费用项编号 = "002";
                        }
                        else if (ytfl == 凭证用途分类.其他报销)
                        {
                            pzfymx.费用项编号 = (string)row.Cells["费用项"].Value;
                        }
                        else if (ytfl == 凭证用途分类.业务报销)
                        {
                            普通票 piao = null;
                            普通箱 xiang = null;

                            piao = rep.UniqueResult<Hd.Model.普通票>(NHibernate.Criterion.DetachedCriteria.For<Hd.Model.普通票>()
                                           .Add(NHibernate.Criterion.Expression.Eq("货代自编号", row.Cells["自编号"].Value)));

                            if (piao == null)
                            {
                                throw new InvalidUserOperationException("自编号" + (string)row.Cells["自编号"].Value + "输入有误,请重新输入!");
                            }
                            switch (业务分类.SelectedDataValue.ToString())
                            {
                                case "11":
                                    using (var rep2 = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<Hd.Model.Jk.进口箱>() as Feng.NH.INHibernateRepository)
                                    {

                                        if (row.Cells["箱号"].Value != null)
                                        {
                                            xiang = rep2.UniqueResult<Hd.Model.Jk.进口箱>(NHibernate.Criterion.DetachedCriteria.For<Hd.Model.Jk.进口箱>()
                                                .Add(NHibernate.Criterion.Expression.Eq("箱号", row.Cells["箱号"].Value))
                                                .CreateCriteria("票")
                                                .Add(NHibernate.Criterion.Expression.Eq("货代自编号", row.Cells["自编号"].Value)));

                                            if (xiang == null)
                                            {
                                                throw new InvalidUserOperationException("箱号" + (string)row.Cells["箱号"].Value + "输入有误,请重新输入!");
                                            }
                                        }
                                    }
                                    break;
                                case "15":
                                    using (var rep2 = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<Hd.Model.Jk.进口箱>() as Feng.NH.INHibernateRepository)
                                    {
                                        //piao = rep2.Session.CreateCriteria<Hd.Model.普通票>()
                                        //        .Add(NHibernate.Criterion.Expression.Eq("货代自编号", row.Cells["自编号"].Value))
                                        //        .UniqueResult<Hd.Model.普通票>();
                                        //if (piao == null)
                                        //{
                                        //    throw new InvalidUserOperationException("自编号" + (string)row.Cells["自编号"].Value + "输入有误,请重新输入!");
                                        //}
                                        if (row.Cells["箱号"].Value != null)
                                        {
                                            xiang = rep2.UniqueResult<Hd.Model.Nmcg.内贸出港箱>(NHibernate.Criterion.DetachedCriteria.For<Hd.Model.Nmcg.内贸出港箱>()
                                                .Add(NHibernate.Criterion.Expression.Eq("箱号", row.Cells["箱号"].Value))
                                                .CreateCriteria("票")
                                                .Add(NHibernate.Criterion.Expression.Eq("货代自编号", row.Cells["自编号"].Value)));

                                            if (xiang == null)
                                            {
                                                throw new InvalidUserOperationException("箱号" + (string)row.Cells["箱号"].Value + "输入有误,请重新输入!");
                                            }
                                        }
                                    }
                                    break;
                                case "45":
                                    using (var rep2 = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<Hd.Model.Jk.进口票>() as Feng.NH.INHibernateRepository)
                                    {
                                        //piao = rep2.Session.CreateCriteria<Hd.Model.普通票>()
                                        //        .Add(NHibernate.Criterion.Expression.Eq("货代自编号", row.Cells["自编号"].Value))
                                        //        .UniqueResult<Hd.Model.普通票>();
                                        //if (piao == null)
                                        //{
                                        //    throw new InvalidUserOperationException("自编号" + (string)row.Cells["自编号"].Value + "输入有误,请重新输入!");
                                        //}
                                        if (row.Cells["箱号"].Value != null)
                                        {
                                            xiang = rep2.UniqueResult<Hd.Model.Jk2.进口其他业务箱>(NHibernate.Criterion.DetachedCriteria.For<Hd.Model.Jk2.进口其他业务箱>()
                                               .Add(NHibernate.Criterion.Expression.Eq("箱号", row.Cells["箱号"].Value))
                                               .CreateCriteria("票")
                                               .Add(NHibernate.Criterion.Expression.Eq("货代自编号", row.Cells["自编号"].Value)));

                                            if (xiang == null)
                                            {
                                                throw new InvalidUserOperationException("箱号" + (string)row.Cells["箱号"].Value + "输入有误,请重新输入!");
                                            }
                                        }
                                    }
                                    break;
                                default:
                                    throw new ArgumentException("不合理的业务类型分类!");

                            }

                            NHibernate.Criterion.DetachedCriteria cri = NHibernate.Criterion.DetachedCriteria.For<业务费用>()
                                .Add(NHibernate.Criterion.Expression.Eq("票.ID", piao.ID))
                                .Add(NHibernate.Criterion.Expression.Eq("费用项编号", row.Cells["费用项"].Value))
                                .Add(NHibernate.Criterion.Expression.Eq("收付标志", Hd.Model.收付标志.付));
                            if (xiang != null)
                            {
                                cri = cri.Add(NHibernate.Criterion.Expression.Eq("箱.ID", xiang.ID));
                            }
                            else
                            {
                                cri = cri.Add(NHibernate.Criterion.Expression.IsNull("箱"));
                            }

                            IList<业务费用> list = rep.List<业务费用>(cri);

                            cri = NHibernate.Criterion.DetachedCriteria.For<费用信息>()
                                                .Add(NHibernate.Criterion.Expression.Eq("票.ID", piao.ID))
                                                .Add(NHibernate.Criterion.Expression.Eq("费用项编号", row.Cells["费用项"].Value));
                            IList<费用信息> fyxxs = rep.List<费用信息>(cri);
                            if (fyxxs.Count > 0)
                            {
                                if (!fyxxs[0].完全标志付)
                                {
                                    fyxxs[0].完全标志付 = true;
                                    (new HdBaseDao<费用信息>()).Update(rep, fyxxs[0]);
                                }
                                else
                                {
                                    throw new InvalidUserOperationException("货代自编号" + piao.货代自编号 + "费用项" + row.Cells["费用项"].Value.ToString()
                                    + "已打完全标志,不能修改费用!");
                                }
                            }
                            bool exist = false;
                            if (list.Count > 0)
                            {
                                foreach (业务费用 i in list)
                                {
                                    if (i.金额 == je && i.相关人编号 == pzfymx.相关人编号 && i.凭证费用明细 == null)
                                    {
                                        i.凭证费用明细 = pzfymx;
                                        (new 业务费用Dao()).Update(rep, i);
                                        pzfymx.费用.Add(i);

                                        exist = true;
                                        break;
                                    }
                                }
                            }
                            if (!exist)
                            {
                                if (list.Count > 1)
                                {
                                    throw new InvalidUserOperationException("货代自编号" + piao.货代自编号 + "费用项" + row.Cells["费用项"].Value.ToString()
                                        + "已存在多条费用,且无费用金额一致,请先修改一致!");
                                }
                                else if (list.Count == 0)
                                {
                                    业务费用 fy = new 业务费用();
                                    fy.备注 = (string)row.Cells["备注"].Value;
                                    fy.费用实体 = piao;
                                    fy.费用项编号 = (string)row.Cells["费用项"].Value;
                                    fy.金额 = Feng.Utils.ConvertHelper.ToDecimal(row.Cells["金额"].Value).Value;
                                    fy.票 = piao;
                                    fy.凭证费用明细 = pzfymx;
                                    fy.收付标志 = Hd.Model.收付标志.付;
                                    fy.相关人编号 = (string)付款对象.SelectedDataValue;
                                    if (xiang != null)
                                    {
                                        fy.箱 = xiang;
                                        fy.箱Id = xiang.ID;
                                    }
                                    (new 业务费用Dao()).Save(rep, fy);
                                    pzfymx.费用.Add(fy);
                                }
                                else// if (list.Count == 1)
                                {
                                    if (list[0].相关人编号 == pzfymx.相关人编号 && list[0].凭证费用明细 == null)
                                    {
                                        if (MessageForm.ShowYesNo("货代自编号" + piao.货代自编号 + "费用项" + row.Cells["费用项"].Value.ToString()
                                            + "已存在费用,且费用金额不符,是否添加调节款?", "确认"))
                                        {
                                            调节业务款 tjk = new 调节业务款();
                                            tjk.备注 = (string)row.Cells["备注"].Value;
                                            tjk.费用实体 = piao;
                                            tjk.费用项编号 = (string)row.Cells["费用项"].Value;
                                            tjk.金额 = Feng.Utils.ConvertHelper.ToDecimal(row.Cells["金额"].Value).Value;
                                            tjk.票 = piao;
                                            tjk.凭证费用明细 = pzfymx;
                                            tjk.收付标志 = Hd.Model.收付标志.付;
                                            tjk.相关人编号 = (string)付款对象.SelectedDataValue;
                                            if (xiang != null)
                                            {
                                                tjk.箱 = xiang;
                                                tjk.箱Id = xiang.ID;
                                            }
                                            (new 费用Dao()).Save(rep, tjk);
                                            pzfymx.费用.Add(tjk);
                                        }
                                        else
                                        {
                                            throw new InvalidUserOperationException("请重新填写货代自编号!");
                                        }
                                    }
                                    else
                                    {
                                        throw new InvalidUserOperationException("货代自编号" + piao.货代自编号 + "费用项" + row.Cells["费用项"].Value.ToString()
                                        + "已存在的一条费用相关人不符或已经出国凭证,请先修改一致!");
                                    }

                                }
                            }
                        }
                        else
                        {
                            throw new ArgumentException("不合理的凭证用途分类!");
                        }
                        pz.凭证费用明细.Add(pzfymx);
                    }

                    pz.会计编号 = SystemConfiguration.UserName;
                    pz.会计金额 = sum;
                    pz.金额.币制编号 = "CNY";
                    pz.金额.数额 = pz.会计金额;
                    pz.凭证类别 = 凭证类别.付款凭证;
                    pz.相关人编号 = (string)付款对象.SelectedDataValue;
                    pz.自动手工标志 = 自动手工标志.手工;

                    (new 凭证Dao()).Save(rep, pz);

                    foreach (凭证费用明细 pzfymx in pz.凭证费用明细)
                    {
                        (new HdBaseDao<凭证费用明细>()).Save(rep, pzfymx);
                    }

                    (new 凭证Dao()).Submit(rep, pz);

                    rep.CommitTransaction();

                    if (this.ControlManager.ControlCheckExceptionProcess != null)
                    {
                        this.ControlManager.ControlCheckExceptionProcess.ClearAllError();
                    }
                    this.ControlManager.State = StateType.View;
                    this.ControlManager.OnCurrentItemChanged();

                    // don't save to database
                    this.ControlManager.EndEdit(false);

                    return true;
                }
                catch (Exception ex)
                {
                    rep.RollbackTransaction();
                    ServiceProvider.GetService<IExceptionProcess>().ProcessWithNotify(ex);
                    return false;
                }
            }
        }
Example #2
0
        public override bool DoSave()
        {
            //if (!this.ControlManager.CheckControlValue())
            //{
            //    return false;
            //}
            this.ValidateChildren();
            if (!this.ControlManager.SaveCurrent())
                return false;

            凭证 pz = this.ControlManager.DisplayManager.CurrentItem as 凭证;
            pz.操作人 = "出纳";
            using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<Hd.Model.凭证>())
            {
                try
                {
                    rep.BeginTransaction();

                    decimal sum = 0;

                    pz.凭证费用明细 = new List<凭证费用明细>();
                    foreach (Xceed.Grid.DataRow row in grdFymx.DataRows)
                    {
                        decimal je = Feng.Utils.ConvertHelper.ToDecimal(row.Cells["金额"].Value).Value;
                        sum += je;

                        凭证费用明细 pzfymx = new 凭证费用明细();
                        pzfymx.备注 = (string)row.Cells["备注"].Value;
                        pzfymx.金额 = je;
                        pzfymx.凭证 = pz;
                        pzfymx.凭证费用类别编号 = (int?)用途分类.SelectedDataValue;
                        pzfymx.收付标志 = 收付标志.收;
                        pzfymx.相关人编号 = (string)付款对象.SelectedDataValue;
                        pzfymx.业务类型编号 = (int?)业务分类.SelectedDataValue;
                        pzfymx.费用项编号 = (string)row.Cells["费用项"].Value;
                        pzfymx.费用 = new List<费用>();

                        int ytfl = (int)用途分类.SelectedDataValue;

                        if (ytfl == 101)          // 业务应付
                        {
                            pzfymx.费用项编号 = (string)row.Cells["费用项"].Value;
                        }
                        else if (ytfl == 103)     //其他应付
                        {
                            pzfymx.费用项编号 = "002";
                        }
                        else if (ytfl == 203 || ytfl == 204 || ytfl == 205)    // 借款套现押金
                        {
                            pzfymx.费用项编号 = "012";
                        }
                        else
                        {
                            pzfymx.费用项编号 = (string)row.Cells["费用项"].Value;
                        }

                        pz.凭证费用明细.Add(pzfymx);
                    }

                    pz.出纳编号 = SystemConfiguration.UserName;
                    pz.会计金额 = sum;
                    pz.金额.币制编号 = "CNY";
                    pz.金额.数额 = pz.会计金额;
                    pz.凭证类别 = 凭证类别.收款凭证;
                    pz.相关人编号 = (string)付款对象.SelectedDataValue;
                    pz.自动手工标志 = 自动手工标志.手工;

                    (new 凭证Dao()).Save(rep, pz);

                    foreach (凭证费用明细 pzfymx in pz.凭证费用明细)
                    {
                        (new HdBaseDao<凭证费用明细>()).Save(rep, pzfymx);
                    }

                    (new 凭证Dao()).Submit(rep, pz);

                    rep.CommitTransaction();

                    if (this.ControlManager.ControlCheckExceptionProcess != null)
                    {
                        this.ControlManager.ControlCheckExceptionProcess.ClearAllError();
                    }
                    this.ControlManager.State = StateType.View;
                    this.ControlManager.OnCurrentItemChanged();

                    return true;
                }
                catch (Exception ex)
                {
                    rep.RollbackTransaction();
                    ServiceProvider.GetService<IExceptionProcess>().ProcessWithNotify(ex);
                    return false;
                }
            }
        }
Example #3
0
        public static void AddFees(凭证 master, IList<费用> list, IControlManager<凭证费用明细> detailCm, bool add, 收付标志? asDzd收付标志)
        {
            if (list == null)
                return;

            List<费用> newList = new List<费用>();
            foreach (费用 i in list)
            {
                if (i.凭证费用明细 == null)
                {
                    newList.Add(i);
                }
            }

            IList<凭证费用明细> ret = new List<凭证费用明细>();
            if (!asDzd收付标志.HasValue)
            {
                // 费用实体类型. 收付标志, 费用项编号, 相关人编号
                Dictionary<Tuple<int, 收付标志, string, string>, IList<费用>> dict = Utility.GroupFyToPzYsyf(newList);

                foreach (KeyValuePair<Tuple<int, 收付标志, string, string>, IList<费用>> kvp in dict)
                {
                    凭证费用明细 pzs1 = new 凭证费用明细();

                    decimal sum = 0;
                    foreach (费用 k4 in kvp.Value)
                    {
                        sum += k4.金额.Value;
                        k4.凭证费用明细 = pzs1;
                    }

                    //string s = NameValueMappingCollection.Instance.FindNameFromId("信息_业务类型_全部", kvp.Key.Item1);
                    //if (string.IsNullOrEmpty(s))
                    //{
                    //    pzs1.业务类型编号 = null;
                    //}
                    //else
                    //{
                    //    pzs1.业务类型编号 = kvp.Key.Item1;
                    //}
                    pzs1.业务类型编号 = kvp.Key.Item1;

                    pzs1.费用 = kvp.Value;
                    pzs1.费用项编号 = kvp.Key.Item3;
                    pzs1.金额 = sum;
                    pzs1.收付标志 = kvp.Key.Item2;
                    pzs1.相关人编号 = kvp.Key.Item4;

                    // pzs1.凭证 = pz;

                    ret.Add(pzs1);
                }
            }
            else
            {
                Dictionary<Tuple<int, string>, IList<费用>> dict = Utility.GroupFyToDzdYsyf(newList);

                foreach (KeyValuePair<Tuple<int, string>, IList<费用>> kvp in dict)
                {
                    凭证费用明细 pzs1 = new 凭证费用明细();

                    decimal sum = 0;
                    foreach (费用 k4 in kvp.Value)
                    {
                        if (k4.收付标志 == asDzd收付标志.Value)
                        {
                            sum += k4.金额.Value;
                        }
                        else
                        {
                            sum -= k4.金额.Value;
                        }
                        k4.凭证费用明细 = pzs1;
                    }

                    //string s = NameValueMappingCollection.Instance.FindNameFromId("信息_业务类型_全部", kvp.Key.First);
                    //if (string.IsNullOrEmpty(s))
                    //{
                    //    pzs1.业务类型编号 = null;
                    //}
                    //else
                    //{
                    //    pzs1.业务类型编号 = kvp.Key.First;
                    //}
                    pzs1.业务类型编号 = kvp.Key.Item1;

                    pzs1.费用 = kvp.Value;
                    pzs1.费用项编号 = "000";    // 常规应收应付
                    pzs1.金额 = sum;
                    pzs1.收付标志 = asDzd收付标志.Value;
                    pzs1.相关人编号 = kvp.Key.Item2;

                    // pzs1.凭证 = pz;

                    ret.Add(pzs1);
                }
            }

            if (add)
            {
                foreach (凭证费用明细 item in ret)
                {
                    detailCm.AddNew();
                    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item;
                    detailCm.EndEdit();

                    foreach (费用 i in item.费用)
                    {
                        i.凭证费用明细 = item;
                    }
                }
            }
            else
            {
                if (ret.Count == 0)
                    return;

                System.Diagnostics.Debug.Assert(ret.Count <= 1, "选出多个凭证费用明细,请查证!");
                System.Diagnostics.Debug.Assert(ret[0].费用项编号 == detailCm.DisplayManagerT.CurrentEntity.费用项编号, "凭证费用明细费用项和选择的费用项不同!");
                System.Diagnostics.Debug.Assert(ret[0].相关人编号 == detailCm.DisplayManagerT.CurrentEntity.相关人编号, "凭证费用明细费用项和选择的相关人不同!");
                System.Diagnostics.Debug.Assert(ret[0].收付标志 == detailCm.DisplayManagerT.CurrentEntity.收付标志, "凭证费用明细费用项和选择的相关人不同!");

                using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<费用>())
                {
                    rep.Initialize(detailCm.DisplayManagerT.CurrentEntity.费用, detailCm.DisplayManagerT.CurrentEntity);
                }

                if (detailCm.DisplayManagerT.CurrentEntity.费用 == null)
                {
                    detailCm.DisplayManagerT.CurrentEntity.费用 = new List<费用>();
                }
                foreach (费用 i in ret[0].费用)
                {
                    i.凭证费用明细 = detailCm.DisplayManagerT.CurrentEntity;
                }

                detailCm.EditCurrent();
                detailCm.EndEdit();
            }
        }
Example #4
0
        private static void 自动对账单生成凭证(IRepository rep, 对账单 dzd, Dictionary <string, object> properties)
        {
            凭证 pz = new 凭证();

            pz.Submitted = true;
            pz.备注        = null;
            pz.出纳编号      = null;
            pz.审核状态      = true;
            pz.收支状态      = false;
            pz.会计编号      = SystemConfiguration.UserName;
            pz.会计金额      = dzd.金额;
            //pz.金额.币制编号 = properties["凭证币制编号"].ToString();
            //pz.金额.数额 = (decimal)properties["凭证金额"];
            pz.金额.币制编号 = "CNY";
            pz.金额.数额   = dzd.金额;
            pz.凭证类别    = 凭证类别.付款凭证;
            pz.日期      = dzd.关账日期.Value;
            pz.审核人编号   = null;
            pz.相关人编号   = dzd.相关人编号;
            pz.自动手工标志  = 自动手工标志.对账单;
            pz.凭证费用明细  = new List <凭证费用明细>();
            pz.审核状态    = true;

            Dictionary <int, Dictionary <收付标志, Dictionary <string, Dictionary <string, List <费用> > > > > dict =
                new Dictionary <int, Dictionary <收付标志, Dictionary <string, Dictionary <string, List <费用> > > > >();

            foreach (费用 item in dzd.费用)
            {
                if (string.IsNullOrEmpty(item.费用项编号) ||
                    string.IsNullOrEmpty(item.相关人编号) ||
                    !item.金额.HasValue)
                {
                    continue;
                }

                if (!dict.ContainsKey(item.费用实体.费用实体类型编号))
                {
                    dict[item.费用实体.费用实体类型编号] = new Dictionary <收付标志, Dictionary <string, Dictionary <string, List <费用> > > >();
                }
                if (!dict[item.费用实体.费用实体类型编号].ContainsKey(item.收付标志))
                {
                    dict[item.费用实体.费用实体类型编号][item.收付标志] = new Dictionary <string, Dictionary <string, List <费用> > >();
                }
                if (!dict[item.费用实体.费用实体类型编号][item.收付标志].ContainsKey(item.费用项编号))
                {
                    dict[item.费用实体.费用实体类型编号][item.收付标志][item.费用项编号] = new Dictionary <string, List <费用> >();
                }
                if (!dict[item.费用实体.费用实体类型编号][item.收付标志][item.费用项编号].ContainsKey(item.相关人编号))
                {
                    dict[item.费用实体.费用实体类型编号][item.收付标志][item.费用项编号][item.相关人编号] = new List <费用>();
                }
                dict[item.费用实体.费用实体类型编号][item.收付标志][item.费用项编号][item.相关人编号].Add(item);
            }

            IList <凭证费用明细> ret = new List <凭证费用明细>();

            foreach (KeyValuePair <int, Dictionary <收付标志, Dictionary <string, Dictionary <string, List <费用> > > > > k0 in dict)
            {
                foreach (KeyValuePair <收付标志, Dictionary <string, Dictionary <string, List <费用> > > > k1 in k0.Value)
                {
                    foreach (KeyValuePair <string, Dictionary <string, List <费用> > > k2 in k1.Value)
                    {
                        foreach (KeyValuePair <string, List <费用> > k3 in k2.Value)
                        {
                            凭证费用明细 pzs1 = new 凭证费用明细();

                            decimal sum = 0;
                            foreach (费用 k4 in k3.Value)
                            {
                                sum      += k4.金额.Value;
                                k4.凭证费用明细 = pzs1;
                            }

                            pzs1.业务类型编号 = k0.Key;

                            pzs1.费用    = k3.Value;
                            pzs1.费用项编号 = k2.Key;
                            pzs1.金额    = sum;
                            pzs1.收付标志  = k1.Key;
                            pzs1.相关人编号 = k3.Key;

                            pzs1.凭证 = pz;

                            pz.凭证费用明细.Add(pzs1);
                        }
                    }
                }
            }

            (new HdBaseDao <凭证>()).Save(rep, pz);
            foreach (凭证费用明细 pzs1 in pz.凭证费用明细)
            {
                (new HdBaseDao <凭证费用明细>()).Save(rep, pzs1);

                foreach (费用 fee in pzs1.费用)
                {
                    (new 费用Dao()).Update(rep, fee);
                }
            }

            // dzd.凭证 = pz;
        }