public ItemDim CreateItemDim(Session session, Guid RefId) { try { NAS.DAL.Nomenclature.Item.Item item = session.GetObjectByKey <NAS.DAL.Nomenclature.Item.Item>(RefId); if (item == null) { return(null); } ItemDim itemDim = new ItemDim(session); itemDim.Code = item.Code; itemDim.Description = item.Description; itemDim.RefId = RefId; itemDim.Name = item.Name; itemDim.RowStatus = Constant.ROWSTATUS_ACTIVE; itemDim.Save(); return(itemDim); } catch (Exception) { return(null); } }
public void CreateFinancialRevenueByItem(Session session, Guid _BillId, Guid _CustomerOrgId, Guid _OwnerOrgId, Item _Item, Unit _Unit, int Day, int Month, int Year, string _AssetDim) { FinancialRevenueByItem_Fact result = new FinancialRevenueByItem_Fact(session); try { SalesInvoice invoice = session.GetObjectByKey <SalesInvoice>(_BillId); if (!Util.IsExistXpoObject <InvoiceDim>(session, "RefId", _BillId)) { InvoiceDim invoiceDim = new InvoiceDim(session); invoiceDim.RefId = _BillId; invoiceDim.Code = invoice.Code; invoiceDim.Name = ""; invoiceDim.Description = ""; invoiceDim.IssueDate = invoice.IssuedDate; invoiceDim.RowStatus = Constant.ROWSTATUS_ACTIVE; invoiceDim.Save(); } if (!Util.IsExistXpoObject <DayDim>(session, "Name", Day.ToString())) { DayDim dayDim = new DayDim(session); dayDim.Description = Day.ToString(); dayDim.Name = Day.ToString(); dayDim.RowStatus = Constant.ROWSTATUS_ACTIVE; dayDim.Save(); } if (!Util.IsExistXpoObject <MonthDim>(session, "Name", Month.ToString())) { MonthDim MonthDim = new MonthDim(session); MonthDim.Description = Month.ToString(); MonthDim.Name = Month.ToString(); MonthDim.RowStatus = Constant.ROWSTATUS_ACTIVE; MonthDim.Save(); } if (!Util.IsExistXpoObject <YearDim>(session, "Name", Year.ToString())) { YearDim YearDim = new YearDim(session); YearDim.Description = Year.ToString(); YearDim.Name = Year.ToString(); YearDim.RowStatus = Constant.ROWSTATUS_ACTIVE; YearDim.Save(); } if (!Util.IsExistXpoObject <FinancialAssetDim>(session, "Name", _AssetDim)) { FinancialAssetDim assetDim = new FinancialAssetDim(session); assetDim.Name = _AssetDim; assetDim.Description = _AssetDim; assetDim.RowStatus = Constant.ROWSTATUS_ACTIVE; assetDim.Save(); } if (!Util.IsExistXpoObject <ItemDim>(session, "RefId", _Item.ItemId)) { ItemDim itemDim = new ItemDim(session); itemDim.RefId = _Item.ItemId; itemDim.Code = _Item.Code; itemDim.Name = _Item.Name; itemDim.Description = _Item.Description; itemDim.RowStatus = Constant.ROWSTATUS_ACTIVE; itemDim.Save(); } if (!Util.IsExistXpoObject <UnitDim>(session, "RefId", _Unit.UnitId)) { UnitDim unitDim = new UnitDim(session); unitDim.RefId = _Unit.UnitId; unitDim.Code = _Unit.Code; unitDim.Name = _Unit.Name; unitDim.Description = _Unit.Description; unitDim.RowStatus = Constant.ROWSTATUS_ACTIVE; unitDim.Save(); } if (!Util.IsExistXpoObject <CustomerOrgDim>(session, "RefId", _CustomerOrgId)) { Organization customerOrg = session.GetObjectByKey <Organization>(_CustomerOrgId); if (customerOrg != null) { CustomerOrgDim customerOrgDim = new CustomerOrgDim(session); customerOrgDim.RefId = _CustomerOrgId; customerOrgDim.Code = customerOrg.Code; customerOrgDim.Name = customerOrg.Name; customerOrgDim.Description = customerOrg.Description; customerOrgDim.RowStatus = Constant.ROWSTATUS_ACTIVE; customerOrgDim.Save(); } } if (!Util.IsExistXpoObject <OwnerOrgDim>(session, "RefId", _OwnerOrgId)) { Organization ownerOrg = session.GetObjectByKey <Organization>(_OwnerOrgId); if (ownerOrg != null) { OwnerOrgDim ownerOrgDim = new OwnerOrgDim(session); ownerOrgDim.RefId = _OwnerOrgId; ownerOrgDim.Code = ownerOrg.Code; ownerOrgDim.Name = ownerOrg.Name; ownerOrgDim.Description = ownerOrg.Description; ownerOrgDim.RowStatus = Constant.ROWSTATUS_ACTIVE; ownerOrgDim.Save(); } } Util util = new Util(); result.InvoiceDimId = util.GetXpoObjectByFieldName <InvoiceDim, Guid>(session, "RefId", _BillId, DevExpress.Data.Filtering.BinaryOperatorType.Equal); result.FinancialAssetDimId = Util.getXpoObjectByName <FinancialAssetDim>(session, _AssetDim); result.DayDimId = Util.getXpoObjectByName <DayDim>(session, Day.ToString()); result.MonthDimId = Util.getXpoObjectByName <MonthDim>(session, Month.ToString()); result.YearDimId = Util.getXpoObjectByName <YearDim>(session, Year.ToString()); result.ItemDimId = util.GetXpoObjectByFieldName <ItemDim, string>(session, "Code", _Item.Code, DevExpress.Data.Filtering.BinaryOperatorType.Equal); result.UnitDimId = util.GetXpoObjectByFieldName <UnitDim, string>(session, "Code", _Unit.Code, DevExpress.Data.Filtering.BinaryOperatorType.Equal); result.CustomerOrgDimId = util.GetXpoObjectByFieldName <CustomerOrgDim, Guid>(session, "RefId", _CustomerOrgId, DevExpress.Data.Filtering.BinaryOperatorType.Equal); result.OwnerOrgDimId = util.GetXpoObjectByFieldName <OwnerOrgDim, Guid>(session, "RefId", _OwnerOrgId, DevExpress.Data.Filtering.BinaryOperatorType.Equal); result.Save(); } catch (Exception) { } }