public static string Get相关人(IRepository rep, 车辆产值 产值, 任务 任务, 合同费用项 htfyx) { 车队合同费用项 cdhtfyx = htfyx as 车队合同费用项; switch (cdhtfyx.费用归属) { case 费用归属.委托人: return 任务.委托人编号; case 费用归属.车主: return 产值.承运人编号; case 费用归属.驾驶员: return 产值.驾驶员编号; case 费用归属.对外: { object entity; if (任务 != null) { entity = 任务; } else { entity = 产值; } string ret = null; object r = EntityScript.CalculateExpression(cdhtfyx.默认相关人, entity); ret = string.IsNullOrEmpty(cdhtfyx.默认相关人) || r == null ? null : r.ToString().Replace("\"", ""); if (string.IsNullOrEmpty(ret)) { ret = null; } return ret; } default: throw new ArgumentException("Invalid 费用归属!"); } }
private static decimal?Get理论值(IRepository rep, 车辆产值 产值, 任务 任务, 合同费用项 htfyx) { decimal?d = null; d = (任务 != null) ? Get理论值金额(rep, htfyx, 任务) : Get理论值金额(rep, htfyx, 产值); return(d); }
// 返回MinValue:没符合的条件,不生成理论值,不生成费用(内部外部都不生成) // 返回0:符合条件,生成理论值, 但不生成费用(内部外部都不生成) // 返回NULL:符合条件,不生成理论值,但生成空费用记录。在不在生成全部的时候生成看配置,生成单费用项的时候生成 // 返回具体值:生成记录 // 根据相关人不同得到理论值 private static decimal?Get理论值金额(IRepository rep, 合同费用项 htfyx, object entity) { rep.Initialize(htfyx.费用理论值, htfyx); foreach (费用理论值信息 i in htfyx.费用理论值) { string exp; if (i.条件.Contains(System.Environment.NewLine)) { exp = s_feeThoeryGenerate2.Replace("%IFEXPRESSION%", i.条件); } else { exp = s_feeThoeryGenerate.Replace("%IFEXPRESSION%", i.条件); } object ret = Script.ExecuteStatement(exp, new Dictionary <string, object> { { "entity", entity } }); if (ConvertHelper.ToBoolean(ret).Value) { if (string.IsNullOrEmpty(i.结果)) { return(null); } else { if (i.结果.Contains(System.Environment.NewLine)) { exp = s_feeThoeryGenerateResult2.Replace("%IFEXPRESSION%", i.结果); } else { exp = s_feeThoeryGenerateResult.Replace("%IFEXPRESSION%", i.结果); } ret = Script.ExecuteStatement(exp, new Dictionary <string, object> { { "entity", entity }, { "rep", rep } }); decimal?d = Feng.Utils.ConvertHelper.ToDecimal(ret); if (d.HasValue) { return(d.Value); } else { return(null); } } } } return(decimal.MinValue); }
public static string Get相关人(IRepository rep, 普通票 票, 普通箱 箱, 合同费用项 htfyx) { object entity; if (箱 != null) { entity = 箱; } else { entity = 票; } string ret = null; if (htfyx is 委托人合同费用项) { return(票.委托人编号); } else if (htfyx is 付款合同费用项) { string mrxgr = (htfyx as 付款合同费用项).默认相关人; object r = EntityScript.CalculateExpression(mrxgr, entity); ret = string.IsNullOrEmpty(mrxgr) || r == null ? null : r.ToString().Replace("\"", ""); if (string.IsNullOrEmpty(ret)) { ret = null; } } else if (htfyx is 受托人合同费用项) { object cyr = EntityScript.GetPropertyValue(票, "承运人编号"); if (cyr != null) { return(cyr.ToString()); } else { return(null); } } else { throw new ArgumentException("Invalid htfyx Type!"); } return(ret); }
public static string Get相关人(IRepository rep, 普通票 票, 普通箱 箱, 合同费用项 htfyx) { object entity; if (箱 != null) { entity = 箱; } else { entity = 票; } string ret = null; if (htfyx is 委托人合同费用项) { return 票.委托人编号; } else if (htfyx is 付款合同费用项) { string mrxgr = (htfyx as 付款合同费用项).默认相关人; object r = EntityScript.CalculateExpression(mrxgr, entity); ret = string.IsNullOrEmpty(mrxgr) || r == null ? null : r.ToString().Replace("\"", ""); if (string.IsNullOrEmpty(ret)) { ret = null; } } else if (htfyx is 受托人合同费用项) { object cyr = EntityScript.GetPropertyValue(票, "承运人编号"); if (cyr != null) { return cyr.ToString(); } else { return null; } } else { throw new ArgumentException("Invalid htfyx Type!"); } return ret; }
private static decimal?Get理论值(IRepository rep, 普通票 票, 普通箱 箱, 合同费用项 htfyx) { if (htfyx is 受托人合同费用项) { return(Get受托人理论值(rep, 票, 箱, htfyx as 受托人合同费用项)); } else if (htfyx is 付款合同费用项) { return(Get付款理论值(rep, 票, 箱, htfyx as 付款合同费用项)); } else if (htfyx is 委托人合同费用项) { return(Get委托人理论值(rep, 票, 箱, htfyx as 委托人合同费用项)); } else { throw new ArgumentException("Invalid htfyx Type!"); } }
public static string Get相关人(IRepository rep, 车辆产值 产值, 任务 任务, 合同费用项 htfyx) { 车队合同费用项 cdhtfyx = htfyx as 车队合同费用项; switch (cdhtfyx.费用归属) { case 费用归属.委托人: return(任务.委托人编号); case 费用归属.车主: return(产值.承运人编号); case 费用归属.驾驶员: return(产值.驾驶员编号); case 费用归属.对外: { object entity; if (任务 != null) { entity = 任务; } else { entity = 产值; } string ret = null; object r = EntityScript.CalculateExpression(cdhtfyx.默认相关人, entity); ret = string.IsNullOrEmpty(cdhtfyx.默认相关人) || r == null ? null : r.ToString().Replace("\"", ""); if (string.IsNullOrEmpty(ret)) { ret = null; } return(ret); } default: throw new ArgumentException("Invalid 费用归属!"); } }
private static void 批量生成费用(IRepository rep, 普通票 票, IEnumerable 箱s, 收付标志 收付标志, 合同费用项 htfyx, IList<业务费用理论值> llzs, bool mustGenerateFy) { 费用项 fyx = EntityBufferCollection.Instance.Get<费用项>(htfyx.费用项编号); if (fyx.箱) { foreach (普通箱 箱 in 箱s) { GenerateFy(rep, 票, 箱, 收付标志, htfyx, llzs, mustGenerateFy); } } else if (fyx.票) { GenerateFy(rep, 票, null, 收付标志, htfyx, llzs, mustGenerateFy); } }
// 返回MinValue:没符合的条件,不生成理论值,不生成费用(内部外部都不生成) // 返回0:符合条件,生成理论值, 但不生成费用(内部外部都不生成) // 返回NULL:符合条件,不生成理论值,但生成空费用记录。在不在生成全部的时候生成看配置,生成单费用项的时候生成 // 返回具体值:生成记录 // 根据相关人不同得到理论值 private static decimal? Get理论值金额(IRepository rep, 合同费用项 htfyx, object entity) { rep.Initialize(htfyx.费用理论值, htfyx); foreach (费用理论值信息 i in htfyx.费用理论值) { string exp; if (i.条件.Contains(System.Environment.NewLine)) { exp = s_feeThoeryGenerate2.Replace("%IFEXPRESSION%", i.条件); } else { exp = s_feeThoeryGenerate.Replace("%IFEXPRESSION%", i.条件); } object ret = Script.ExecuteStatement(exp, new Dictionary<string, object> { { "entity", entity } }); if (ConvertHelper.ToBoolean(ret).Value) { if (string.IsNullOrEmpty(i.结果)) { return null; } else { if (i.结果.Contains(System.Environment.NewLine)) { exp = s_feeThoeryGenerateResult2.Replace("%IFEXPRESSION%", i.结果); } else { exp = s_feeThoeryGenerateResult.Replace("%IFEXPRESSION%", i.结果); } ret = Script.ExecuteStatement(exp, new Dictionary<string, object> { { "entity", entity }, { "rep", rep } }); decimal? d = Feng.Utils.ConvertHelper.ToDecimal(ret); if (d.HasValue) return d.Value; else return null; } } } return decimal.MinValue; }
private static decimal? Get理论值(IRepository rep, 普通票 票, 普通箱 箱, 合同费用项 htfyx) { if (htfyx is 受托人合同费用项) { return Get受托人理论值(rep, 票, 箱, htfyx as 受托人合同费用项); } else if (htfyx is 付款合同费用项) { return Get付款理论值(rep, 票, 箱, htfyx as 付款合同费用项); } else if (htfyx is 委托人合同费用项) { return Get委托人理论值(rep, 票, 箱, htfyx as 委托人合同费用项); } else { throw new ArgumentException("Invalid htfyx Type!"); } }
private static void GenerateFy(IRepository rep, 普通票 票, 普通箱 箱, 收付标志 收付标志, 合同费用项 htfyx, IList<业务费用理论值> llzs, bool mustGenerateFy) { string 相关人 = Get相关人(rep, 票, 箱, htfyx); decimal? 金额 = Get理论值(rep, 票, 箱, htfyx); if (金额.HasValue && 金额.Value == decimal.MinValue) { return; } bool llrHaveGenerated = false; foreach (业务费用理论值 i in llzs) { bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志; ; if (htfyx.是否判断相关人) { b &= i.相关人编号 == 相关人; } if (b && 箱 != null) { b &= i.箱Id == 箱.ID; } if (b) { llrHaveGenerated = true; break; } } 业务费用理论值 ywfylrz = null; if (!llrHaveGenerated) { if (金额.HasValue) { ywfylrz = new 业务费用理论值(); ywfylrz.费用实体 = 票; // new 普通票 { Id = 票.ID, Version = 票.Version, 费用实体类型编号 = 票.费用实体类型编号 }; ywfylrz.费用项编号 = htfyx.费用项编号; ywfylrz.金额 = 金额.Value; ywfylrz.票 = 票; ywfylrz.收付标志 = 收付标志; ywfylrz.相关人编号 = Get相关人(rep, 票, 箱, htfyx); if (箱 != null) { ywfylrz.箱 = 箱; ywfylrz.箱Id = 箱.ID; } (new HdBaseDao<业务费用理论值>()).Save(rep, ywfylrz); llzs.Add(ywfylrz); } } if (htfyx.是否生成实际费用) { bool generateFy = false; // 在外层,判断理论值是否生成过 if (!mustGenerateFy) { if (htfyx.是否空值全部生成) { // 金额为Null的时候判断时候生成过,没生成过也要生成 if (!金额.HasValue) { bool fyHaveGenerated = false; foreach (业务费用 i in 票.费用) { bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志; if (htfyx.是否判断相关人) { b &= i.相关人编号 == 相关人; } if (b && 箱 != null) { b &= i.箱Id == 箱.ID; } if (b) { fyHaveGenerated = true; break; } } generateFy = !fyHaveGenerated; } } if (!generateFy) { // 只有理论值未生成过,且有理论值的情况下,准备生成费用 if (!llrHaveGenerated && ywfylrz != null) { // 如果理论值未生成过,要检查是否要生成费用 bool fyHaveGenerated = false; foreach (业务费用 i in 票.费用) { bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志; if (htfyx.是否判断相关人) { b &= i.相关人编号 == 相关人; } if (b && 箱 != null) { b &= i.箱Id == 箱.ID; } if (b) { fyHaveGenerated = true; break; } } generateFy = !fyHaveGenerated; } else { generateFy = false; } } } else { generateFy = true; } if (generateFy) { bool fylbSubmitted = false; 费用项 fyx = EntityBufferCollection.Instance.Get<费用项>(htfyx.费用项编号); //int fylbbh = fyx.收入类别.Value; //费用类别 fylb = EntityBufferCollection.Instance["费用类别"].Get(fylbbh) as 费用类别; //System.Diagnostics.Debug.Assert(fylb.大类 == "业务额外" || fylb.大类 == "业务常规" || fylb.大类 == "业务其他"); IList<费用信息> list = (rep as Feng.NH.INHibernateRepository).List<费用信息>(NHibernate.Criterion.DetachedCriteria.For<费用信息>() .Add(NHibernate.Criterion.Expression.Eq("费用项编号", htfyx.费用项编号)) .Add(NHibernate.Criterion.Expression.Eq("票.ID", 票.ID))); System.Diagnostics.Debug.Assert(list.Count <= 1); if (list.Count == 1) { if (收付标志 == 收付标志.收) { fylbSubmitted = list[0].Submitted; } else { fylbSubmitted = list[0].完全标志付; } } // 完全标志还未打 if (!fylbSubmitted) { // 不生成理论值为0的 if (!金额.HasValue || (金额.HasValue && 金额.Value != 0)) { 业务费用 item = new 业务费用(); item.费用实体 = 票; // new 普通票 { Id = 票.ID, Version = 票.Version, 费用实体类型编号 = 票.费用实体类型编号 }; item.费用项编号 = htfyx.费用项编号; item.金额 = 金额; item.票 = 票; item.收付标志 = 收付标志; item.相关人编号 = 相关人; if (箱 != null) { item.箱 = 箱; item.箱Id = 箱.ID; } (new 业务费用Dao()).Save(rep, item); 票.费用.Add(item); } } } } }
private static decimal? Get理论值(IRepository rep, 车辆产值 产值, 任务 任务, 合同费用项 htfyx) { decimal? d = null; d = (任务 != null) ? Get理论值金额(rep, htfyx, 任务) : Get理论值金额(rep, htfyx, 产值); return d; }
private static void 批量生成费用(IRepository rep, 普通票 票, IEnumerable 箱s, 收付标志 收付标志, 合同费用项 htfyx, IList <业务费用理论值> llzs, bool mustGenerateFy) { 费用项 fyx = EntityBufferCollection.Instance.Get <费用项>(htfyx.费用项编号); if (fyx.箱) { foreach (普通箱 箱 in 箱s) { GenerateFy(rep, 票, 箱, 收付标志, htfyx, llzs, mustGenerateFy); } } else if (fyx.票) { GenerateFy(rep, 票, null, 收付标志, htfyx, llzs, mustGenerateFy); } }
private static void GenerateFy(IRepository rep, 普通票 票, 普通箱 箱, 收付标志 收付标志, 合同费用项 htfyx, IList <业务费用理论值> llzs, bool mustGenerateFy) { string 相关人 = Get相关人(rep, 票, 箱, htfyx); decimal?金额 = Get理论值(rep, 票, 箱, htfyx); if (金额.HasValue && 金额.Value == decimal.MinValue) { return; } bool llrHaveGenerated = false; foreach (业务费用理论值 i in llzs) { bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志;; if (htfyx.是否判断相关人) { b &= i.相关人编号 == 相关人; } if (b && 箱 != null) { b &= i.箱Id == 箱.ID; } if (b) { llrHaveGenerated = true; break; } } 业务费用理论值 ywfylrz = null; if (!llrHaveGenerated) { if (金额.HasValue) { ywfylrz = new 业务费用理论值(); ywfylrz.费用实体 = 票; // new 普通票 { Id = 票.ID, Version = 票.Version, 费用实体类型编号 = 票.费用实体类型编号 }; ywfylrz.费用项编号 = htfyx.费用项编号; ywfylrz.金额 = 金额.Value; ywfylrz.票 = 票; ywfylrz.收付标志 = 收付标志; ywfylrz.相关人编号 = Get相关人(rep, 票, 箱, htfyx); if (箱 != null) { ywfylrz.箱 = 箱; ywfylrz.箱Id = 箱.ID; } (new HdBaseDao <业务费用理论值>()).Save(rep, ywfylrz); llzs.Add(ywfylrz); } } if (htfyx.是否生成实际费用) { bool generateFy = false; // 在外层,判断理论值是否生成过 if (!mustGenerateFy) { if (htfyx.是否空值全部生成) { // 金额为Null的时候判断时候生成过,没生成过也要生成 if (!金额.HasValue) { bool fyHaveGenerated = false; foreach (业务费用 i in 票.费用) { bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志; if (htfyx.是否判断相关人) { b &= i.相关人编号 == 相关人; } if (b && 箱 != null) { b &= i.箱Id == 箱.ID; } if (b) { fyHaveGenerated = true; break; } } generateFy = !fyHaveGenerated; } } if (!generateFy) { // 只有理论值未生成过,且有理论值的情况下,准备生成费用 if (!llrHaveGenerated && ywfylrz != null) { // 如果理论值未生成过,要检查是否要生成费用 bool fyHaveGenerated = false; foreach (业务费用 i in 票.费用) { bool b = i.费用项编号 == htfyx.费用项编号 && i.收付标志 == 收付标志; if (htfyx.是否判断相关人) { b &= i.相关人编号 == 相关人; } if (b && 箱 != null) { b &= i.箱Id == 箱.ID; } if (b) { fyHaveGenerated = true; break; } } generateFy = !fyHaveGenerated; } else { generateFy = false; } } } else { generateFy = true; } if (generateFy) { bool fylbSubmitted = false; 费用项 fyx = EntityBufferCollection.Instance.Get <费用项>(htfyx.费用项编号); //int fylbbh = fyx.收入类别.Value; //费用类别 fylb = EntityBufferCollection.Instance["费用类别"].Get(fylbbh) as 费用类别; //System.Diagnostics.Debug.Assert(fylb.大类 == "业务额外" || fylb.大类 == "业务常规" || fylb.大类 == "业务其他"); IList <费用信息> list = (rep as Feng.NH.INHibernateRepository).List <费用信息>(NHibernate.Criterion.DetachedCriteria.For <费用信息>() .Add(NHibernate.Criterion.Expression.Eq("费用项编号", htfyx.费用项编号)) .Add(NHibernate.Criterion.Expression.Eq("票.ID", 票.ID))); System.Diagnostics.Debug.Assert(list.Count <= 1); if (list.Count == 1) { if (收付标志 == 收付标志.收) { fylbSubmitted = list[0].Submitted; } else { fylbSubmitted = list[0].完全标志付; } } // 完全标志还未打 if (!fylbSubmitted) { // 不生成理论值为0的 if (!金额.HasValue || (金额.HasValue && 金额.Value != 0)) { 业务费用 item = new 业务费用(); item.费用实体 = 票; // new 普通票 { Id = 票.ID, Version = 票.Version, 费用实体类型编号 = 票.费用实体类型编号 }; item.费用项编号 = htfyx.费用项编号; item.金额 = 金额; item.票 = 票; item.收付标志 = 收付标志; item.相关人编号 = 相关人; if (箱 != null) { item.箱 = 箱; item.箱Id = 箱.ID; } (new 业务费用Dao()).Save(rep, item); 票.费用.Add(item); } } } } }
public static void EditLlz(ArchiveSeeForm masterForm) { Xceed.Grid.Row row = (masterForm.ArchiveDetailForm as IArchiveDetailFormWithDetailGrids).DetailGrids[0].CurrentRow; if (row == null) { throw new InvalidUserOperationException("请选择要编辑理论值的合同费用项!"); } 合同费用项 htfyx = (row as Xceed.Grid.DataRow).Tag as 合同费用项; using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <费用理论值信息>()) { rep.Initialize(htfyx.费用理论值, htfyx); } IList <string> llzs = new List <string>(); if (htfyx.费用理论值 != null) { foreach (费用理论值信息 i in htfyx.费用理论值) { llzs.Add(i.条件); llzs.Add(i.结果); } } Hd.Service.理论值编辑.FrmEditor form = new Hd.Service.理论值编辑.FrmEditor( new Dictionary <string, string> { { "委托人编号", "人员单位_委托人" }, { "船公司编号", "人员单位_船公司" }, { "箱型编号", "备案_箱型_全部" }, { "提箱地编号", "人员单位_港区堆场" }, { "费用项编号", "费用项_全部" } }, llzs); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IList <string> ret = form.GetResult(); using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <费用理论值信息>()) { try { rep.BeginTransaction(); foreach (费用理论值信息 i in htfyx.费用理论值) { rep.Delete(i); } htfyx.费用理论值.Clear(); for (int i = 0; i < ret.Count; i += 2) { 费用理论值信息 item = new 费用理论值信息(); item.合同费用项 = htfyx; item.结果 = ret[i + 1]; item.条件 = ret[i]; item.序号 = i / 2; (new HdBaseDao <费用理论值信息>()).Save(rep, item); htfyx.费用理论值.Add(item); } rep.CommitTransaction(); } catch (Exception ex) { rep.RollbackTransaction(); ServiceProvider.GetService <IExceptionProcess>().ProcessWithNotify(ex); } } } }