SHOW:
|
|
- or go back to the newest paste.
| 1 | using System; | |
| 2 | using System.Net; | |
| 3 | using System.Windows; | |
| 4 | using System.Windows.Controls; | |
| 5 | using System.Windows.Documents; | |
| 6 | using System.Windows.Ink; | |
| 7 | using System.Windows.Input; | |
| 8 | using System.Windows.Media; | |
| 9 | using System.Windows.Media.Animation; | |
| 10 | using System.Windows.Shapes; | |
| 11 | using Microsoft.Practices.Prism.ViewModel; | |
| 12 | using System.Data.Linq.Mapping; | |
| 13 | using System.ComponentModel; | |
| 14 | - | using System.Xml.Serialization; |
| 14 | + | |
| 15 | - | using System.IO; |
| 15 | + | |
| 16 | - | using Bick.Budget.Data.ValueTypes; |
| 16 | + | namespace Bick.Budget.Entities.Transactions |
| 17 | {
| |
| 18 | - | using System.Collections; |
| 18 | + | |
| 19 | public class Transaction : NotificationObject | |
| 20 | - | namespace Bick.Budget.Data.Transactions |
| 20 | + | |
| 21 | #region Fields | |
| 22 | - | /// <summary> |
| 22 | + | |
| 23 | - | /// Describes financial transaction |
| 23 | + | /// Stores transaction id |
| 24 | - | /// </summary> |
| 24 | + | |
| 25 | private Guid id; | |
| 26 | ||
| 27 | /// <summary> | |
| 28 | /// Stores transaction name | |
| 29 | /// </summary> | |
| 30 | - | /// Unique ID for transaction |
| 30 | + | |
| 31 | ||
| 32 | /// <summary> | |
| 33 | /// Stores amount of transaction | |
| 34 | /// </summary> | |
| 35 | - | /// Unique ID for category |
| 35 | + | |
| 36 | ||
| 37 | /// <summary> | |
| 38 | /// Stores date when transaction was created | |
| 39 | /// </summary> | |
| 40 | - | /// Transaction's name |
| 40 | + | |
| 41 | ||
| 42 | /// <summary> | |
| 43 | /// Stores date when transaction was marked as completed (paid/received) | |
| 44 | /// </summary> | |
| 45 | - | /// Transaction's description |
| 45 | + | private DateTime? dateCompleted; |
| 46 | ||
| 47 | - | private string description; |
| 47 | + | |
| 48 | /// Stores date when transaction is planned to be completed | |
| 49 | /// </summary> | |
| 50 | - | /// Amount of transaction |
| 50 | + | private DateTime? datePlanned; |
| 51 | ||
| 52 | /// <summary> | |
| 53 | /// Stores parent category entity | |
| 54 | /// </summary> | |
| 55 | - | /// Transaction added date |
| 55 | + | |
| 56 | ||
| 57 | /// <summary> | |
| 58 | /// Stores parent category ID | |
| 59 | /// </summary> | |
| 60 | - | /// Parent category object |
| 60 | + | |
| 61 | #endregion | |
| 62 | ||
| 63 | #region Constructors | |
| 64 | /// <summary> | |
| 65 | /// Default constructor for Transaction class | |
| 66 | /// </summary> | |
| 67 | - | /// Constructor for Transaction object |
| 67 | + | |
| 68 | {
| |
| 69 | this.ID = Guid.NewGuid(); | |
| 70 | this.DateAdded = DateTime.Now; | |
| 71 | } | |
| 72 | #endregion | |
| 73 | ||
| 74 | #region Properties | |
| 75 | #region Columns | |
| 76 | /// <summary> | |
| 77 | /// Gets transaction ID | |
| 78 | /// </summary> | |
| 79 | - | /// Gets transaction unique ID |
| 79 | + | |
| 80 | public Guid ID | |
| 81 | {
| |
| 82 | get | |
| 83 | {
| |
| 84 | return this.id; | |
| 85 | } | |
| 86 | ||
| 87 | private set | |
| 88 | {
| |
| 89 | if (this.id != value) | |
| 90 | {
| |
| 91 | this.id = value; | |
| 92 | this.RaisePropertyChanged(() => this.ID); | |
| 93 | } | |
| 94 | } | |
| 95 | } | |
| 96 | ||
| 97 | /// <summary> | |
| 98 | /// Gets or sets transaction name | |
| 99 | /// </summary> | |
| 100 | - | /// Gets transaction parent category ID |
| 100 | + | |
| 101 | public string Name | |
| 102 | {
| |
| 103 | get | |
| 104 | {
| |
| 105 | return this.name; | |
| 106 | } | |
| 107 | ||
| 108 | set | |
| 109 | {
| |
| 110 | if (this.name != value) | |
| 111 | {
| |
| 112 | this.name = value; | |
| 113 | this.RaisePropertyChanged(() => this.Name); | |
| 114 | } | |
| 115 | - | this.RaisePropertyChanged(() => this.CategoryID); |
| 115 | + | |
| 116 | } | |
| 117 | ||
| 118 | /// <summary> | |
| 119 | /// Gets or sets transaction amount | |
| 120 | /// </summary> | |
| 121 | [Column] | |
| 122 | [DefaultValue(0)] | |
| 123 | public double Amount | |
| 124 | {
| |
| 125 | get | |
| 126 | {
| |
| 127 | return this.amount; | |
| 128 | } | |
| 129 | ||
| 130 | set | |
| 131 | {
| |
| 132 | if (this.amount != value) | |
| 133 | {
| |
| 134 | this.amount = value; | |
| 135 | this.RaisePropertyChanged(() => this.Amount); | |
| 136 | } | |
| 137 | } | |
| 138 | } | |
| 139 | ||
| 140 | /// <summary> | |
| 141 | /// Gets date when transaction was created | |
| 142 | /// </summary> | |
| 143 | - | /// Gets or sets amount of transaction |
| 143 | + | |
| 144 | public DateTime DateAdded | |
| 145 | {
| |
| 146 | get | |
| 147 | {
| |
| 148 | return this.dateAdded; | |
| 149 | } | |
| 150 | ||
| 151 | private set | |
| 152 | {
| |
| 153 | if (this.dateAdded != value) | |
| 154 | {
| |
| 155 | this.dateAdded = value; | |
| 156 | this.RaisePropertyChanged(() => this.DateAdded); | |
| 157 | } | |
| 158 | } | |
| 159 | } | |
| 160 | ||
| 161 | /// <summary> | |
| 162 | /// Gets or sets date when transaction was marked as completed (paid/received) | |
| 163 | /// </summary> | |
| 164 | [Column(CanBeNull = true)] | |
| 165 | - | /// Gets transaction added date |
| 165 | + | public DateTime? DateCompleted |
| 166 | {
| |
| 167 | get | |
| 168 | {
| |
| 169 | return this.dateCompleted; | |
| 170 | } | |
| 171 | ||
| 172 | set | |
| 173 | {
| |
| 174 | if (this.dateCompleted != value) | |
| 175 | {
| |
| 176 | this.dateCompleted = value.Value; | |
| 177 | this.RaisePropertyChanged(() => this.DateCompleted); | |
| 178 | } | |
| 179 | } | |
| 180 | } | |
| 181 | ||
| 182 | /// <summary> | |
| 183 | /// Gets or sets date when transaction is planned to be completed | |
| 184 | /// </summary> | |
| 185 | [Column(CanBeNull = true)] | |
| 186 | - | #region Objects |
| 186 | + | public DateTime? DatePlanned |
| 187 | {
| |
| 188 | - | /// Gets or sets parent <see cref="Category"/> object |
| 188 | + | |
| 189 | {
| |
| 190 | return this.datePlanned; | |
| 191 | } | |
| 192 | ||
| 193 | set | |
| 194 | {
| |
| 195 | if (this.datePlanned != value) | |
| 196 | {
| |
| 197 | this.datePlanned = value; | |
| 198 | this.RaisePropertyChanged(() => this.DatePlanned); | |
| 199 | } | |
| 200 | } | |
| 201 | } | |
| 202 | ||
| 203 | /// <summary> | |
| 204 | /// Gets parent category ID | |
| 205 | /// </summary> | |
| 206 | [Column(CanBeNull = true)] | |
| 207 | public Guid? CategoryID | |
| 208 | {
| |
| 209 | get | |
| 210 | {
| |
| 211 | return this.categoryID; | |
| 212 | } | |
| 213 | ||
| 214 | private set | |
| 215 | {
| |
| 216 | if (this.categoryID != value) | |
| 217 | {
| |
| 218 | this.categoryID = value; | |
| 219 | this.RaisePropertyChanged(() => this.categoryID); | |
| 220 | } | |
| 221 | } | |
| 222 | } | |
| 223 | #endregion | |
| 224 | ||
| 225 | /// <summary> | |
| 226 | /// Gets or sets parent Category | |
| 227 | /// </summary> | |
| 228 | [Association(Name = "FK_Transactions_Category", Storage = "category", ThisKey = "CategoryID", IsForeignKey = true)] | |
| 229 | public Categories.Category Category | |
| 230 | {
| |
| 231 | get | |
| 232 | {
| |
| 233 | return this.category.Entity; | |
| 234 | } | |
| 235 | ||
| 236 | set | |
| 237 | {
| |
| 238 | Categories.Category previousValue = this.category.Entity; | |
| 239 | if (((previousValue != value) || (this.category.HasLoadedOrAssignedValue == false))) | |
| 240 | {
| |
| 241 | if ((previousValue != null)) | |
| 242 | {
| |
| 243 | this.category.Entity = null; | |
| 244 | previousValue.Transactions.Remove(this); | |
| 245 | } | |
| 246 | ||
| 247 | this.category.Entity = value; | |
| 248 | if ((value != null)) | |
| 249 | {
| |
| 250 | if ((value.AddedTransactions == null) || (!value.AddedTransactions.Contains(this))) | |
| 251 | {
| |
| 252 | value.Transactions.Add(this); | |
| 253 | } | |
| 254 | ||
| 255 | this.CategoryID = value.ID; | |
| 256 | } | |
| 257 | else | |
| 258 | {
| |
| 259 | this.category = new EntityRef<Categories.Category>(); | |
| 260 | } | |
| 261 | ||
| 262 | this.RaisePropertyChanged(() => this.Category); | |
| 263 | } | |
| 264 | } | |
| 265 | } | |
| 266 | #endregion | |
| 267 | } | |
| 268 | } |