日期:2014-05-18 浏览次数:21358 次
namespace XXXXX
{
struct sREG
{
public DateTime REGDatetime;
public string REGENo;
public string EName;
public bool REGRed;
public string REGStyle;
public double REGCost;
}
public partial class REquipmentG : Window
{
List<sREG> _listREG = new List<sREG>();
//………………………………
//………………………………
//………………………………
//初始化DataGrid的函数
private bool InitialDataGrid()
{
try
{
SqlDataReader reader = null;
//CommonFunction.SQLSearch此函数返回个Reader
CommonFunction.SQLSearch("select REGDatetime,REGENo,EName,REGRed,REGStyle,REGCost from tEquipments,tREG where tREG.REGENo=tEquipments.ENo", ref MainWindow._cnn, ref reader);
while (reader.Read())
{
sREG tempsREG = new sREG();
tempsREG.REGDatetime = Convert.ToDateTime(reader[0]);
tempsREG.REGENo = Convert.ToString(reader[1]);
tempsREG.EName = Convert.ToString(reader[2]);
tempsREG.REGRed = Convert.ToBoolean(reader[3]);
tempsREG.REGStyle = Convert.ToString(reader[4]);
tempsREG.REGCost = Convert.ToDouble(reader[5]);
_listREG.Add(tempsREG);
}
dgMain.ItemsSource = _listREG;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
//MessageBox.Show(_listREG[0].EName);
return true;
}
}
}
<Canvas >
<DataGrid x:Name="dgMain" Width="400" Height="300"/>
</Canvas>