L
labjac
Guest
Hallo
Think I've been staring at the screen for to long, just want to check where I'm going wrong. I need to set a property from a constructor and will then just be get for outside calls. But how to set the CellBackColour based on criteria without using a method, or is a private method for CellBackColour the only way, I don't want to call a method from the constructor. I know this is a simple question, but for some reason it's not making sense.
public class PigeonCellStatusModel
{
private string cellBackcolour;
private string pigeonLocation;
private bool allocatedToProduction;
private string orderNr;
private int aeraNr;
private int zoneNr;
private int rowNr;
private int columnNr;
private bool pigeonEnabled;
/// <summary>
/// Pass row Data from SQL Datatable
/// </summary>
/// <param name="data"></param>
public PigeonCellStatusModel(DataRow RowData)
{
pigeonLocation = RowData[3].ToString();
var pigeonLocationData = new PigeonLocationModel(pigeonLocation);
aeraNr = pigeonLocationData.AreaNr;
zoneNr = pigeonLocationData.ZoneNr;
rowNr = pigeonLocationData.RowNr;
columnNr = pigeonLocationData.ColumnNr;
pigeonEnabled = Convert.ToBoolean(RowData[5]);
allocatedToProduction = Convert.ToBoolean(RowData[6]);
orderNr = RowData[7].ToString();
cellBackcolour = CellBackColour; //This obviously doesn't set the private field.
}
public string CellBackColour
{
get { return cellBackcolour; }
set
{
if (orderNr.Length > 0)
{
cellBackcolour = "Green";
}
else if (!pigeonEnabled)
{
cellBackcolour = "Red";
}
else
{
cellBackcolour = "Grey";
}
}
}
public bool AllocatedToProduction
{
get { return allocatedToProduction; }
}
public string OrderNr
{
get { return orderNr; }
}
}
}
labjac
Continue reading...
Think I've been staring at the screen for to long, just want to check where I'm going wrong. I need to set a property from a constructor and will then just be get for outside calls. But how to set the CellBackColour based on criteria without using a method, or is a private method for CellBackColour the only way, I don't want to call a method from the constructor. I know this is a simple question, but for some reason it's not making sense.
public class PigeonCellStatusModel
{
private string cellBackcolour;
private string pigeonLocation;
private bool allocatedToProduction;
private string orderNr;
private int aeraNr;
private int zoneNr;
private int rowNr;
private int columnNr;
private bool pigeonEnabled;
/// <summary>
/// Pass row Data from SQL Datatable
/// </summary>
/// <param name="data"></param>
public PigeonCellStatusModel(DataRow RowData)
{
pigeonLocation = RowData[3].ToString();
var pigeonLocationData = new PigeonLocationModel(pigeonLocation);
aeraNr = pigeonLocationData.AreaNr;
zoneNr = pigeonLocationData.ZoneNr;
rowNr = pigeonLocationData.RowNr;
columnNr = pigeonLocationData.ColumnNr;
pigeonEnabled = Convert.ToBoolean(RowData[5]);
allocatedToProduction = Convert.ToBoolean(RowData[6]);
orderNr = RowData[7].ToString();
cellBackcolour = CellBackColour; //This obviously doesn't set the private field.
}
public string CellBackColour
{
get { return cellBackcolour; }
set
{
if (orderNr.Length > 0)
{
cellBackcolour = "Green";
}
else if (!pigeonEnabled)
{
cellBackcolour = "Red";
}
else
{
cellBackcolour = "Grey";
}
}
}
public bool AllocatedToProduction
{
get { return allocatedToProduction; }
}
public string OrderNr
{
get { return orderNr; }
}
}
}
labjac
Continue reading...