//public static void 自动凭证应付对账单生成费用(ArchiveOperationForm masterForm) //{ // IControlManager<业务费用> detailCm = (((IArchiveDetailFormWithDetailGrids)detailForm).DetailGrids[0] as IArchiveGrid).ControlManager // as IControlManager<业务费用>; // IList<费用> list = new List<费用>(); // foreach (业务费用 item in detailCm.DisplayManagerT.Entities) // { // list.Add(item.Clone() as 业务费用); // } // ArchiveOperationForm masterFormKj = TabbedMdiForm.ShowMenuFormInMdi("凭证_会计付款") as ArchiveOperationForm; // if (masterFormKj != null) // { // if (masterFormKj.DoAdd()) // { // IControlManager<凭证费用明细> detailCmKj = (((IArchiveDetailFormWithDetailGrids)detailForm).DetailGrids[0] as IArchiveGrid).ControlManager as IControlManager<凭证费用明细>; // IBaseDao masterDao = ((IArchiveGrid)masterFormKj.ActiveGrid).Bll as IBaseDao; // MemoryDao<凭证费用明细> memoryBll = (masterDao.GetSubDao(0) as IMasterDao).DetailMemoryDao as MemoryDao<凭证费用明细>; // MemoryDao<费用> memoryBll2 = (((masterDao.GetSubDao(0) as IMasterDao).DetailDao as IBaseDao).GetSubDao(0) as IMasterDao).DetailMemoryDao as MemoryDao<费用>; // (masterFormKj.DisplayManager.CurrentItem as 凭证).自动手工标志 = 自动手工标志.对账单; // process_pz.AddFees(masterFormKj.DisplayManager.CurrentItem as 凭证, list, detailCmKj, memoryBll, memoryBll2); // //frm_cw_fkpz_kj_detail detailFormTo = form.ArchiveDetailForm as frm_cw_fkpz_kj_detail; // detailCmKj.DisplayManager.DataControls["金额.数额"].SelectedDataValue = detailForm.ControlManager.DisplayManager.DataControls["凭证金额"].SelectedDataValue; // detailCmKj.DisplayManager.DataControls["金额.币制编号"].SelectedDataValue = detailForm.ControlManager.DisplayManager.DataControls["凭证币制编号"].SelectedDataValue; // } // } //} public static void 择应付对账单费用(ArchiveOperationForm masterForm) { if (masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue == null) { MessageForm.ShowError("请先填写相关人编号!"); return; } masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].ReadOnly = true; EntityScript.SetPropertyValue(masterForm.DisplayManager.CurrentItem, "相关人编号", masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue); Dictionary <string, object> dict = new Dictionary <string, object>(); dict["相关人编号"] = masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue; ArchiveCheckForm form = ProcessSelect.Execute((masterForm.ArchiveDetailForm as IDisplayManagerContainer).DisplayManager, "选择_应付对账单_费用", dict); if (form != null) { IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager; using (var rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>()) { foreach (object i in form.SelectedEntites) { 业务费用 item = i as 业务费用; item.对账单 = masterForm.DisplayManager.CurrentItem as 对账单; detailCm.AddNew(); detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item; detailCm.EndEdit(); } } } }
public static void 生成油费对外费用(ArchiveOperationForm masterForm) { if (MessageForm.ShowYesNo("是否自动生成油费对外费用?", "提示")) { int count = 0; try { if (masterForm.DisplayManager.Items != null && masterForm.DisplayManager.Items.Count > 0) { foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 业务费用 fy = dataRow.Tag as 业务费用; // 把 费用归属=驾驶员 费用项=204 的记录 逐条生成 费用归属=对外的 // 收付标志 反一下 相关人=null using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>()) { rep.Initialize(fy.车辆产值, fy); } if (fy.费用归属 == 费用归属.驾驶员 && fy.费用项编号 == "204") { 业务费用 kps = masterForm.ControlManager.AddNew() as 业务费用; kps.费用归属 = 费用归属.对外; kps.收付标志 = fy.收付标志 == 收付标志.收 ? 收付标志.付 : 收付标志.收; kps.数量 = fy.数量; kps.费用项编号 = fy.费用项编号; kps.金额 = fy.金额; kps.费用实体 = fy.费用实体; kps.车辆产值 = fy.车辆产值; kps.车辆编号 = fy.车辆编号; kps.任务 = fy.任务; masterForm.DisplayManager.DisplayCurrent(); masterForm.ControlManager.EndEdit(true); count++; } } } } catch (Exception ex) { throw new InvalidUserOperationException(ex.Message); } finally { MessageForm.ShowInfo("已生成 " + count + " 条对外费用!"); } } }
public static void 择出口应收对账单费用(ArchiveOperationForm masterForm) { if (masterForm.ControlManager.DisplayManager.DataControls["费用项编号"].SelectedDataValue == null) { MessageForm.ShowError("请先填写费用项编号!"); return; } if (masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue == null) { MessageForm.ShowError("请先填写相关人编号!"); return; } masterForm.ControlManager.DisplayManager.DataControls["费用项编号"].ReadOnly = true; masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].ReadOnly = true; EntityScript.SetPropertyValue(masterForm.DisplayManager.CurrentItem, "费用项编号", masterForm.ControlManager.DisplayManager.DataControls["费用项编号"].SelectedDataValue); EntityScript.SetPropertyValue(masterForm.DisplayManager.CurrentItem, "相关人编号", masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue); string type = (string)masterForm.ControlManager.DisplayManager.DataControls["费用项编号"].SelectedDataValue; ArchiveCheckForm form = null; Dictionary <string, object> dict = new Dictionary <string, object>(); dict["相关人编号"] = masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue; if (type == "000") // 常规 { form = ProcessSelect.Execute((masterForm.ArchiveDetailForm as IDisplayManagerContainer).DisplayManager, "选择_出口_应收对账单_常规费用", dict); } else if (type == "001") // 额外 { form = ProcessSelect.Execute((masterForm.ArchiveDetailForm as IDisplayManagerContainer).DisplayManager, "选择_出口_应收对账单_额外费用", dict); } if (form != null) { IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager; foreach (object i in form.SelectedEntites) { 业务费用 item = i as 业务费用; item.对账单 = masterForm.DisplayManager.CurrentItem as 对账单; detailCm.AddNew(); detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item; detailCm.EndEdit(); } } }
public static void 批量添加进口箱费用(ArchiveOperationForm masterForm) { IControlManager cm = masterForm.ControlManager; ArchiveCheckForm form = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("选择_批量添加费用_进口箱")) as ArchiveCheckForm; if (form != null && form.ShowDialog() == DialogResult.OK) { foreach (object i in form.SelectedEntites) { 业务费用 item = new 业务费用(); if (i is 普通箱) { 普通箱 xiang = i as 普通箱; // it must have piao item.票 = xiang.GetType().InvokeMember("票", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public, null, xiang, null) as 普通票; item.箱 = (i == null ? null : xiang); item.箱Id = i == null ? null : (Guid?)xiang.ID; item.费用实体 = new 普通票 { ID = item.票.ID, Version = item.票.Version, 费用实体类型编号 = item.票.费用实体类型编号 }; } else { System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString()); } object entity = cm.AddNew(); if (entity != null) { cm.DisplayManager.Items[cm.DisplayManager.Position] = item; cm.EndEdit(); } else { // 出现错误,不再继续。 AddNew的时候,前一个出现错误,没保存。然后提示时候保存,选不继续 masterForm.ControlManager.CancelEdit(); break; } } } }
public static void 批量生成空费用项(ArchiveOperationForm masterForm) { 普通票 piao = (masterForm.ParentForm as GeneratedArchiveOperationForm).DisplayManager.CurrentItem as 普通票; if (piao == null) { return; } if (masterForm.DisplayManager.Items.Count > 0) { if (!MessageForm.ShowYesNo("是否确定生成空费用项", "提示")) { return; } } using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <普通票>()) { IList <费用项> fyxList = (rep as Feng.NH.INHibernateRepository).Session.CreateSQLQuery( "select * from 参数备案_费用项 where 现有费用实体类型 like '%" + piao.费用实体类型编号 + ",%' and 票 = 1") .AddEntity(typeof(费用项)).List <费用项>(); if (fyxList == null || fyxList.Count == 0) { return; } foreach (费用项 fyx in fyxList) { 业务费用 fy = new 业务费用 { 费用项编号 = fyx.编号, 收付标志 = 收付标志.付, 票 = piao }; masterForm.ControlManager.AddNew(); masterForm.ControlManager.DisplayManager.Items[masterForm.DisplayManager.Position] = fy; masterForm.ControlManager.EndEdit(); } } }
static void DataRowTemplate_BeginningEdit(object sender, System.ComponentModel.CancelEventArgs e) { //masterForm.ActiveGrid.DataRowTemplate.Cells["票.费用实体类型"].ValueChanged += new EventHandler(process_fy_yw_ValueChanged); Xceed.Grid.DataRow dataRow = sender as Xceed.Grid.DataRow; if (((IBoundGrid)dataRow.GridControl).DisplayManager.InBatchOperation) { return; } //if (cell.ParentRow.Cells["费用类别编号"].Value != null // && cell.ParentRow.Cells["收付标志"].Value != null) //{ // StringBuilder filter = new StringBuilder(); // if (((收付标志)cell.ParentRow.Cells["收付标志"].Value) == 收付标志.收) // { // filter.Append("收 = 'true' AND 收入类别 = '" + cell.ParentRow.Cells["费用类别编号"].Value.ToString() + "'"); // } // else // { // filter.Append("付 = 'true' AND 支出类别 = '" + cell.ParentRow.Cells["费用类别编号"].Value.ToString() + "'"); // } // cell.ParentRow.Cells["费用项编号"].CellEditorManager = Feng.Windows.ControlDataLoad.GetGridComboEditor("费用项_业务_" + m_type, filter.ToString()); //} 业务费用 item = dataRow.Tag as 业务费用; bool isPiao = !item.箱Id.HasValue; string filter = "现有费用实体类型 LIKE '%" + item.票.费用实体类型编号; if (isPiao) { filter += ",%' AND 票 = " + isPiao; } else { filter += ",%' AND 箱 = " + !isPiao; } dataRow.Cells["费用项编号"].CellEditorManager = Feng.Windows.Utils.GridDataLoad.GetGridComboEditor("费用项_业务", filter); }
private static IList <费用> GetSelectedFee4Pz(ArchiveOperationForm masterForm) { IList <费用> list = new List <费用>(); foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 业务费用 item = dataRow.Tag as 业务费用; if (item.凭证费用明细 == null && item.对账单 == null) { // 界面之间跳转的,不共用数据,用复制数据,这样数据不会搞混 // 例如这里,生成凭证,费用的凭证费用明细字段设置了,但如果凭证地方取消,凭证费用明细字段却没清空 // 如果是用公用数据的话,会对这里产生影响。 list.Add(item.Clone() as 业务费用); } } return(list); }
public static void 批量添加进口费用(ArchiveOperationForm masterForm) { IControlManager cm = masterForm.ControlManager; ArchiveCheckForm form = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("选择_批量添加费用_进口票")) as ArchiveCheckForm; if (form != null && form.ShowDialog() == DialogResult.OK) { foreach (object i in form.SelectedEntites) { 业务费用 item = new 业务费用(); if (i is 普通票) { item.票 = i as 普通票; item.费用实体 = new 普通票 { ID = item.票.ID, Version = item.票.Version, 费用实体类型编号 = item.票.费用实体类型编号 }; } else { System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString()); } object entity = cm.AddNew(); if (entity != null) { cm.DisplayManager.Items[cm.DisplayManager.Position] = item; cm.EndEdit(); } else { // 出现错误,不再继续。 AddNew的时候,前一个出现错误,没保存。然后提示时候保存,选不继续 masterForm.ControlManager.CancelEdit(); break; } } } }
public static void 批量添加进口费用(ArchiveOperationForm masterForm) { IControlManager cm = masterForm.ControlManager; ArchiveCheckForm form = ServiceProvider.GetService<IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("选择_批量添加费用_进口票")) as ArchiveCheckForm; if (form != null && form.ShowDialog() == DialogResult.OK) { foreach (object i in form.SelectedEntites) { 业务费用 item = new 业务费用(); if (i is 普通票) { item.票 = i as 普通票; item.费用实体 = new 普通票 { ID = item.票.ID, Version = item.票.Version, 费用实体类型编号 = item.票.费用实体类型编号 }; } else { System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString()); } object entity = cm.AddNew(); if (entity != null) { cm.DisplayManager.Items[cm.DisplayManager.Position] = item; cm.EndEdit(); } else { // 出现错误,不再继续。 AddNew的时候,前一个出现错误,没保存。然后提示时候保存,选不继续 masterForm.ControlManager.CancelEdit(); break; } } } }
public static void 生成收款相应费用(ArchiveOperationForm masterForm) { if (masterForm.MasterGrid.GridControl.SelectedRows.Count == 0) { ServiceProvider.GetService <IMessageBox>().ShowWarning("请选择付款费用!"); return; } if (!MessageForm.ShowYesNo("是否要生成选中项相应的收款费用?", "确认")) { return; } int cnt = 0; using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>()) { foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 业务费用 entity = dataRow.Tag as 业务费用; if (entity.收付标志 == 收付标志.收) { continue; } rep.Initialize(entity.票, entity); 业务费用 item = new 业务费用(); item.收付标志 = 收付标志.收; item.费用实体 = entity.费用实体; item.费用项编号 = entity.费用项编号; //item.费用信息 = entity.费用信息; item.费用类别编号 = entity.费用类别编号; item.金额 = entity.金额; item.箱Id = entity.箱Id; item.相关人编号 = entity.票.委托人编号; item.票 = entity.票; item.箱 = entity.箱; object newEntity = masterForm.ControlManager.AddNew(); if (newEntity != null) { masterForm.ControlManager.DisplayManager.Items[masterForm.ControlManager.DisplayManager.Position] = item; masterForm.ControlManager.EndEdit(); //masterForm.ActiveGrid.CurrentDataRow.Cells["费用项编号"].CellEditorManager = dataRow.Cells["费用项编号"].CellEditorManager; cnt++; } else { masterForm.ControlManager.CancelEdit(); break; } } } MessageForm.ShowInfo("已生成" + cnt + "条收款费用!"); }
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); } } }
public static void 批量生成空费用项(ArchiveOperationForm masterForm) { 普通票 piao = (masterForm.ParentForm as GeneratedArchiveOperationForm).DisplayManager.CurrentItem as 普通票; if (piao == null) { return; } if (masterForm.DisplayManager.Items.Count > 0) { if (!MessageForm.ShowYesNo("是否确定生成空费用项", "提示")) { return; } } using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<普通票>()) { IList<费用项> fyxList = (rep as Feng.NH.INHibernateRepository).Session.CreateSQLQuery( "select * from 参数备案_费用项 where 现有费用实体类型 like '%" + piao.费用实体类型编号 + ",%' and 票 = 1") .AddEntity(typeof(费用项)).List<费用项>(); if (fyxList == null || fyxList.Count == 0) { return; } foreach (费用项 fyx in fyxList) { 业务费用 fy = new 业务费用 { 费用项编号 = fyx.编号, 收付标志 = 收付标志.付, 票 = piao }; masterForm.ControlManager.AddNew(); masterForm.ControlManager.DisplayManager.Items[masterForm.DisplayManager.Position] = fy; masterForm.ControlManager.EndEdit(); } } }
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 (b && 任务 != null) { b &= i.任务ID == 任务.ID; } if (b) { llrHaveGenerated = true; break; } } 业务费用理论值 ywfylrz = null; if (!llrHaveGenerated) { if (金额.HasValue) { ywfylrz = new 业务费用理论值(); ywfylrz.费用实体 = 产值; ywfylrz.费用项编号 = htfyx.费用项编号; ywfylrz.票 = 产值; ywfylrz.收付标志 = htfyx.收付标志; ywfylrz.相关人编号 = Get相关人(rep, 产值, 任务, htfyx); ywfylrz.车辆编号 = 产值.车辆编号; ywfylrz.费用归属 = (htfyx as 车队合同费用项).费用归属; //ywfylrz.金额 = 金额.Value; ProcessFywithSl(ywfylrz, 金额.Value); 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.费用归属 == htfyx.费用归属; 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.费用归属 == htfyx.费用归属; 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; 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 (htfyx.收付标志 == 收付标志.收) { fylbSubmitted = list[0].Submitted; } else { fylbSubmitted = list[0].完全标志付; } } // 完全标志还未打 if (!fylbSubmitted) { // 不生成理论值为0的 if (!金额.HasValue || (金额.HasValue && 金额.Value != 0)) { 业务费用 item = new 业务费用(); item.费用实体 = 产值; item.车辆产值 = 产值; item.费用项编号 = htfyx.费用项编号; item.收付标志 = htfyx.收付标志; item.相关人编号 = 相关人; item.车辆编号 = 产值.车辆编号; item.费用归属 = (htfyx as 车队合同费用项).费用归属; //item.金额 = 金额; if (金额 != null) { ProcessFywithSl(item, 金额.Value); } else { item.金额 = 金额; } if (任务 != null) { item.任务 = 任务; } (new 业务费用Dao()).Save(rep, item); 产值.费用.Add(item); } } } } }
public static void FyDoubleClick(object sender1, EventArgs e1) { Xceed.Grid.DataCell cell = sender1 as Xceed.Grid.DataCell; Xceed.Grid.DataRow row = cell.ParentRow as Xceed.Grid.DataRow; ArchiveSeeForm masterForm = cell.GridControl.FindForm() as ArchiveSeeForm; if (masterForm == null) { // 通过DetailForm来的 masterForm = (cell.GridControl.FindForm() as ArchiveDetailForm).ParentForm as ArchiveSeeForm; } ArchiveOperationForm fydjForm = masterForm.Tag as ArchiveOperationForm; //if (cell.FieldName == "拟付金额" || cell.FieldName == "拟收金额" || cell.FieldName == "费用项") { if (fydjForm == null) { fydjForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("业务备案_车辆产值费用_双击")) as ArchiveOperationForm; masterForm.Tag = fydjForm; Dictionary <string, object> setDatanew = new Dictionary <string, object>(); fydjForm.Tag = setDatanew; (fydjForm.ControlManager.Dao as 业务费用Dao).TransactionBeginning += new EventHandler <OperateArgs <费用> >(delegate(object sender, OperateArgs <费用> e) { if (e.Entity.费用实体 == null) { 业务费用 fy = e.Entity as 业务费用; fy.费用实体 = e.Repository.Get <费用实体>(setDatanew["费用实体"]); fy.费用项编号 = (string)setDatanew["费用项"]; fy.车辆产值 = fy.费用实体 as 车辆产值; } }); fydjForm.DisplayManager.SearchManager.EnablePage = false; fydjForm.DisplayManager.SearchManager.DataLoaded += new EventHandler <DataLoadedEventArgs>(delegate(object sender, DataLoadedEventArgs e) { fydjForm.TopMost = true; fydjForm.Show(); }); fydjForm.FormClosing += new FormClosingEventHandler(delegate(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (!masterForm.IsDisposed) { if (masterForm is ArchiveOperationForm) { (masterForm as ArchiveOperationForm).ControlManager.DisplayManager.SearchManager.ReloadItem((masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Position); (masterForm as ArchiveOperationForm).ControlManager.OnCurrentItemChanged(); } e.Cancel = true; fydjForm.Hide(); } else { } } }); } Dictionary <string, object> setData = fydjForm.Tag as Dictionary <string, object>; setData.Clear(); // 票费用登记窗体 if (row.Cells["费用实体"] != null) { setData["费用实体"] = (Guid)row.Cells["费用实体"].Value; setData["费用项"] = (string)row.Cells["费用项"].Value; if (/*cell.FieldName == "已收金额" || cell.FieldName == "应收金额" || */ cell.FieldName == "拟收金额") { setData["收付标志"] = 收付标志.收; } else if (/*cell.FieldName == "已付金额" || cell.FieldName == "应付金额" || */ cell.FieldName == "拟付金额") { setData["收付标志"] = 收付标志.付; } } else { throw new ArgumentException("There must be a column named 费用实体!"); } //NameValueMappingCollection.Instance["信息_箱号_动态"].Params["@票"] = (Guid)setData["费用实体"]; //NameValueMappingCollection.Instance.Reload("信息_箱号_动态"); //Feng.Windows.Forms.MyObjectPicker op = (fydjForm.MasterGrid.GetInsertionRow().Cells["任务"].CellEditorManager as Feng.Grid.Editors.MyObjectPickerEditor).TemplateControl; //string exp = "车辆产值.ID = " + ((Guid)setData["费用实体"]).ToString(); //op.SearchExpressionParam = exp; Feng.Windows.Forms.MyObjectPicker op = (fydjForm.MasterGrid.Columns["任务"].CellEditorManager as Feng.Grid.Editors.MyObjectPickerEditor).TemplateControl; string exp = "车辆产值.ID = " + ((Guid)setData["费用实体"]).ToString(); op.SearchExpressionParam = exp; ISearchExpression se = SearchExpression.And(SearchExpression.Eq("费用实体.ID", (Guid)setData["费用实体"]), SearchExpression.Eq("费用项编号", (string)setData["费用项"])); if (setData.ContainsKey("收付标志")) { se = SearchExpression.And(se, SearchExpression.Eq("收付标志", setData["收付标志"])); } fydjForm.ControlManager.DisplayManager.SearchManager.LoadData(se, new List <ISearchOrder>()); } }
public static void 批量添加费用(ArchiveOperationForm masterForm) { IControlManager cm = masterForm.ControlManager; ArchiveSelectForm selectForm = new ArchiveSelectForm("批量添加业务费用"); if (selectForm.ShowDialog() == DialogResult.OK) { ArchiveCheckForm form = selectForm.SelectedForm as ArchiveCheckForm; if (form != null && form.ShowDialog() == DialogResult.OK) { foreach (object i in form.SelectedEntites) { 业务费用 item = new 业务费用(); if (i is 普通票) { item.票 = i as 普通票; item.费用实体 = new 普通票 { ID = item.票.ID, Version = item.票.Version, 费用实体类型编号 = item.票.费用实体类型编号 }; } else if (i is 普通箱) { 普通箱 xiang = i as 普通箱; // it must have piao item.票 = xiang.GetType().InvokeMember("票", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public, null, xiang, null) as 普通票; item.箱 = (i == null ? null : xiang); item.箱Id = i == null ? null : (Guid?)xiang.ID; item.费用实体 = new 普通票 { ID = item.票.ID, Version = item.票.Version, 费用实体类型编号 = item.票.费用实体类型编号 }; } else { System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString()); } object entity = cm.AddNew(); if (entity != null) { cm.DisplayManager.Items[cm.DisplayManager.Position] = item; cm.EndEdit(); } else { // 出现错误,不再继续。 AddNew的时候,前一个出现错误,没保存。然后提示时候保存,选不继续 masterForm.ControlManager.CancelEdit(); break; } //bool isPiao = (i is 普通票); //string filter = "现有费用实体类型 LIKE '%" + (int)item.票.费用实体类型; //if (isPiao) //{ // filter += ",%' AND 票 = " + isPiao; //} //else //{ // filter += ",%' AND 箱 = " + !isPiao; //} //masterForm.ActiveGrid.CurrentDataRow.Cells["费用项编号"].CellEditorManager = ControlDataLoad.GetGridComboEditor("费用项_业务", filter); } } } }
private static void ProcessFywithSl(业务费用 ywfylrz, decimal d) { IDefinition def = ServiceProvider.GetService<IDefinition>(); if (ywfylrz.费用项编号 == "203") // 轮胎补贴 { decimal? dd = Feng.Utils.ConvertHelper.ToDecimal(def.TryGetValue("轮胎补贴率")); if (dd.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * dd; } else { throw new ArgumentException("数据库中必须配置轮胎补贴率!"); } } else if (ywfylrz.费用项编号 == "204" || ywfylrz.费用项编号 == "205") // 油费 { decimal? czyj = Feng.Utils.ConvertHelper.ToDecimal(def.TryGetValue("车主油价")); decimal? jsyyj = Feng.Utils.ConvertHelper.ToDecimal(def.TryGetValue("驾驶员油价")); decimal? cbyj = Feng.Utils.ConvertHelper.ToDecimal(def.TryGetValue("成本油价")); if (ywfylrz.车辆产值.车辆 != null) { switch (ywfylrz.车辆产值.车辆.车辆类别) { case 车辆类别.自有车: case 车辆类别.代管车: if (ywfylrz.费用归属 == 费用归属.对外) { if (cbyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * cbyj; } else { throw new ArgumentException("数据库中必须配置成本油价!"); } } else { if (jsyyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * jsyyj; } else { throw new ArgumentException("数据库中必须配置驾驶员油价!"); } } break; case 车辆类别.挂靠车: if (ywfylrz.费用归属 == 费用归属.对外) { if (cbyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * cbyj; } else { throw new ArgumentException("数据库中必须配置成本油价!"); } } else if (ywfylrz.费用归属 == 费用归属.车主) { if (ywfylrz.费用项编号 == "204") //油费 { if (czyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * czyj; } else { throw new ArgumentException("数据库中必须配置车主油价!"); } } else if (ywfylrz.费用项编号 == "205") //定耗油 { if (czyj.HasValue && jsyyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * (czyj - jsyyj); } else { throw new ArgumentException("数据库中必须配置车主油价、驾驶员油价!"); } } } else { throw new ArgumentException("费用归属不规范!"); } break; case 车辆类别.外协车: break; default: throw new ArgumentException("车辆类别不规范!"); } } } else { ywfylrz.金额 = d; } }
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 (b && 任务 != null) { b &= i.任务ID == 任务.ID; } if (b) { llrHaveGenerated = true; break; } } 业务费用理论值 ywfylrz = null; if (!llrHaveGenerated) { if (金额.HasValue) { ywfylrz = new 业务费用理论值(); ywfylrz.费用实体 = 产值; ywfylrz.费用项编号 = htfyx.费用项编号; ywfylrz.票 = 产值; ywfylrz.收付标志 = htfyx.收付标志; ywfylrz.相关人编号 = Get相关人(rep, 产值, 任务, htfyx); ywfylrz.车辆编号 = 产值.车辆编号; ywfylrz.费用归属 = (htfyx as 车队合同费用项).费用归属; //ywfylrz.金额 = 金额.Value; ProcessFywithSl(ywfylrz, 金额.Value); 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.费用归属 == htfyx.费用归属; 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.费用归属 == htfyx.费用归属; 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; 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 (htfyx.收付标志 == 收付标志.收) { fylbSubmitted = list[0].Submitted; } else { fylbSubmitted = list[0].完全标志付; } } // 完全标志还未打 if (!fylbSubmitted) { // 不生成理论值为0的 if (!金额.HasValue || (金额.HasValue && 金额.Value != 0)) { 业务费用 item = new 业务费用(); item.费用实体 = 产值; item.车辆产值 = 产值; item.费用项编号 = htfyx.费用项编号; item.收付标志 = htfyx.收付标志; item.相关人编号 = 相关人; item.车辆编号 = 产值.车辆编号; item.费用归属 = (htfyx as 车队合同费用项).费用归属; //item.金额 = 金额; if (金额 != null) { ProcessFywithSl(item, 金额.Value); } else { item.金额 = 金额; } if (任务 != null) { item.任务 = 任务; } (new 业务费用Dao()).Save(rep, item); 产值.费用.Add(item); } } } } }
public static void 批量添加费用(ArchiveOperationForm masterForm) { IControlManager cm = masterForm.ControlManager; ArchiveSelectForm selectForm = new ArchiveSelectForm("批量添加业务费用"); if (selectForm.ShowDialog() == DialogResult.OK) { ArchiveCheckForm form = selectForm.SelectedForm as ArchiveCheckForm; if (form != null && form.ShowDialog() == DialogResult.OK) { foreach (object i in form.SelectedEntites) { 业务费用 item = new 业务费用(); if (i is 车辆产值) { 车辆产值 tang = i as 车辆产值; item.车辆 = (i == null ? null : tang.车辆); item.车辆编号 = i == null ? null : (Guid?)tang.车辆编号; item.费用实体 = tang; item.车辆产值 = tang; } else if (i is 任务) { 任务 xiang = i as 任务; // it must have piao //item.车辆产值 = xiang.车辆产值; item.任务 = (i == null ? null : xiang); item.车辆 = (i == null ? null : xiang.车辆产值.车辆); item.车辆编号 = i == null ? null : (Guid?)xiang.车辆产值.车辆编号; item.费用实体 = xiang.车辆产值;// new 车辆产值 { ID = item.车辆产值.ID, Version = item.车辆产值.Version }; item.车辆产值 = xiang.车辆产值; } else { System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString()); } object entity = cm.AddNew(); if (entity != null) { cm.DisplayManager.Items[cm.DisplayManager.Position] = item; cm.EndEdit(); } else { // 出现错误,不再继续。 AddNew的时候,前一个出现错误,没保存。然后提示时候保存,选不继续 masterForm.ControlManager.CancelEdit(); break; } //bool isPiao = (i is 普通票); //string filter = "现有费用实体类型 LIKE '%" + (int)item.票.费用实体类型; //if (isPiao) //{ // filter += ",%' AND 票 = " + isPiao; //} //else //{ // filter += ",%' AND 箱 = " + !isPiao; //} //masterForm.ActiveGrid.CurrentDataRow.Cells["费用项编号"].CellEditorManager = ControlDataLoad.GetGridComboEditor("费用项_业务", filter); } } } }
public static void 生成开票税(ArchiveOperationForm masterForm) { decimal sl = Convert.ToDecimal(ServiceProvider.GetService <IDefinition>().TryGetValue("开票税率")); if (sl == 0) { throw new InvalidUserOperationException("当前开票税率值无效!"); } if (MessageForm.ShowYesNo("是否自动生成开票税?当前税率: " + sl * 100 + "%", "提示")) { int count = 0; try { if (masterForm.DisplayManager.Items != null && masterForm.DisplayManager.Items.Count > 0) { foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 业务费用 fy = dataRow.Tag as 业务费用; if ((fy.费用项编号 == "102" || fy.费用项编号 == "103") && fy.费用归属 == 费用归属.委托人 && fy.收付标志 == 收付标志.收) { 业务费用 kps = masterForm.ControlManager.AddNew() as 业务费用; kps.费用归属 = 费用归属.对外; kps.收付标志 = 收付标志.付; kps.相关人编号 = "900130"; kps.费用项编号 = "335"; kps.金额 = decimal.Multiply(fy.金额.Value, sl); kps.费用实体 = fy.费用实体; kps.车辆产值 = fy.车辆产值; kps.车辆编号 = fy.车辆编号; kps.任务 = fy.任务; masterForm.DisplayManager.DisplayCurrent(); masterForm.ControlManager.EndEdit(true); count++; } } //for (int i = 0; i < masterForm.DisplayManager.Items.Count; i++) //{ // masterForm.DisplayManager.Position = i; // 业务费用 fy = masterForm.DisplayManager.CurrentItem as 业务费用; // // 当 费用项=运费 费用归属=委托人 收款记录 生成: // // 费用归属=对外 付 相关人=税务局 费用项=开票税 金额=运费*开票税率 // if (fy.费用项编号 == "102" && fy.费用归属 == 费用归属.委托人 && fy.收付标志 == 收付标志.收) // { // 业务费用 kps = masterForm.ControlManager.AddNew() as 业务费用; // kps.费用归属 = 费用归属.对外; // kps.收付标志 = 收付标志.付; // kps.相关人编号 = "900130"; // kps.费用项编号 = "335"; // kps.金额 = decimal.Multiply(fy.金额.Value, sl); // kps.费用实体 = fy.费用实体; // kps.车辆编号 = fy.车辆编号; // kps.任务 = fy.任务; // masterForm.DisplayManager.DisplayCurrent(); // masterForm.ControlManager.EndEdit(true); // count++; // } //} } } catch (Exception ex) { throw new InvalidUserOperationException(ex.Message); } finally { MessageForm.ShowInfo("已生成 " + count + " 条开票税!"); } } }
public static void 费用登记(ArchiveOperationForm masterForm) { int successCount = 0, skipCount = 0; ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper( new Feng.Async.AsyncHelper.DoWork(delegate() { using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<业务费用>()) { rep.BeginTransaction(); foreach (Xceed.Grid.DataRow row in masterForm.MasterGrid.GridControl.SelectedRows) { // 90 = 未备案 // 91 = 提单号不合理 // 92 = 箱号不合理 // 93 = 金额不同 // 94 = 已对账已凭证 // 95 = 未对账 // 96 = 未登记 // 97 = 未排车 // 98 = 费用不完整 if (!row.Cells["状态"].Value.ToString().Contains("96")) // 只有“未登记”的费用才会被登记 { skipCount++; continue; } if (row.Cells["相关人"].Value == null || row.Cells["费用项"].Value == null) { if (MessageForm.ShowYesNo("第 " + row.Cells["ID"].Value.ToString() + " 条费用,填写不完整!" + Environment.NewLine + "提单号:" + row.Cells["提单号"].Value.ToString() + " 箱号:" + row.Cells["箱号"].Value.ToString() + Environment.NewLine + "“是”跳过继续登记,“否”取消所有登记?", "提示")) { skipCount++; continue; } else { successCount = skipCount = 0; rep.RollbackTransaction(); return null; } } 业务费用 ywfy = new 业务费用(); ywfy.相关人编号 = row.Cells["相关人"].Value.ToString(); ywfy.费用项编号 = row.Cells["费用项"].Value.ToString(); ywfy.金额 = Convert.ToDecimal(row.Cells["金额"].Value); ywfy.收付标志 = 收付标志.付; ywfy.费用归属 = 费用归属.委托人; ywfy.车辆产值 = rep.Get<车辆产值>(new Guid(row.Cells["车辆产值"].Value.ToString())); ywfy.任务 = rep.Get<任务>(new Guid(row.Cells["任务"].Value.ToString())); ywfy.费用实体 = ywfy.车辆产值; new 业务费用Dao().Save(rep, ywfy); successCount++; //rep.Save(ywfy); } rep.CommitTransaction(); } return null; }), new Feng.Async.AsyncHelper.WorkDone(delegate(object result) { MessageForm.ShowInfo("成功" + successCount + "条, 跳过" + skipCount + "条"); }), masterForm, "登记"); }
public static void 生成车主承担费用(ArchiveOperationForm masterForm) { if (MessageForm.ShowYesNo("是否自动生成车主承担费用?", "提示")) { int count = 0; try { if (masterForm.DisplayManager.Items != null && masterForm.DisplayManager.Items.Count > 0) { foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) { continue; } 业务费用 fy = dataRow.Tag as 业务费用; 车队费用项 fyx = EntityBufferCollection.Instance.Get <车队费用项>(fy.费用项编号); if (fyx.车主 == null) { continue; } // 把 费用归属<>车主 的记录 逐条生成 费用归属=车主的 // 收付标志 反一下 相关人=承运人 。。。 using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>()) { rep.Initialize(fy.车辆产值, fy); } if (fy.费用归属 != 费用归属.车主) { 业务费用 kps = masterForm.ControlManager.AddNew() as 业务费用; kps.费用归属 = 费用归属.车主; kps.收付标志 = fy.收付标志 == 收付标志.收 ? 收付标志.付 : 收付标志.收; kps.相关人编号 = fy.车辆产值.承运人编号; kps.数量 = fy.数量; kps.费用项编号 = fy.费用项编号; kps.金额 = fy.金额; kps.费用实体 = fy.费用实体; kps.车辆产值 = fy.车辆产值; kps.车辆编号 = fy.车辆编号; kps.任务 = fy.任务; masterForm.DisplayManager.DisplayCurrent(); masterForm.ControlManager.EndEdit(true); count++; } } //for (int i = 0; i < masterForm.DisplayManager.Items.Count; i++) //{ // masterForm.DisplayManager.Position = i; // 业务费用 fy = masterForm.DisplayManager.CurrentItem as 业务费用; // // 把 费用归属<>车主 的记录 逐条生成 费用归属=车主的 // // 收付标志 反一下 相关人=承运人 。。。 // using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<业务费用>()) // { // rep.Initialize(fy.车辆产值, fy); // } // if (fy.费用归属 != 费用归属.车主) // { // 业务费用 kps = masterForm.ControlManager.AddNew() as 业务费用; // kps.费用归属 = 费用归属.车主; // kps.收付标志 = fy.收付标志 == 收付标志.收 ? 收付标志.付 : 收付标志.收; // kps.相关人编号 = fy.车辆产值.承运人编号; // kps.费用项编号 = fy.费用项编号; // kps.金额 = fy.金额; // kps.费用类别编号 = fy.费用类别编号; // kps.费用实体 = fy.费用实体; // kps.车辆编号 = fy.车辆编号; // kps.任务 = fy.任务; // masterForm.DisplayManager.DisplayCurrent(); // masterForm.ControlManager.EndEdit(true); // count++; // } //} } } catch (Exception ex) { throw new InvalidUserOperationException(ex.Message); } finally { MessageForm.ShowInfo("已生成 " + count + " 条车主费用!"); } } }
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; } } }
public static void 批量添加进口箱费用(ArchiveOperationForm masterForm) { IControlManager cm = masterForm.ControlManager; ArchiveCheckForm form = ServiceProvider.GetService<IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("选择_批量添加费用_进口箱")) as ArchiveCheckForm; if (form != null && form.ShowDialog() == DialogResult.OK) { foreach (object i in form.SelectedEntites) { 业务费用 item = new 业务费用(); if (i is 普通箱) { 普通箱 xiang = i as 普通箱; // it must have piao item.票 = xiang.GetType().InvokeMember("票", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public, null, xiang, null) as 普通票; item.箱 = (i == null ? null : xiang); item.箱Id = i == null ? null : (Guid?)xiang.ID; item.费用实体 = new 普通票 { ID = item.票.ID, Version = item.票.Version, 费用实体类型编号 = item.票.费用实体类型编号 }; } else { System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString()); } object entity = cm.AddNew(); if (entity != null) { cm.DisplayManager.Items[cm.DisplayManager.Position] = item; cm.EndEdit(); } else { // 出现错误,不再继续。 AddNew的时候,前一个出现错误,没保存。然后提示时候保存,选不继续 masterForm.ControlManager.CancelEdit(); break; } } } }
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 生成收款相应费用(ArchiveOperationForm masterForm) { if (masterForm.MasterGrid.GridControl.SelectedRows.Count == 0) { ServiceProvider.GetService<IMessageBox>().ShowWarning("请选择付款费用!"); return; } if (!MessageForm.ShowYesNo("是否要生成选中项相应的收款费用?", "确认")) { return; } int cnt = 0; using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<业务费用>()) { foreach (Xceed.Grid.Row row in masterForm.MasterGrid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow == null) continue; 业务费用 entity = dataRow.Tag as 业务费用; if (entity.收付标志 == 收付标志.收) continue; rep.Initialize(entity.票, entity); 业务费用 item = new 业务费用(); item.收付标志 = 收付标志.收; item.费用实体 = entity.费用实体; item.费用项编号 = entity.费用项编号; //item.费用信息 = entity.费用信息; item.费用类别编号 = entity.费用类别编号; item.金额 = entity.金额; item.箱Id = entity.箱Id; item.相关人编号 = entity.票.委托人编号; item.票 = entity.票; item.箱 = entity.箱; object newEntity = masterForm.ControlManager.AddNew(); if (newEntity != null) { masterForm.ControlManager.DisplayManager.Items[masterForm.ControlManager.DisplayManager.Position] = item; masterForm.ControlManager.EndEdit(); //masterForm.ActiveGrid.CurrentDataRow.Cells["费用项编号"].CellEditorManager = dataRow.Cells["费用项编号"].CellEditorManager; cnt++; } else { masterForm.ControlManager.CancelEdit(); break; } } } MessageForm.ShowInfo("已生成" + cnt + "条收款费用!"); }
public static void 费用登记(ArchiveOperationForm masterForm) { int successCount = 0, skipCount = 0; ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper( new Feng.Async.AsyncHelper.DoWork(delegate() { using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>()) { rep.BeginTransaction(); foreach (Xceed.Grid.DataRow row in masterForm.MasterGrid.GridControl.SelectedRows) { // 60 = 未备案 // 61 = 箱号不合理 // 62 = 金额不同 // 63 = 已对账已凭证 // 64 = 未对账 // 65 = 未登记 // 66 = 费用不完整 if (!row.Cells["状态"].Value.ToString().Contains("65")) // 只有“未登记”的费用才会被登记 { skipCount++; continue; } if (row.Cells["相关人"].Value == null || row.Cells["费用项"].Value == null) { if (MessageForm.ShowYesNo("第 " + row.Cells["Id"].Value.ToString() + " 条费用,填写不完整!" + Environment.NewLine + "提单号:" + row.Cells["提单号"].Value.ToString() + " 箱号:" + row.Cells["箱号"].Value.ToString() + Environment.NewLine + "“是”跳过继续登记,“否”取消所有登记?", "提示")) { skipCount++; continue; } else { successCount = skipCount = 0; rep.RollbackTransaction(); return(null); } } 业务费用 ywfy = new 业务费用(); ywfy.相关人编号 = row.Cells["相关人"].Value.ToString(); ywfy.费用项编号 = row.Cells["费用项"].Value.ToString(); ywfy.金额 = Convert.ToDecimal(row.Cells["金额"].Value); ywfy.收付标志 = 收付标志.付; ywfy.票 = rep.Get <普通票>(new Guid(row.Cells["费用实体"].Value.ToString())); ywfy.箱Id = new Guid(row.Cells["箱"].Value.ToString()); ywfy.费用实体 = ywfy.票; new 业务费用Dao().Save(rep, ywfy); successCount++; //rep.Save(ywfy); } rep.CommitTransaction(); } return(null); }), new Feng.Async.AsyncHelper.WorkDone(delegate(object result) { MessageForm.ShowInfo("成功" + successCount + "条, 跳过" + skipCount + "条"); }), masterForm, "登记"); }
public static void FyDoubleClick(object sender1, EventArgs e1) { Xceed.Grid.DataCell cell = sender1 as Xceed.Grid.DataCell; Xceed.Grid.DataRow row = cell.ParentRow as Xceed.Grid.DataRow; //if (row.ParentGrid.ReadOnly) // return; //IBoundGrid grid = (m_masterForm.ArchiveDetailForm as IArchiveDetailFormWithDetailGrids).DetailGrids[0]; ArchiveSeeForm masterForm = cell.GridControl.FindForm() as ArchiveSeeForm; if (masterForm == null) { // 通过DetailForm来的 masterForm = (cell.GridControl.FindForm() as ArchiveDetailForm).ParentForm as ArchiveSeeForm; } ArchiveOperationForm fydjForm = masterForm.Tag as ArchiveOperationForm; //if (cell.FieldName == "拟付金额" || cell.FieldName == "拟收金额" || cell.FieldName == "费用项") { if (fydjForm == null) { if (masterForm.Name == "内贸出港_票费用") { fydjForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("内贸出港_票费用项费用登记")) as ArchiveOperationForm; } else { fydjForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("业务财务_票费用项费用登记")) as ArchiveOperationForm; } masterForm.Tag = fydjForm; Dictionary <string, object> setDatanew = new Dictionary <string, object>(); fydjForm.Tag = setDatanew; (fydjForm.ControlManager.Dao as 业务费用Dao).TransactionBeginning += new EventHandler <OperateArgs <业务费用> >(delegate(object sender, OperateArgs <业务费用> e) { if (e.Entity.费用实体 == null) { 业务费用 fy = e.Entity as 业务费用; fy.费用实体 = e.Repository.Get <费用实体>(setDatanew["费用实体"]); fy.票 = fy.费用实体 as 普通票; fy.费用项编号 = (string)setDatanew["费用项"]; } }); fydjForm.DisplayManager.SearchManager.EnablePage = false; fydjForm.DisplayManager.SearchManager.DataLoaded += new EventHandler <DataLoadedEventArgs>(delegate(object sender, DataLoadedEventArgs e) { fydjForm.TopMost = true; fydjForm.Show(); }); fydjForm.FormClosing += new FormClosingEventHandler(delegate(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (!masterForm.IsDisposed) { if (masterForm is ArchiveOperationForm) { //(masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Items[(masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Position] = (fydjForm.DisplayManager.CurrentItem as 费用).费用实体; (masterForm as ArchiveOperationForm).ControlManager.DisplayManager.SearchManager.ReloadItem((masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Position); (masterForm as ArchiveOperationForm).ControlManager.OnCurrentItemChanged(); } //IBoundGrid grid = (masterForm.ArchiveDetailForm as IArchiveDetailFormWithDetailGrids).DetailGrids[0]; //ISearchManager sm = grid.DisplayManager.SearchManager; //System.Data.DataTable dt = (System.Data.DataTable)sm.FindData(new List<ISearchExpression> { }, null); //foreach (System.Data.DataRow i in dt.Rows) //{ // if (i["费用项"].ToString() == setDatanew["费用项"].ToString()) // { // object save = row.Cells["Submitted"].Value; // grid.SetDataRowsIListData(i, row); // row.Cells["Submitted"].Value = save; // break; // } //} e.Cancel = true; fydjForm.Hide(); } } }); } Dictionary <string, object> setData = fydjForm.Tag as Dictionary <string, object>; setData.Clear(); //进口_额外费用_委托人 费用项双击事件 if (masterForm.Text.Equals("进口_额外费用_委托人")) { //明细窗体 if (cell.ParentColumn.Title.Equals("费用项")) { setData["费用实体"] = (Guid)row.Cells["费用实体"].Value; setData["费用项"] = (string)row.Cells["费用项"].Value; } //主窗体 else { using (var rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <费用项>()) { IList <费用项> list = (rep as Feng.NH.INHibernateRepository).List <费用项>(NHibernate.Criterion.DetachedCriteria.For <费用项>() .Add(NHibernate.Criterion.Expression.Eq("名称", cell.ParentColumn.Title))); if (list != null && list.Count > 0) { setData["费用实体"] = (row.Tag as 进口票).ID; setData["费用项"] = list[0].编号; } } } } // 票费用登记窗体 else if (row.Cells["费用实体"] != null) { setData["费用实体"] = (Guid)row.Cells["费用实体"].Value; setData["费用项"] = (string)row.Cells["费用项"].Value; if (/*cell.FieldName == "已收金额" || cell.FieldName == "应收金额" || */ cell.FieldName == "拟收金额") { setData["收付标志"] = 收付标志.收; } else if (/*cell.FieldName == "已付金额" || cell.FieldName == "应付金额" || */ cell.FieldName == "拟付金额") { setData["收付标志"] = 收付标志.付; } } // 滞箱费 else { setData["费用实体"] = (row.Tag as 费用信息).票Id; setData["费用项"] = "167"; } NameValueMappingCollection.Instance["信息_箱号_动态"].Params["@票"] = (Guid)setData["费用实体"]; NameValueMappingCollection.Instance.Reload(fydjForm.DisplayManager.Name, "信息_箱号_动态"); ISearchExpression se = SearchExpression.And(SearchExpression.Eq("费用实体.ID", (Guid)setData["费用实体"]), SearchExpression.Eq("费用项编号", (string)setData["费用项"])); if (setData.ContainsKey("收付标志")) { se = SearchExpression.And(se, SearchExpression.Eq("收付标志", setData["收付标志"])); } fydjForm.ControlManager.DisplayManager.SearchManager.LoadData(se, null); } //Dictionary<string, bool?> submitted = new Dictionary<string, bool?>(); //foreach (Xceed.Grid.DataRow i in grid.DataRows) //{ // submitted[i.Cells["费用项"].Value.ToString()] = (bool?)i.Cells["Submitted"].Value; //} //(row.GridControl as IBoundGrid).ReloadData(); //foreach (Xceed.Grid.DataRow i in grid.DataRows) //{ // i.Cells["Submitted"].Value = submitted[i.Cells["费用项"].Value.ToString()]; //} }
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 void ProcessFywithSl(业务费用 ywfylrz, decimal d) { IDefinition def = ServiceProvider.GetService <IDefinition>(); if (ywfylrz.费用项编号 == "203") // 轮胎补贴 { decimal?dd = Feng.Utils.ConvertHelper.ToDecimal(def.TryGetValue("轮胎补贴率")); if (dd.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * dd; } else { throw new ArgumentException("数据库中必须配置轮胎补贴率!"); } } else if (ywfylrz.费用项编号 == "204" || ywfylrz.费用项编号 == "205") // 油费 { decimal?czyj = Feng.Utils.ConvertHelper.ToDecimal(def.TryGetValue("车主油价")); decimal?jsyyj = Feng.Utils.ConvertHelper.ToDecimal(def.TryGetValue("驾驶员油价")); decimal?cbyj = Feng.Utils.ConvertHelper.ToDecimal(def.TryGetValue("成本油价")); if (ywfylrz.车辆产值.车辆 != null) { switch (ywfylrz.车辆产值.车辆.车辆类别) { case 车辆类别.自有车: case 车辆类别.代管车: if (ywfylrz.费用归属 == 费用归属.对外) { if (cbyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * cbyj; } else { throw new ArgumentException("数据库中必须配置成本油价!"); } } else { if (jsyyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * jsyyj; } else { throw new ArgumentException("数据库中必须配置驾驶员油价!"); } } break; case 车辆类别.挂靠车: if (ywfylrz.费用归属 == 费用归属.对外) { if (cbyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * cbyj; } else { throw new ArgumentException("数据库中必须配置成本油价!"); } } else if (ywfylrz.费用归属 == 费用归属.车主) { if (ywfylrz.费用项编号 == "204") //油费 { if (czyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * czyj; } else { throw new ArgumentException("数据库中必须配置车主油价!"); } } else if (ywfylrz.费用项编号 == "205") //定耗油 { if (czyj.HasValue && jsyyj.HasValue) { ywfylrz.数量 = d; ywfylrz.金额 = d * (czyj - jsyyj); } else { throw new ArgumentException("数据库中必须配置车主油价、驾驶员油价!"); } } } else { throw new ArgumentException("费用归属不规范!"); } break; case 车辆类别.外协车: break; default: throw new ArgumentException("车辆类别不规范!"); } } } else { ywfylrz.金额 = d; } }