98 lines
3.5 KiB
C#
98 lines
3.5 KiB
C#
using DevExpress.Data.Filtering;
|
|
using DevExpress.ExpressApp;
|
|
using DevExpress.ExpressApp.DC;
|
|
using DevExpress.ExpressApp.Model;
|
|
using DevExpress.Persistent.Base;
|
|
using DevExpress.Persistent.BaseImpl;
|
|
using DevExpress.Persistent.Validation;
|
|
using DevExpress.Xpo;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace DurnyklyYol.Module.BusinessObjects
|
|
{
|
|
[DefaultClassOptions, NavigationItem("Finance")]
|
|
[ImageName("BO_Invoice")]
|
|
[DefaultProperty(nameof(No))]
|
|
//[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
|
|
//[Persistent("DatabaseTableName")]
|
|
// Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
|
|
public class Expense : BaseObject
|
|
{ // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
|
|
// Use CodeRush to create XPO classes and properties with a few keystrokes.
|
|
// https://docs.devexpress.com/CodeRushForRoslyn/118557
|
|
public Expense(Session session)
|
|
: base(session)
|
|
{
|
|
}
|
|
public override void AfterConstruction()
|
|
{
|
|
base.AfterConstruction();
|
|
ExpenseDate = DateTime.Now;
|
|
}
|
|
|
|
protected override void OnSaving()
|
|
{
|
|
base.OnSaving();
|
|
if (Session is not NestedUnitOfWork
|
|
&& (Session.DataLayer != null)
|
|
&& Session.IsNewObject(this)
|
|
&& (Session.ObjectLayer is SimpleObjectLayer)
|
|
//OR
|
|
//&& !(Session.ObjectLayer is DevExpress.ExpressApp.Security.ClientServer.SecuredSessionObjectLayer)
|
|
&& string.IsNullOrEmpty(No))
|
|
{
|
|
int nextSequence = DistributedIdGeneratorHelper.Generate(Session.DataLayer, this.GetType().FullName, "ERPrefix");
|
|
No = string.Format("ÇD-{0:D6}", nextSequence);
|
|
}
|
|
}
|
|
|
|
string description;
|
|
string no;
|
|
decimal amount;
|
|
Cargo cargo;
|
|
DateTime expenseDate;
|
|
|
|
[Size(SizeAttribute.DefaultStringMappingFieldSize), RuleUniqueValue, Indexed(Unique = true), ReadOnly(true), VisibleInDetailView(false)]
|
|
public string No
|
|
{
|
|
get => no;
|
|
set => SetPropertyValue(nameof(No), ref no, value);
|
|
}
|
|
|
|
[RuleValueComparison(ValueComparisonType.GreaterThan, 0)]
|
|
[ModelDefault("DisplayFormat", "${0:#,##0.00}")]
|
|
public decimal Amount
|
|
{
|
|
get => amount;
|
|
set => SetPropertyValue(nameof(Amount), ref amount, value);
|
|
}
|
|
|
|
[RuleRequiredField(DefaultContexts.Save)]
|
|
[ModelDefault("DisplayFormat", "{0:g}"), ModelDefault("EditMask", "g")]
|
|
public DateTime ExpenseDate
|
|
{
|
|
get => expenseDate;
|
|
set => SetPropertyValue(nameof(ExpenseDate), ref expenseDate, value);
|
|
}
|
|
|
|
|
|
[Association("Cargo-Expenses"), RuleRequiredField(DefaultContexts.Save)]
|
|
public Cargo Cargo
|
|
{
|
|
get => cargo;
|
|
set => SetPropertyValue(nameof(Cargo), ref cargo, value);
|
|
}
|
|
|
|
|
|
[Size(SizeAttribute.DefaultStringMappingFieldSize), RuleRequiredField(DefaultContexts.Save)]
|
|
public string Description
|
|
{
|
|
get => description;
|
|
set => SetPropertyValue(nameof(Description), ref description, value);
|
|
}
|
|
}
|
|
} |