Skip to content

Instantly share code, notes, and snippets.

@fpopic
Created June 24, 2015 19:12
Show Gist options
  • Select an option

  • Save fpopic/bd280e7f929d6aae13c6 to your computer and use it in GitHub Desktop.

Select an option

Save fpopic/bd280e7f929d6aae13c6 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace BLL
{
public partial class Bill : IDataErrorInfo, INotifyPropertyChanged
{
private int id;
private int contractId;
private DateTime dateIssued;
private DateTime? paymentDeadline;
private decimal? discount;
private bool paid;
public int Id
{
get { return id; }
set
{
id = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Id"));
}
}
public int ContractId
{
get { return contractId; }
set
{
contractId = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("ContractId"));
}
}
public DateTime DateIssued
{
get { return dateIssued; }
set
{
dateIssued = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("DateIssued"));
}
}
public DateTime? PaymentDeadline
{
get { return paymentDeadline; }
set
{
paymentDeadline = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("PaymentDeadline"));
}
}
public decimal? Discount
{
get { return discount; }
set
{
discount = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Discount"));
}
}
public bool Paid
{
get { return paid; }
set
{
paid = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Paid"));
}
}
#region IDataErrorInfo Members
public string Error
{
get
{
var sb = new StringBuilder();
if (!string.IsNullOrWhiteSpace(this["ContractId"]))
{
sb.AppendLine(this["ContractId"]);
}
if (!string.IsNullOrWhiteSpace(this["DateIssued"]))
{
sb.AppendLine(this["DateIssued"]);
}
if (!string.IsNullOrWhiteSpace(this["Paid"]))
{
sb.AppendLine(this["Paid"]);
}
return sb.Length > 0 ? sb.ToString() : String.Empty;
}
}
public string this[string columnName]
{
get
{
switch (columnName)
{
case "ContractId":
return ContractId == 0 ? "Nije odabran ugovor!" : String.Empty;
case "DateIssued":
return DateIssued == null ? "Nije odabran datum izdanja!" : String.Empty;
case "Paid":
return paid == null ? "Nije odabran status!" : String.Empty;
default:
return String.Empty;
}
}
}
#endregion
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment