要求:具有来自数据库表的记录列表(员工姓名)的组合框说'-nworksuser'和列表以及复选框(供选择)。 根据选择(多个/单个/全部)模式,我需要在所有相关表格中显示数据网格视图中的记录(一对一/一对多)。
Xaml:
<ComboBox Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="2" Grid.RowSpan="2" Height="30" Name="comboBox_Employee" >
</ComboBox>
<DataGrid Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="11" Grid.RowSpan="15" Name="Datagrid_AttendanceLog"/>
.cs来填充组合框:
public partial class AttendanceLog : Window
{
string LiveUser;
public AttendanceLog(string LiveUser)
{
InitializeComponent();
this.LiveUser = LiveUser;
FillComboEmpName();
}
void FillComboEmpName()
{
int eno;
MySqlConnection conn4;
conn4 = new MySqlConnection("server=localhost;uid=root;database=newcompanydatabase;pwd=Admin@123;");
string Query = "select * from nWorksUser where _type='Employee' or _type='Admin_Employee';";
MySqlCommand cmd2 = new MySqlCommand(Query, conn4);
try
{
conn4.Open();
MySqlDataReader rdr;
rdr = cmd2.ExecuteReader();
while (rdr.Read())
{
string user = rdr.GetString("Username");
comboBox_Employee.Items.Add(user);
}
}
}
如何为每个记录和代码添加复选框以在datagrid视图中显示相关记录?