public void Init(branchListItem item) { this.Name = item.Name; this.Num = item.Num; this.City = item.City; this.Asset = item.Asset; }
private void BtnClickQue(object sender, RoutedEventArgs e) { data.Clear(); data.Add(colHead); string sqlStr = "select * from branch;"; MySqlCommand cmd = new MySqlCommand(sqlStr, con); MySqlDataReader reader = null; try { reader = cmd.ExecuteReader(); branchListItem item = new branchListItem(); while (reader.Read()) { item.Name = reader.GetString("branchName"); item.Num = reader.GetString("bankNum"); item.City = reader.GetString("branchCity"); item.Asset = reader.GetString("branchAsset").ToString(); data.Add(new branchListItem(item)); } TxtAlert.Text = "query success!"; } catch (MySqlException ex) { TxtAlert.Text = "Fail to execute sql command\nError message: "; TxtAlert.Text += ex.Message; } finally { reader.Close(); } }
public branchListItem(branchListItem item) { Init(item); }