public override List <NASCustomFieldPredefinitionData> GetPredefinitionDataOfObject(Guid objectCustomFieldId) { List <NASCustomFieldPredefinitionData> ret = null; Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomField objectCustomField = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); if (objectCustomField.ObjectCustomFieldDatas != null) { ret = new List <NASCustomFieldPredefinitionData>(); foreach (var data in objectCustomField.ObjectCustomFieldDatas) { PredefinitionData predefinitionData = (PredefinitionData)data.CustomFieldDataId; SalesInvoice salesInvoice = session.GetObjectByKey <SalesInvoice>(predefinitionData.RefId); if (salesInvoice != null) { NASCustomFieldPredefinitionData retItem = new NASCustomFieldPredefinitionData() { Code = salesInvoice.Code, Description = String.Empty, Name = String.Empty, PredefinitionType = Enum.GetName(typeof(MultiSelectionBuiltInTypeEnum), MultiSelectionBuiltInTypeEnum.MULTI_CHOICE_LIST_INVOICE_SALE), RefId = salesInvoice.BillId }; ret.Add(retItem); } } } return(ret); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
public override List <NASCustomFieldPredefinitionData> GetPredefinitionDataOfObject(Guid objectCustomFieldId) { List <NASCustomFieldPredefinitionData> ret = null; Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomField objectCustomField = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); if (objectCustomField.ObjectCustomFieldDatas != null) { ret = new List <NASCustomFieldPredefinitionData>(); foreach (var data in objectCustomField.ObjectCustomFieldDatas) { PredefinitionData predefinitionData = (PredefinitionData)data.CustomFieldDataId; Organization organization = session.GetObjectByKey <Organization>(predefinitionData.RefId); if (organization != null) { NASCustomFieldPredefinitionData retItem = new NASCustomFieldPredefinitionData() { Code = organization.Code, Description = organization.Description, Name = organization.Name, PredefinitionType = Enum.GetName(typeof(MultiSelectionBuiltInTypeEnum), MultiSelectionBuiltInTypeEnum.MULTI_CHOICE_LIST_CUSTOMER), RefId = organization.OrganizationId }; ret.Add(retItem); } } } return(ret); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
public CustomFieldDataPreDefinitionData GetData(Guid objectCustomFieldId) { CustomFieldDataPreDefinitionData ret = null; Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomField objectCustomField = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); if (objectCustomField.ObjectCustomFieldDatas != null) { ret = new CustomFieldDataPreDefinitionData(); foreach (var data in objectCustomField.ObjectCustomFieldDatas) { PredefinitionData predefinitionData = (PredefinitionData)data.CustomFieldDataId; NAS.DAL.Inventory.Command.InventoryCommand Command = session.GetObjectByKey <NAS.DAL.Inventory.Command.InventoryCommand>(predefinitionData.RefId); if (Command != null) { CustomFieldDataPreDefinitionDataItem item = new CustomFieldDataPreDefinitionDataItem() { CustomFieldDataId = predefinitionData.CustomFieldDataId, PredefinitionType = predefinitionData.PredefinitionType, RefId = predefinitionData.RefId, DisplayText = Command.Name }; ret.Add(item); } } } return(ret); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
public CustomFieldDataPreDefinitionData GetData(Guid objectCustomFieldId) { CustomFieldDataPreDefinitionData ret = null; Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomField objectCustomField = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); if (objectCustomField.ObjectCustomFieldDatas != null) { ret = new CustomFieldDataPreDefinitionData(); foreach (var data in objectCustomField.ObjectCustomFieldDatas) { PredefinitionData predefinitionData = (PredefinitionData)data.CustomFieldDataId; Item itemData = session.GetObjectByKey <Item>(predefinitionData.RefId); if (itemData != null) { CustomFieldDataPreDefinitionDataItem item = new CustomFieldDataPreDefinitionDataItem() { CustomFieldDataId = predefinitionData.CustomFieldDataId, PredefinitionType = predefinitionData.PredefinitionType, RefId = predefinitionData.RefId, DisplayText = String.Format("{0} - {1}", itemData.Code, itemData.Name) }; ret.Add(item); } } } return(ret); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
public override NASCustomFieldPredefinitionData GetPredefinitionDataOfObject(Guid objectCustomFieldId) { NASCustomFieldPredefinitionData ret = null; Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomFieldData objectCustomFieldData = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId).ObjectCustomFieldDatas.FirstOrDefault(); if (objectCustomFieldData != null) { PredefinitionData predefinitionData = (PredefinitionData)objectCustomFieldData.CustomFieldDataId; Organization customer = session.GetObjectByKey <Organization>(predefinitionData.RefId); if (customer != null) { ret = new NASCustomFieldPredefinitionData() { Code = customer.Code, Description = customer.Description, Name = customer.Name, PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum), SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_CUSTOMER), RefId = customer.OrganizationId }; } } return(ret); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
public override NASCustomFieldPredefinitionData GetPredefinitionDataOfObject(Guid objectCustomFieldId) { NASCustomFieldPredefinitionData ret = null; Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomFieldData objectCustomFieldData = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId).ObjectCustomFieldDatas.FirstOrDefault(); if (objectCustomFieldData != null) { PredefinitionData predefinitionData = (PredefinitionData)objectCustomFieldData.CustomFieldDataId; SalesInvoice salesInvoice = session.GetObjectByKey <SalesInvoice>(predefinitionData.RefId); if (salesInvoice != null) { ret = new NASCustomFieldPredefinitionData() { Code = salesInvoice.Code, Description = String.Empty, Name = String.Empty, PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum), SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_INVOICE_SALE), RefId = salesInvoice.BillId }; } } return(ret); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
public override NASCustomFieldPredefinitionData GetPredefinitionDataOfObject(Guid objectCustomFieldId) { NASCustomFieldPredefinitionData ret = null; Session session = null; try { session = XpoHelper.GetNewSession(); ObjectCustomFieldData objectCustomFieldData = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId).ObjectCustomFieldDatas.FirstOrDefault(); if (objectCustomFieldData != null) { PredefinitionData predefinitionData = (PredefinitionData)objectCustomFieldData.CustomFieldDataId; InventoryCommand command = session.GetObjectByKey <InventoryCommand>(predefinitionData.RefId); if (command != null) { ret = new NASCustomFieldPredefinitionData() { Code = command.Code, Description = command.Description, Name = command.Name, PredefinitionType = Enum.GetName(typeof(SingleSelectionBuiltInTypeEnum), SingleSelectionBuiltInTypeEnum.SINGLE_CHOICE_LIST_INPUT_INVENTORY_COMMAND), RefId = command.InventoryCommandId }; } } return(ret); } catch (Exception) { throw; } finally { if (session != null) { session.Dispose(); } } }
/// <summary> /// Get supplier that allocated for the ReceiptVouchesTransaction /// </summary> /// <param name="session">DevExpress.Xpo.Session</param> /// <param name="transactionId">Id of type ReceiptVouchesTransaction</param> /// <returns></returns> public Organization GetAllocatedSupplier(Session session, Guid transactionId) { Organization ret = null; try { ReceiptVouchesTransaction transaction = session.GetObjectByKey <ReceiptVouchesTransaction>(transactionId); TransactionObject transactionObject = transaction.TransactionObjects.First(); if (transactionObject == null) { return(null); } ObjectTypeCustomField objectTypeCustomField = ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SUPPLIER); ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where( r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId == objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault(); if (objectCustomField == null) { return(null); } ObjectCustomFieldData objectCustomFieldData = objectCustomField.ObjectCustomFieldDatas.FirstOrDefault(); if (objectCustomFieldData == null) { return(null); } PredefinitionData predefinitionData = (PredefinitionData)objectCustomFieldData.CustomFieldDataId; ret = session.GetObjectByKey <Organization>(predefinitionData.RefId); return(ret); } catch (Exception) { throw; } }
public InventoryCommand GetAllocatedInputInventoryCommandByManualTransaction(Session session, Guid manualBookingTransactionId) { InventoryCommand ret = null; try { Transaction transaction = session.GetObjectByKey <Transaction>(manualBookingTransactionId); TransactionObject transactionObject = transaction.TransactionObjects.First(); if (transactionObject == null) { return(null); } ObjectTypeCustomField objectTypeCustomField = ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_INPUT_INVENTORY_COMMAND); ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where( r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId == objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault(); if (objectCustomField == null) { return(null); } ObjectCustomFieldData objectCustomFieldData = objectCustomField.ObjectCustomFieldDatas.FirstOrDefault(); if (objectCustomFieldData == null) { return(null); } PredefinitionData predefinitionData = (PredefinitionData)objectCustomFieldData.CustomFieldDataId; ret = session.GetObjectByKey <InventoryCommand>(predefinitionData.RefId); return(ret); } catch (Exception) { throw; } }
public NAS.DAL.Invoice.PurchaseInvoice GetAllocatedPurchaseInvoiceByManualTransaction(Session session, Guid manualBookingTransactionId) { NAS.DAL.Invoice.PurchaseInvoice ret = null; try { Transaction transaction = session.GetObjectByKey <Transaction>(manualBookingTransactionId); TransactionObject transactionObject = transaction.TransactionObjects.First(); if (transactionObject == null) { return(null); } ObjectTypeCustomField objectTypeCustomField = ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_PURCHASE_INVOICE); ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where( r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId == objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault(); if (objectCustomField == null) { return(null); } ObjectCustomFieldData objectCustomFieldData = objectCustomField.ObjectCustomFieldDatas.FirstOrDefault(); if (objectCustomFieldData == null) { return(null); } PredefinitionData predefinitionData = (PredefinitionData)objectCustomFieldData.CustomFieldDataId; ret = session.GetObjectByKey <NAS.DAL.Invoice.PurchaseInvoice>(predefinitionData.RefId); return(ret); } catch (Exception) { throw; } }
public NAS.DAL.Invoice.PurchaseInvoice GetAllocatedPurchaseInvoiceByInventoryCommand(Session session, Guid inventoryCommandId) { NAS.DAL.Invoice.PurchaseInvoice ret = null; try { InventoryCommand command = session.GetObjectByKey <InventoryCommand>(inventoryCommandId); InventoryCommandObject commandObject = command.InventoryCommandObjects.First(); if (commandObject == null) { return(null); } ObjectTypeCustomField objectTypeCustomField = ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.INVENTORY_IN_PURCHASE_INVOICE); ObjectCustomField objectCustomField = commandObject.ObjectId.ObjectCustomFields.Where( r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId == objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault(); if (objectCustomField == null) { return(null); } ObjectCustomFieldData objectCustomFieldData = objectCustomField.ObjectCustomFieldDatas.FirstOrDefault(); if (objectCustomFieldData == null) { return(null); } PredefinitionData predefinitionData = (PredefinitionData)objectCustomFieldData.CustomFieldDataId; ret = session.GetObjectByKey <NAS.DAL.Invoice.PurchaseInvoice>(predefinitionData.RefId); return(ret); } catch (Exception) { throw; } }
public NAS.DAL.Nomenclature.Organization.Organization GetAllocatedCustomerByManualTransaction(Session session, Guid manualBookingTransactionId) { NAS.DAL.Nomenclature.Organization.Organization ret = null; try { Transaction transaction = session.GetObjectByKey <Transaction>(manualBookingTransactionId); TransactionObject transactionObject = transaction.TransactionObjects.First(); if (transactionObject == null) { return(null); } ObjectTypeCustomField objectTypeCustomField = ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_CUSTOMER); ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where( r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId == objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault(); if (objectCustomField == null) { return(null); } ObjectCustomFieldData objectCustomFieldData = objectCustomField.ObjectCustomFieldDatas.FirstOrDefault(); if (objectCustomFieldData == null) { return(null); } PredefinitionData predefinitionData = (PredefinitionData)objectCustomFieldData.CustomFieldDataId; ret = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(predefinitionData.RefId); return(ret); } catch (Exception) { return(null); } }
public bool UpdateCustomFieldData(Guid objectCustomFieldId, IEnumerable <Guid> refIds, PredefinitionCustomFieldTypeEnum preDefinitionType, CustomFieldTypeFlag flag) { bool ret = false; UnitOfWork uow = null; try { uow = XpoHelper.GetNewUnitOfWork(); ObjectCustomField objectCustomField = uow.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); objectCustomField.CustomFieldType = flag.Value; uow.FlushChanges(); NAS.DAL.CMS.ObjectDocument.CustomField customField = objectCustomField.ObjectTypeCustomFieldId.CustomFieldId; //Delete all old data uow.Delete(objectCustomField.ObjectCustomFieldDatas); uow.FlushChanges(); //Insert new data for object if (refIds != null) { foreach (var refId in refIds) { PredefinitionData predefinitionData = new PredefinitionData(uow) { CustomFieldId = customField, PredefinitionType = Enum.GetName(typeof(PredefinitionCustomFieldTypeEnum), preDefinitionType), RefId = refId }; //predefinitionData.Save(); ObjectCustomFieldData objectCustomFieldData = new ObjectCustomFieldData(uow) { CustomFieldDataId = predefinitionData, ObjectCustomFieldId = objectCustomField }; //objectCustomFieldData.Save(); uow.FlushChanges(); } } ICustomFieldDataPreDefinitionDataGetter getter = GetDataGetter(preDefinitionType); ObjectBO objectBO = new ObjectBO(); DynamicObjectListSerializeDataItem dataitem = new DynamicObjectListSerializeDataItem() { ObjectCustomFieldId = objectCustomFieldId, CustomFieldName = customField.Name, CustomFieldData = getter.GetData(objectCustomFieldId).ToString() }; objectBO.SetDynamicObjectListItem(uow, objectCustomField.ObjectId.ObjectId, dataitem); uow.CommitChanges(); ret = true; return(ret); } catch (Exception) { throw; } finally { if (uow != null) { uow.Dispose(); } } }