Fixed some stupid errors re. tags, added VisibilityLevel field

This commit is contained in:
Rick Falkvinge
2014-01-01 07:27:52 +00:00
parent c6f2b11bf0
commit 81059f41b3
6 changed files with 52 additions and 29 deletions
@@ -8,18 +8,19 @@ namespace Swarmops.Basic.Types.Financial
{
public class BasicFinancialTransactionTagSet: IHasIdentity
{
public BasicFinancialTransactionTagSet (int financialTransactionTagSetId, int financialTransactionTagSetTypeId, int organizationId, int order, bool allowUntagged, int profitLossType)
public BasicFinancialTransactionTagSet (int financialTransactionTagSetId, int financialTransactionTagSetTypeId, int organizationId, int order, bool allowUntagged, int visibilityLevel, int profitLossType)
{
this.FinancialTransactionTagSetId = financialTransactionTagSetId;
this.FinancialTransactionTagSetTypeId = financialTransactionTagSetTypeId;
this.OrganizationId = organizationId;
this.Order = order;
this.AllowUntagged = allowUntagged;
this.VisibilityLevel = visibilityLevel;
this.ProfitLossType = profitLossType;
}
public BasicFinancialTransactionTagSet (BasicFinancialTransactionTagSet original):
this (original.FinancialTransactionTagSetId, original.FinancialTransactionTagSetTypeId, original.OrganizationId, original.Order, original.AllowUntagged, original.ProfitLossType)
this (original.FinancialTransactionTagSetId, original.FinancialTransactionTagSetTypeId, original.OrganizationId, original.Order, original.AllowUntagged, original.VisibilityLevel, original.ProfitLossType)
{
// copy ctor
}
@@ -30,6 +31,7 @@ namespace Swarmops.Basic.Types.Financial
public int Order { get; protected set; }
public bool AllowUntagged { get; protected set; }
public int ProfitLossType { get; protected set; }
public int VisibilityLevel { get; protected set; }
#region Implementation of IHasIdentity
@@ -17,7 +17,7 @@ namespace Swarmops.Database
private const string financialTransactionTagSetFieldSequence =
" FinancialTransactionTagSetId,FinancialTransactionTagSetTypeId,OrganizationId,DisplayOrder,AllowUntagged," + // 0-4
"ProfitLossType " + // 5
"VisibilityLevel,ProfitLossType " + // 5-6
"FROM FinancialTransactionTagSets ";
private static BasicFinancialTransactionTagSet ReadFinancialTransactionTagSetFromDataReader(IDataRecord reader)
@@ -27,9 +27,10 @@ namespace Swarmops.Database
int organizationId = reader.GetInt32 (2);
int order = reader.GetInt32 (3);
bool allowUntagged = reader.GetBoolean (4);
int profitLossType = reader.GetInt32(5);
int visibilityLevel = reader.GetInt32(5);
int profitLossType = reader.GetInt32(6);
return new BasicFinancialTransactionTagSet(financialTransactionTagSetId, financialTransactionTagSetTypeId, organizationId, order, allowUntagged, profitLossType);
return new BasicFinancialTransactionTagSet(financialTransactionTagSetId, financialTransactionTagSetTypeId, organizationId, order, allowUntagged, visibilityLevel, profitLossType);
}
#endregion
@@ -82,9 +82,9 @@ namespace Swarmops.Logic.App_GlobalResources {
/// <summary>
/// Looks up a localized string similar to Project.
/// </summary>
internal static string Project {
internal static string ProjectName {
get {
return ResourceManager.GetString("Project", resourceCulture);
return ResourceManager.GetString("ProjectName", resourceCulture);
}
}
}
@@ -123,7 +123,7 @@
<data name="IncomeType" xml:space="preserve">
<value>Income Type</value>
</data>
<data name="Project" xml:space="preserve">
<data name="ProjectName" xml:space="preserve">
<value>Project</value>
</data>
</root>
@@ -35,7 +35,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// Construct data source
List<TagSetDataSourceItem> dataSource = new List<TagSetDataSourceItem>();
List<TagSetDataSourceItem> dataSourceVisibleTags = new List<TagSetDataSourceItem>();
List<TagSetDataSourceItem> dataSourceForcedTags = new List<TagSetDataSourceItem>();
foreach (int tagSetId in _tagSetIds)
{
@@ -47,15 +48,20 @@ namespace Swarmops.Frontend.Pages.v5.Financial
FinancialTransactionTagSet.FromIdentity(tagSetId).
FinancialTransactionTagSetTypeId)
};
dataSource.Add(item);
dataSourceVisibleTags.Add(item);
if (!FinancialTransactionTagSet.FromIdentity(tagSetId).AllowUntagged)
{
dataSourceForcedTags.Add(item);
}
}
// Bind data
this.RepeaterTagLabels.DataSource = dataSource;
this.RepeaterTagDrop.DataSource = dataSource;
this.RepeaterTagDropScript.DataSource = dataSource;
this.RepeaterErrorCheckTags.DataSource = dataSource;
this.RepeaterTagLabels.DataSource = dataSourceVisibleTags;
this.RepeaterTagDrop.DataSource = dataSourceVisibleTags;
this.RepeaterTagDropScript.DataSource = dataSourceVisibleTags;
this.RepeaterErrorCheckTags.DataSource = dataSourceForcedTags;
this.RepeaterTagLabels.DataBind();
this.RepeaterTagDrop.DataBind();
@@ -169,7 +175,11 @@ namespace Swarmops.Frontend.Pages.v5.Financial
if (!String.IsNullOrEmpty(selectedTagString))
{
int selectedTagType = Int32.Parse(selectedTagString);
invoice.FinancialTransaction.CreateTag(FinancialTransactionTagType.FromIdentity(selectedTagType), CurrentUser);
if (selectedTagType != 0)
{
invoice.FinancialTransaction.CreateTag(
FinancialTransactionTagType.FromIdentity(selectedTagType), CurrentUser);
}
}
}
@@ -35,27 +35,33 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// Construct data source
List<TagSetDataSourceItem> dataSource = new List<TagSetDataSourceItem>();
List<TagSetDataSourceItem> dataSourceVisibleTags = new List<TagSetDataSourceItem>();
List<TagSetDataSourceItem> dataSourceForcedTags = new List<TagSetDataSourceItem>();
foreach (int tagSetId in _tagSetIds)
{
TagSetDataSourceItem item = new TagSetDataSourceItem()
{
TagSetId = tagSetId,
TagSetLocalizedName =
FinancialTransactionTagSetType.GetLocalizedName(
FinancialTransactionTagSet.FromIdentity(tagSetId).
FinancialTransactionTagSetTypeId)
};
dataSource.Add(item);
{
TagSetId = tagSetId,
TagSetLocalizedName =
FinancialTransactionTagSetType.GetLocalizedName(
FinancialTransactionTagSet.FromIdentity(tagSetId).
FinancialTransactionTagSetTypeId)
};
dataSourceVisibleTags.Add(item);
if (!FinancialTransactionTagSet.FromIdentity(tagSetId).AllowUntagged)
{
dataSourceForcedTags.Add(item);
}
}
// Bind data
this.RepeaterTagLabels.DataSource = dataSource;
this.RepeaterTagDrop.DataSource = dataSource;
this.RepeaterTagDropScript.DataSource = dataSource;
this.RepeaterErrorCheckTags.DataSource = dataSource;
this.RepeaterTagLabels.DataSource = dataSourceVisibleTags;
this.RepeaterTagDrop.DataSource = dataSourceVisibleTags;
this.RepeaterTagDropScript.DataSource = dataSourceVisibleTags;
this.RepeaterErrorCheckTags.DataSource = dataSourceForcedTags;
this.RepeaterTagLabels.DataBind();
this.RepeaterTagDrop.DataBind();
@@ -172,7 +178,11 @@ namespace Swarmops.Frontend.Pages.v5.Financial
if (!String.IsNullOrEmpty(selectedTagString))
{
int selectedTagType = Int32.Parse(selectedTagString);
claim.FinancialTransaction.CreateTag(FinancialTransactionTagType.FromIdentity(selectedTagType), CurrentUser);
if (selectedTagType != 0)
{
claim.FinancialTransaction.CreateTag(FinancialTransactionTagType.FromIdentity(selectedTagType),
CurrentUser);
}
}
}