public void AddCollateral(ContractCollateral contractCollateral, int contractId, SqlTransaction pSqlTransac) { string q = @"INSERT INTO [CollateralsLinkContracts] ([contract_id]) VALUES (@contract_id) SELECT CONVERT(int, SCOPE_IDENTITY())"; using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac)) { c.AddParam("@contract_id", contractId); contractCollateral.Id = Convert.ToInt32(c.ExecuteScalar()); } foreach (CollateralPropertyValue propertyValue in contractCollateral.PropertyValues) { AddCollateralPropertyValue(contractCollateral, propertyValue, pSqlTransac); } }
public void AddCollateralPropertyValue(ContractCollateral contractCollateral, CollateralPropertyValue propertyValue, SqlTransaction pSqlTransac) { string q = @"INSERT INTO [CollateralPropertyValues] ([contract_collateral_id], [property_id], [value]) VALUES (@contract_collateral_id, @property_id, @value)"; using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac)) { c.AddParam("@contract_collateral_id", contractCollateral.Id); c.AddParam("@property_id", propertyValue.Property.Id); c.AddParam("@value", propertyValue.Value); c.ExecuteNonQuery(); } }
public void AddCollateral(ContractCollateral pCollateral) { _collaterals.Add(pCollateral); }
private List<ContractCollateral> GetCollaterals(int pLoanId) { List<int> collateralIds = new List<int>(); const string q = @"SELECT [id] FROM [CollateralsLinkContracts] WHERE contract_id = @contract_id "; using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) { c.AddParam("@contract_id", pLoanId); using (OpenCbsReader r = c.ExecuteReader()) { if (r == null || r.Empty) return new List<ContractCollateral>(); while (r.Read()) collateralIds.Add(r.GetInt("id")); } } List<ContractCollateral> contractCollaterals = new List<ContractCollateral>(); foreach (int collateralId in collateralIds) { ContractCollateral contractCollateral = new ContractCollateral(); List<CollateralPropertyValue> propertyValues = new List<CollateralPropertyValue>(); string sqlPropertyText = @"SELECT [contract_collateral_id], [property_id], [value] FROM [CollateralPropertyValues] WHERE contract_collateral_id = @contract_collateral_id "; using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(sqlPropertyText, conn)) { c.AddParam("@contract_collateral_id", collateralId); using (OpenCbsReader r = c.ExecuteReader()) { if (r == null || r.Empty) return new List<ContractCollateral>(); while (r.Read()) { CollateralPropertyValue propertyValue = new CollateralPropertyValue { Id = collateralId, Property = new CollateralProperty { Id = r.GetInt("property_id") }, //Property. = _collateralProductManager.SelectCollateralProperty(r.GetInt("property_id")), Value = r.GetString("value") }; propertyValues.Add(propertyValue); } } } foreach (CollateralPropertyValue propertyValue in propertyValues) { propertyValue.Property = _collateralProductManager.SelectCollateralProperty(propertyValue.Property.Id); } contractCollateral.PropertyValues = propertyValues; contractCollaterals.Add(contractCollateral); } return contractCollaterals; }
private void FillCollateralPropertyValues(ContractCollateral contractCollateral) { foreach (CollateralPropertyValue propertyValue in contractCollateral.PropertyValues) { CustomProperty myProp = null; if (propertyValue.Property.Type == OCollateralPropertyTypes.Number) { myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, Converter.CustomFieldValueToDecimal(propertyValue.Value), typeof(decimal), false, true); } else if (propertyValue.Property.Type == OCollateralPropertyTypes.String) { myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, propertyValue.Value, typeof(string), false, true); } else if (propertyValue.Property.Type == OCollateralPropertyTypes.Date) { myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, Converter.CustomFieldValueToDate(propertyValue.Value), typeof(DateTime), false, true); } else if (propertyValue.Property.Type == OCollateralPropertyTypes.Collection) { if (propertyValue.Value != null) { Collection.Items = propertyValue.Property.Collection; collections.Add(propertyValue.Property.Name, propertyValue.Property.Collection); myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, Collection.Items[int.Parse(propertyValue.Value)], typeof(CollectionType), false, true); } else { Collection.Items = propertyValue.Property.Collection; collections.Add(propertyValue.Property.Name, propertyValue.Property.Collection); myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, string.Empty, typeof(CollectionType), false, true); } } else if (propertyValue.Property.Type == OCollateralPropertyTypes.Owner) { if (propertyValue.Value != null) { Person client = (Person)ServicesProvider.GetInstance().GetClientServices().FindTiers(int.Parse(propertyValue.Value), OClientTypes.Person); myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, client, typeof(Person), false, true); } else { myProp = new CustomProperty(propertyValue.Property.Name, propertyValue.Property.Description, string.Empty, typeof(Person), false, true); } } myProperties.Add(myProp); } propertyGrid.Refresh(); }
private void buttonCancel_Click(object sender, EventArgs e) { contractCollateral = null; Close(); }
public ContractCollateralForm(CollateralProduct product, ContractCollateral contractCollateral, bool isView) { this.product = product; this.contractCollateral = contractCollateral; myProperties = new CustomClass(); collections = new CollectionList(); InitializeComponent(); FillCollateralPropertyValues(contractCollateral); if(isView) { propertyGrid.Enabled = false; groupBoxOwnerDetails.Enabled = false; buttonSave.Enabled = false; } }
public ContractCollateralForm(CollateralProduct product) { this.product = product; contractCollateral = new ContractCollateral(); myProperties = new CustomClass(); collections = new CollectionList(); InitializeComponent(); FillCollateralProperties(); }
public ContractCollateralForm(CollateralProduct product, IExtensionActivator extensionActivator) { _extensionActivator = extensionActivator; this.product = product; contractCollateral = new ContractCollateral(); myProperties = new CustomClass(); collections = new CollectionList(); InitializeComponent(); FillCollateralProperties(); }