public BlockBuilding SearchBlock(string search) { BlockBuilding block = new BlockBuilding(); string query = "select * from tblblock where blockId='" + search + "';"; try { databaseConnection.Open(); commandDatabase = new MySqlCommand(query, databaseConnection); MySqlDataReader reader = commandDatabase.ExecuteReader(); while (reader.Read()) { block.setBlockId(reader["blockId"].ToString()); block.setBlockName(reader["name"].ToString()); block.setGender(reader["gender"].ToString()); block.setDescription(reader["description"].ToString()); block.setStatus(reader["status"].ToString()); } databaseConnection.Close(); } catch (Exception ex) { MessageBox.Show("Query Error : " + ex.Message); } return(block); }
private void btnAdd_Click(object sender, EventArgs e) { string blockId = txtBlockId.Text; string blockName = txtBlockName.Text; string gender = txtGender.Text; string description = txtDescription.Text; string status = txtStatus.Text; BlockBuilding block = new BlockBuilding(); block.setBlockId(blockId); block.setBlockName(blockName); block.setGender(gender); block.setDescription(description); block.setStatus(status); BlockController blockController = new BlockController(); bool i = blockController.UpdateBlock(block); if (i == true) { MessageBox.Show("Block Information updated successfully!"); } else { MessageBox.Show("Block Information is not updated successfully!"); } }