private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e == null || e.Value == null || !(sender is DataGridView))
return;
DataGridView view = (DataGridView)sender;
try
{
if (view.Columns[e.ColumnIndex].DataPropertyName == "InOrOut")
{
int val = Convert.ToInt32(e.Value);
switch (val)
{
case 0:
e.Value = "进场";
break;
case 1:
e.Value = "出场";
break;
default:
break;
}
e.FormattingApplied = true;
}
if (view.Columns[e.ColumnIndex].DataPropertyName == "ParkingLotID")
{
int val = Convert.ToInt32(e.Value);
ACS_Parking.Model.tc_parkinglotinfo modelParkingLotInfo=bll_parkinglotinfo.GetModel(val);
if (modelParkingLotInfo != null)
{
e.Value = modelParkingLotInfo.ParkingLotName;
}
e.FormattingApplied = true;
}
}
catch (System.Exception ex)
{
e.FormattingApplied = false;
MessageBox.Show(ex.ToString());
}
}