## page was renamed from ParticleShapeAsc
= Sample Business Object: ParticleShapeAsc =
{{{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using ArchaeologySiteManager.Data;
using ArchaeologySiteManager.State;
using System.Windows.Forms;
namespace ArchaeologySiteManager.Data.Associations
{
class ParticleShapeAsc : INotifyPropertyChanged
{
public int ParticleShapeID
{
get
{
return _ParticleShapeID;
}
set
{
_ParticleShapeID = value;
objState.DataState = ObjectState.CHANGED;
this.NotifyPropertyChanged("ParticleShapeID");
}
}
public int Percent
{
get
{
return _Percent;
}
set
{
_Percent = value;
objState.DataState = ObjectState.CHANGED;
this.NotifyPropertyChanged("Percent");
}
}
private int LocusIdentity;
private int SupplementID;
private int _ParticleShapeID;
private int _Percent;
//private bool LoadedFromTable;
private ArchDataset.ARCH_Asc_EarthLocusC_ParticleShapeRow row;
private ArchDataset.ARCH_Asc_EarthLocusC_ParticleShapeDataTable table;
private ArchDatasetTableAdapters.ARCH_Asc_EarthLocusC_ParticleShapeTableAdapter tad;
private ObjectState objState;
public event PropertyChangedEventHandler PropertyChanged;
public ParticleShapeAsc()
{
objState = new ObjectState();
objState.SourceState = ObjectState.NEW;
objState.DataState = ObjectState.CHANGED;
LocusIdentity = 0;
SupplementID = 0;
ParticleShapeID = 1;
Percent = 0;
}
public ParticleShapeAsc(ArchDataset.ARCH_Asc_EarthLocusC_ParticleShapeRow r,
ArchDataset.ARCH_Asc_EarthLocusC_ParticleShapeDataTable t,
ArchDatasetTableAdapters.ARCH_Asc_EarthLocusC_ParticleShapeTableAdapter ta)
{
table = t;
tad = ta;
row = r;
objState = new ObjectState();
objState.DataState = ObjectState.UNCHANGED;
objState.SourceState = ObjectState.LOADED_FROM_DB;
LocusIdentity = r.LocusIdentity;
SupplementID = r.SupplementID;
ParticleShapeID = r.ParticleShapeID;
Percent = r.Percent;
}
public bool createdFromDB()
{
return objState.SourceState == ObjectState.LOADED_FROM_DB;
}
//TODO Implement save logic here - NOTE: The datagridview may not update the
// LocusID and SupID values and therefore we may need to allow a fix for that here.
public void save()
{
if (objState.SourceState == ObjectState.NEW)
{
row = table.NewARCH_Asc_EarthLocusC_ParticleShapeRow();
saveRow();
row.EndEdit();
table.Rows.Add(row);
tad.Update(row);
objState.SourceState = ObjectState.LOADED_FROM_DB;
objState.DataState = ObjectState.UNCHANGED;
}
else
{
if (objState.DataState == ObjectState.CHANGED)
{
saveRow();
row.EndEdit();
tad.Update(row);
objState.DataState = ObjectState.UNCHANGED;
}
}
}
///
/// Helper function to set row values from object values.
///
private void saveRow()
{
row.LocusIdentity = this.LocusIdentity;
row.SupplementID = this.SupplementID;
row.ParticleShapeID = this.ParticleShapeID;
row.Percent = this.Percent;
}
///
/// Definitely a hack to get around the fact that the DataGridView doesn't assign the
/// LocusID and SupplementID values.
///
///
///
public void save(
int lid,
int supid,
ArchDataset.ARCH_Asc_EarthLocusC_ParticleShapeDataTable t,
ArchDatasetTableAdapters.ARCH_Asc_EarthLocusC_ParticleShapeTableAdapter ta)
{
LocusIdentity = lid;
SupplementID = supid;
table = t;
tad = ta;
save();
}
private void NotifyPropertyChanged(string name)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
}}}